如何使用ECharts操作关系图中的节点?

How to use ECharts to manipulate nodes in a relationship graph?

我想用ECharts实现一个页面。在此页面中,用户可以使用一些按钮来添加节点(或边缘)或编辑节点(或边缘)的名称。所以我想操纵关系图的节点,例如此处显示的力布局: https://echarts.apache.org/examples/en/editor.html?c=graph-force 现在我的问题是,由于示例中图形的数据是由gexf文件提供的,有没有办法从javascript控制它们?例如添加节点、删除节点或编辑节点(或边)。

示例中使用的数据是 XML 格式,稍后将转换为对象数组,您可以查看该格式并使用 javascript 生成您自己的格式。例如,

var nodes = [
    {
      id: "0",
      name: "",
      itemStyle: null,
      symbolSize: 50,
      attributes: {
        modularity_class: 0
      },
      value: 28.685715,
      label: {
        show: false
      },
      category: 0
    },
    {
      id: "1",
      name: "",
      itemStyle: null,
      symbolSize: 10,
      attributes: {
        modularity_class: 0
      },
      value: 4,
      label: {
        show: false
      },
      category: 0
    },
    {
      id: "2",
      name: "",
      itemStyle: null,
      symbolSize: 10,
      attributes: {
        modularity_class: 0
      },
      value: 9.485714,
      label: {
        show: false
      },
      category: 0
    }];

  var links = [
    {
      id: "0",
      name: null,
      source: "0",
      target: "1",
      lineStyle: {
        normal: {}
      }
    },
    {
      id: "1",
      name: null,
      source: "0",
      target: "2",
      lineStyle: {
        normal: {}
      }];