antvis/G6

如何同时编辑所有节点 #4768

neolee6053 posted onGitHub

问题描述

我们可以实例化图时全局配置,但之后呢?如何才能同时编辑所有节点?比如我要把所有的label暂时藏了

https://g6.antv.antgroup.com/manual/middle/elements/nodes/default-node#%E5%AE%9E%E4%BE%8B%E5%8C%96%E5%9B%BE%E6%97%B6%E5%85%A8%E5%B1%80%E9%85%8D%E7%BD%AE

有没有graph.update({defaultNode: {}})之类的?

====== 另外,有什么简单的方法可以把label藏起来? 如果我把opacity调成0 , background还是会看见 image

重现链接

https://codesandbox.io/s/new

重现步骤

如上

预期行为

如上

平台

  • 操作系统: [ Window.]
  • 网页浏览器: [Firefox]
  • G6 版本: [4.8.15]

屏幕截图或视频(可选)

No response

补充说明(可选)

No response


我也有相同的疑惑

posted by 584sentiment over 1 year ago

graph.updateItem(nodeId, { label: '' });

posted by Yanyan-Wang over 1 year ago

graph.updateItem(nodeId, { label: '' });

谢谢,可是这样会更改data对吧? 如果要切换的话,那原本的label就找不回了?

另外,这是单个node的,没有所有node的吗? 结果现在我用了loop,还有种种merge的问题. 所以,现在我这样做

nodes.forEach(n => { const currentLabelCfg: any = n.getModel().labelCfg; graph.updateItem(n, { labelCfg: merge({}, currentLabelCfg, { style: { opacity: this.showNodeText, background: { fill: this.showNodeText ? '#FFF' : 'transparent' } } }) }); });

posted by neolee6053 over 1 year ago

G6 5.0 已支持配置样式映射,你可以通过 graph.setNode({ label: '' }) 来隐藏所有 label 且不修改数据

posted by Aarebecca 11 months ago

Fund this Issue

$0.00
Funded

Pull requests