Bewan
Bewan

Reputation: 125

Highchart - Sankey click event for node

i tried to add click event to sankey diagram node. I found link click event is possible, but not node click event. is it possible to add click event to node?

Upvotes: 0

Views: 558

Answers (1)

Sebastian Hajdus
Sebastian Hajdus

Reputation: 1560

In this example you can see how there is a click on point event added to the chart plotOptions, this is one way to add a click to a point.

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);
          }
        },
      }
    }
  },

Another way is a click on point linked using its 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);
    }
  }
}],

Demo: https://jsfiddle.net/BlackLabel/jw8skp1z/

Upvotes: 1

Related Questions