antv G6 更新节点上的数据?

antv G6 如何刷新改变节点上绑定的数据值呢?

阅读 9.1k
1 个回答

findById找到你要更新的节点,然后update就行了
一般两种方式:

// 1
const model = {
  id: 'node',
  label: 'node',
  address: 'cq',
  x: 200,
  y: 150,
  style: {
    fill: 'blue'
  }
}

// 通过ID查询节点实例
const item = graph.findById('node')
graph.updateItem(item, model)

// 2
const model = {
  id: 'node',
  type: 'rect',
  label: 'node',
  style: {
    fill: 'red',
  },
};

const item = graph.findById('node')
item.update(model);
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进