To customize the visibility of series in a Highcharts chart, you can modify the exportChart
method by toggling the showInLegend
property:
var H = Highcharts;
H.wrap(H.Chart.prototype, 'exportChart', function(proceed, exportingOptions) {
var series = this.series;
Highcharts.each(series, function(s) {
if (s.visible) {
s.update({
showInLegend: true
}, false);
} else {
s.update({
showInLegend: false
}, false);
}
});
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
Highcharts.each(series, function(s) {
s.update({
showInLegend: true
}, false);
});
this.redraw();
});
Check out this live demo showcasing the functionality: http://jsfiddle.net/BlackLabel/cgj9vwas/