I have a Highcharts line chart and a number of dynamic series, like this: https://jsfiddle.net/km0jjxue/6/
var chart = Highcharts.chart('container', {
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
visible: true,
}, {
data: [129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4],
visible: true,
}, {
data: [83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3],
visible: false,
}, {
data: [42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1],
visible: false,
}, {
data: [48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2],
visible: false,
}],
});
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px"></div>
I also have a filter, which reloads the chart with new data according to what I select in this filter.
The problem happens when I deselect or select other series in the chart and then change an option in my filter, causing the chart to redraw with the new data and only the first two series are visible again.
What can I do that if I select, for example, Series 3 and Series 4 making their chart data visible, and then choose another option in my filter, so that when the chart reloads with the new data I still have Series 3 and 4 selected as well (and not only Series 1 and Series 2)?