处理rangeSelector按钮,当它超出数据系列的xaxis范围时

时间:2014-07-04 11:42:19

标签: jquery highcharts highstock

数据系列的x轴最小范围是5/15/2006 我发送显示图表的x轴的当前最大值是5/24/2011并且过去7天选择缩放按钮,然后如果我选择过去30天的缩放按钮,因为它超出x-的范围轴,所以我希望它使这个选择无效并保持旧的过去7天缩放按钮,显示图表的范围不会改变。

怎么做?

这是JS代码:

var end = 1148428800000;
var rowcount;

$(function () {
    $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function (data) {

        // Create the chart
        $('#container').highcharts('StockChart', {
            navigator: {
                enabled: false
            },
            scrollbar: {
                enabled: false
            },

            rangeSelector: {
                inputEnabled: false,
                selected: 0,
                buttonTheme: {
                    width: null
                },
                buttons: [{
                    type: 'day',
                    count: 6,
                    text: 'past 7 days'
                }, {
                    type: 'day',
                    count: 14,
                    text: 'past 15 days'
                }, {
                    type: 'day',
                    count: 29,
                    text: 'past 30 days'
                }]
            },

            xAxis: {
                max: end,
                type: 'datetime',
                minTickInterval: 24 * 3600 * 1000,
                events: {
                    setExtremes: function (e) {
                        if (typeof (e.rangeSelectorButton) !== 'undefined') {
                            rowcount = e.rangeSelectorButton.count;
                        }
                    }
                }
            },

            title: {
                text: 'AAPL Stock Price'
            },

            series: [{
                name: 'AAPL Stock Price',
                data: data,
                marker: {
                    enabled: true,
                    radius: 3
                },
                shadow: true,
                tooltip: {
                    valueDecimals: 2
                }
            }]
        });
    });

});

以下是[Jsfiddle]

0 个答案:

没有答案