mxgraph - mxgraph 如何获取和设置边缘的标签位置?
问题描述
我想保存边缘标签位置,我发现mxEdgeHandler.prototype.moveLabel
可以得到标签位置,但是之后如何设置标签位置graph.insertEdge
?
解决方案
你可以看看mxGeometry offset
。
For edges, this holds the offset (in pixels) from the position defined
by <x> and <y> on the edge. For relative geometries (for vertices), this
defines the absolute offset from the point defined by the relative coordinates.
For absolute geometries (for vertices), this defines the offset for the label.
Default is null.
如果使用insertEdge
函数,不能直接设置偏移量,但是可以在函数返回的边上更新
const mxEdge = graph.insertEdge(parent, id, 'label', source, target, style);
mxCell.geometry.offset = new this.mxPoint(relativeLabelX, relativeLabelY);
请注意,您可能还必须设置边缘几何形状的 x 和 y 值,因为它们似乎未在创建 egde 时设置。
您也可以先创建边然后将其添加到图形中(这就是 insertEdge 函数为您所做的)。创建边缘 mxCell 时,您可以在将其添加到图形之前设置其几何形状,或者在添加它之后像调用 insertEdge 时一样。
推荐阅读
- python - Ghostscript 9.26 在 PowerPC (ppc64le) 架构上构建失败
- c# - 非泛型方法“ControllerBase.Ok()”不能与类型参数一起使用
- python - TypeError:如何修复仅对 DatetimeIndex、TimedeltaIndex 或 PeriodIndex 有效,但获得了“Index”实例
- python - Django - 电子邮件未发送,但其对象是在数据库中创建的
- node.js - NestJS 拦截器:无法在传出请求上设置 HTTP 标头
- mysql - 多个数据库的多租户数据库连接池
- tensorflow - 使用 Conv 或 Rnn 嵌入的 tf-hub 层的错误输出
- slack - Slack 是否为每个工作空间或组织使用每个服务器实例?
- github - Github API中的限速graphql查询有费用吗?
- swift - 在 Swift 中加快 UIImage 处理速度