Disable series through configuration in highcharts

I have a line chart with several series. When viewing all at once, the diagram is confusing, so I would like some series to be hidden initially.

I know that I can programmatically disable a series, but is there a way to do this when initializing a chart?

+7
source share
2 answers

Believe me, there is a configuration option for this.

Inside the series set "visible = false"

The legend will still list the series, but is inactive. And the series itself will be hidden in the chart at initial display.

Configuration Example:

series: [{ name: 'HiddenByDefault', legendIndex: 1, visible: false, color: '#4572A7', type: 'spline', data: [a, b, c], tooltip: { valueSuffix: ' Β₯' } } 
+27
source

You can achieve this by hiding all the episodes that you don’t want to see immediately after the graph has finished loading.

Fiddle: http://jsfiddle.net/bHDLX/

The code:

 $(function () { // create the chart $('#container').highcharts({ chart: { events: { load: function(event) { alert ('Chart loaded'); this.series.forEach(function(d,i){if(d.options.id==1)d.hide()}) } } }, xAxis: { }, series: [{ animation: false, id : 1, 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] }, { animation: false, id : 2, data: [29.9, 144.0, 176.0, 71.5, 106.4, 129.2, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4] },{ animation: false, id : 3, data: [ 194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4] }] }); 

});

+6
source

All Articles