Habib
Habib

Reputation: 300

Highcharts remove legend and series from chart on legendItemClick

Highcharts have default functionality to show/hide series on legend click which can be controlled using legendItemClick event.

We have a requirement to remove both the legend and series from the chart when user click on the legend. JQuery solution is not recommended. Leveraging an existing highcharts event would be great.

Any suggestion? Thanks in advance.

Upvotes: 0

Views: 1441

Answers (2)

Tharindu Marapana
Tharindu Marapana

Reputation: 265

You can remove the legend circle icon and name by using,

series: [{ showInLegend: false, }]

Upvotes: 0

Halvor Holsten Strand
Halvor Holsten Strand

Reputation: 20536

You could utilize the legendItemClick to update the series to hide it from the legend.

Your code could look like this (JSFiddle):

legendItemClick: function(e) {
    this.update({ showInLegend: false });
}

This is assuming you have some external mechanism to make it re-appear. If the series will never appear again you could also simply do this.remove() instead of the update.

Upvotes: 1

Related Questions