user1177860
user1177860

Reputation: 509

Highcharts how to save a selected legend

I am trying to workout if it possible to get a callback from highcharts to say which legend item has been selected or de-selected. Which then I can add into my series data which gets saved, so when I load highcharts up again it has the saved selected legends.

Upvotes: 0

Views: 905

Answers (1)

ewolden
ewolden

Reputation: 5803

Look at series.events.legendItemClick,

legendItemClick: function

Fires when the legend item belonging to the series is clicked. One parameter, event, is passed to the function. The default action is to toggle the visibility of the series. This can be prevented by returning false or calling event.preventDefault().

or series.events.hide which gets called when a series is hidden.

hide: function

Fires when the series is hidden after chart generation time, either by clicking the legend item or by calling .hide().

With one of those in combination with series.visible you should be able to do what you are after.

visible: Boolean

Set the initial visibility of the series.

Defaults to true.

Upvotes: 2

Related Questions