highcharts Highchart -节点的Sankey点击事件

gdrx4gfi  于 2022-11-24  发布在  Highcharts
关注(0)|答案(1)|浏览(161)

我尝试将单击事件添加到sankey图节点。我发现链接单击事件是可能的,但节点单击事件不是。是否可以将单击事件添加到节点?

m1m5dgzv

m1m5dgzv1#

在本例中,您可以看到如何将单击点事件添加到图表plotOptions,这是将单击添加到点的一种方法。
https://api.highcharts.com/highcharts/series.sankey.point.events

plotOptions: {
    series: {
      point: {
        events: {
          click: function() {
            let point = this;
            console.log('click point', point, 'from', point.from, 'to', point.to);
          }
        },
      }
    }
  },

另一种方法是单击使用其id链接的点。
https://api.highcharts.com/highcharts/series.sankey.nodes

nodes: [{
  id: 'Brazil',
}, {
  id: 'Portugal',
  events: {
    click() {
      let series = this.series,
        nodes = series.nodeLookup;
        console.log('click event on node linked by id ', nodes);
    }
  }
}],

演示:https://jsfiddle.net/BlackLabel/jw8skp1z/

相关问题