How can I hide series from a HighCharts legend?

2019-04-03 03:24发布

问题:

I have 4 series in my chart. 2 are visible when the chart loads. 2 are hidden.

When the user zooms in, the visibility switches.

How can I have a legend that only displays the 2 visible series?

回答1:

Pass showInLegend parameter to series you don't want to be visible in legend like:

series.showInLegend = false;