在highcharts中通過配置禁用系列。

[英]Disable series through configuration in highcharts


I have a line chart with several series. When viewed all at once the chart is confusing, so I would like to have certain series hidden initially.

我有一個系列的線形圖。當查看所有的時候,圖表是令人困惑的,所以我想要有某些系列最初隱藏。

I know I can programmatically turn off series, but is there a way to do this when initializing the chart?

我知道我可以以編程方式關閉系列,但是在初始化圖表時是否有辦法做到這一點呢?

2 个解决方案

#1


27  

Believe there is a configuration option for this.

相信這里有一個配置選項。

Within Series, set "visible = false"

在系列中,設置“可見= false”

The legend will still list the series but greyed out. And the series itself will be hidden in the chart upon initial display.

傳奇仍然會列出這個系列,但會被淘汰。並且這個系列將會隱藏在最初顯示的圖表中。

Example configuration:

示例配置:

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

        }

#2


6  

You can achive this by hiding all the series that you dont want to see just after the chart has completed loading.

您可以通過隱藏所有您不希望在圖完成后看到的系列來實現這一點。

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

小提琴:http://jsfiddle.net/bHDLX/

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

});

});


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2013/05/09/72a06720cc8b26cd2df708bf7afb5788.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com