-
官方示例 https://x6.antv.vision/en/examples/node/tool#editable 演示了如何双击来创建一段文字。现在想要定制其创建好后的样式。 从各种官网的示例中我学到了:markup 里的 selector 和 attrs 都是用来选择到相关的元素进行样式更迭的,因此我加入了如下图代码,并没有生效? |
Beta Was this translation helpful? Give feedback.
Answered by
cnyballk
Jul 24, 2023
Replies: 3 comments 2 replies
-
Beta Was this translation helpful? Give feedback.
0 replies
-
可以试试用监听的方式改 比如 graph.on('edge:labels:added', (e) => {
e.added[0].attrs = {
label: {
...e.added[0].attrs.label,
fontSize: 34,
fill: '#fff',
},
rect: {
fill: '#000',
},
}
}) 编辑的时候可以 edge.addTools({
name:'edge-editor',
args: {
event: e,
attrs: {
fontSize: 34,
color: '#fff',
backgroundColor: '#000',
},
},
}) |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
hylerrix
-
感谢!这个不看源码还真很难找到。我也还居然没想到第五种思路——x6 已经内置的 edge:labels:added 事件。搞定咯。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
可以试试用监听的方式改 比如
编辑的时候可以