javascript - 如何设置 Highchart 中的选项默认处于非事件状态

标签 javascript jquery highcharts

我在这个页面上有这个代码:http://www.highcharts.com/demo/combo

$(function () {
        $('#container').highcharts({
            chart: {
            },
            title: {
                text: 'Combination chart'
            },
            xAxis: {
                categories: ['Apples', 'Oranges', 'Pears', 'Bananas', 'Plums']
            },
            tooltip: {
                formatter: function() {
                    var s;
                    if (this.point.name) { // the pie chart
                        s = ''+
                            this.point.name +': '+ this.y +' fruits';
                    } else {
                        s = ''+
                            this.x  +': '+ this.y;
                    }
                    return s;
                }
            },
            labels: {
                items: [{
                    html: 'Total fruit consumption',
                    style: {
                        left: '40px',
                        top: '8px',
                        color: 'black'
                    }
                }]
            },
            series: [{
                type: 'column',
                name: 'Jane',
                data: [3, 2, 1, 3, 4]
            }, {
                type: 'column',
                name: 'John',
                data: [2, 3, 5, 7, 6]
            }, {
                type: 'column',
                name: 'Joe',
                data: [4, 3, 3, 9, 0]
            }, {
                type: 'spline',
                name: 'Average',
                data: [3, 2.67, 3, 6.33, 3.33],
                marker: {
                    lineWidth: 2,
                    lineColor: Highcharts.getOptions().colors[3],
                    fillColor: 'white'
                }
            }, {
                type: 'pie',
                name: 'Total consumption',
                data: [{
                    name: 'Jane',
                    y: 13,
                    color: Highcharts.getOptions().colors[0] // Jane's color
                }, {
                    name: 'John',
                    y: 23,
                    color: Highcharts.getOptions().colors[1] // John's color
                }, {
                    name: 'Joe',
                    y: 19,
                    color: Highcharts.getOptions().colors[2] // Joe's color
                }],
                center: [100, 80],
                size: 100,
                showInLegend: false,
                dataLabels: {
                    enabled: false
                }
            }]
        });
    });

它在这里生成这个统计数据:

http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/combo/

我希望能够将“John”和“Joe”默认设置为非事件状态。有办法做到这一点吗?不过应该可以激活它们。

最佳答案

您想一开始就以“不可见”状态进行绘制吗?

        {
            type: 'column',
            name: 'Joe',
            data: [4, 3, 3, 9, 0],
            visible: false // <-- set visibility to false
        },

fiddle here .

关于javascript - 如何设置 Highchart 中的选项默认处于非事件状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20163163/

相关文章:

javascript - Highcharts 工具提示看起来很奇怪

javascript - 使用javascript更改文本框文本颜色

javascript - 在选择菜单上使用统一代码

javascript - 我不明白的 jQuery 或 javascript 语法

javascript - 在不同的函数中使用let变量

javascript - 将图表点绘制为实时流 : Highcharts

javascript - dlib http 服务器将网站显示为纯 html,没有 javascript/css

jquery - 下拉菜单改变列表元素的位置

javascript - 无法使用 iOS 向下滚动 100% 高度部分

javascript - Highcharts - redraw() 与 new Highcharts.chart