echarts [Feature] Show related node's label when emphasis a node in force graph with hideOverlap

at0kjp5o  于 5个月前  发布在  Echarts
关注(0)|答案(1)|浏览(95)

What problem does this feature solve?

I use labelLayout.hideOverlap attr to render a tidy canvas when I have many nodes with label. When I emphasis a node, I can see itself is highlight, the related node and their link is highlight. But the related nodes' name only show when I emphasis these nodes one by one.

In some situation such as present a knowledge graph, the label of a node is also it's name. The user need to see the nodes' name that related to a specific node.

I try to add a listener to mouse event, then show all labels when mousemove and hide overlap when mouseout. I show all labels by modify all datas' label attr, then use the setOption function. But because of the large data, the canvas stuck about 1s, what is unacceptable because the mousemove is a frequent event.

What it looks like now:

What I hope is:

What does the proposed API look like?

Maybe add a series.label.showWhenRelated attribute? Like this:

option: {
  series: [{
    type: 'graph',
    layout: 'force',
    ...
    label: {
      show: true,
      position: 'right',
      formatter: '{b}',
      showWhenRelated: true
    },
    labelLayout: {
      hideOverlap: true
    }

Manual using mouse to highlight, and using dispatchAction(multiple nodes) should archieve the expected effect.

eulz3vhy

eulz3vhy1#

This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.

相关问题