简体   繁体   中英

Highcharts hide not active series from legend when taking screenshot

Is it somehow possible to hide all inactive series from legend when taking screenshot?

For example I have chart like this :

在此处输入图片说明

But what I want have on picture is this: 在此处输入图片说明

You can wrap exportChart method and set showInLegend property to false on invisible series:

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);
        }
    });

    // which are sliced off this function's arguments
    proceed.apply(this, Array.prototype.slice.call(arguments, 1));

    Highcharts.each(series, function(s) {
        s.update({
            showInLegend: true
        }, false);
    });

    this.redraw();
});

Live demo: http://jsfiddle.net/BlackLabel/cgj9vwas/

Try this:

series: [{
            showInLegend: false,
            name: 'Series',
            data: value                
        }]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM