apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.48k stars 19.62k forks source link

Get node dataIndex from its ID. #9161

Closed sethwilsonUS closed 3 years ago

sethwilsonUS commented 6 years ago

One-line summary [问题简述]

Since selecting a legend category seems to change a graph node's dataIndex, I would like to be able to access a node's dataIndex by its ID.

Version & Environment [版本及环境]

Expected behaviour [期望结果]

I have found a getNodeById function in the source code, which is the sort of thing I would like to have--find a node's dataIndex based on its ID. But I can't figure out a way to use this functionality in my code.

ECharts option [ECharts配置项]

option = {
    title: {
      text: 'Document Reuse',
      subtext: 'Default layout',
      top: 'bottom',
      left: 'right'
    },
    tooltip: {},
    legend: [{
      data: categories.map(function(category) {
        return category.name;
      })
    }],
    animationDuration: 1500,
    animationEasingUpdate: 'quinticInOut',
    series: [{
      name: 'All Links',
      type: 'graph',
      layout: 'none',
      data: graph.nodes,
      links: graph.links,
      categories: categories,
      roam: true,
      focusNodeAdjacency: true,
      itemStyle: {
        normal: {
          borderColor: '#fff',
          borderWidth: 1,
          shadowBlur: 10,
          shadowColor: 'rgba(0, 0, 0, 0.3)'
        }
      },
      label: {
        position: 'right',
        formatter: '{b}'
      },
      lineStyle: {
        color: 'source',
        curveness: 0.3
      },
      emphasis: {
        lineStyle: {
          width: 10
        }
      }
    }]
};

Other comments [其他信息]

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.