Highcharts autoscale yaxis多个情节带问题

时间:2013-06-24 10:40:57

标签: highcharts

我遇到使用Axis.update方法动态更新yAxis的问题。在对yAxis进行更新时,如果有多个绘图带,则在重绘yAxis时不会删除第二个绘图带,因此它是重复的。我认为这可能是Highcharts(highstock)库中的一个问题,但我想知道是否有人经历过这个并且知道我是否错过了一个设置。

示例:http://jsfiddle.net/heeXA/

HTML:

<div id="chart"></div>
<button id="autoscale">Toggle autoscale</button>

JavaScript的:

$("#chart").highcharts({
    height: 350,
    yAxis: [{
        top: 50,
        height: 200,
        min: 0,
        max: 30,
        tickInterval: 4,
        plotBands: [{
            from: 12,
            to: 16,
            color: "#d9edf7",
            label: {
                "text": "Plot band 1"
            }
        }, {
            from: 20,
            to: 25,
            color: "#dff0d8",
            label: {
                text: "Plot band 2"
            }
        }]
    }],
    series: [{
        type: "line",
        yAxis: 0,
        data: [1, 5, 9, 15, 19, 21, 26, 9]
    }]
});

$("#autoscale").on("click", function () {
    $(this).toggleClass("autoscaled");
    var autoscaled = $(this).hasClass("autoscaled");
    var chart = $("#chart").highcharts();
    chart.yAxis[0].update({
        min: autoscaled ? null : 0,
        max: autoscaled ? null : 30,
        tickInterval: autoscaled ? null : 4
    });
});

更新

这似乎是所有偶数编号乐队的问题! http://jsfiddle.net/StgHu/1/

0 个答案:

没有答案