在highcharts中选择了rangeSelector按钮

我想知道如何确定在highstock中选择哪个rangeSelector按钮.

我的rangeSelector按钮:

   buttons: [{
            type: 'month',
            count: 1,
            text: '1 MONTH',
        }, {
            type: 'month',
            count: 3,
            text: '3 MONTH'
        }, {
            type: 'month',
            count: 6,
            text: '6 MONTH'
        }, {
            type: 'ytd',
            text: 'YTD'
        }, {
            type: 'year',
            count: 1,
            text: '1 YEAR'
        }, {
            type: 'all',
            text: 'ALL'
        }],

例如,我点击我的第一个rangeSelector,即1个月.我想知道这个按钮是否被选中.

有什么事吗?

谢谢

您可以捕获setExtremes()(http://api.highcharts.com/highstock#xAxis.events.setExtremes),然后在事件obejct中,您可以访问具有count,text和type属性的event.rangeSelectorButton对象.

 xAxis: {
        events: {
            setExtremes: function(e) {
                console.log(this);
                if(typeof(e.rangeSelectorButton)!== 'undefined')
                {
                  alert('count: '+e.rangeSelectorButton.count + 'text: ' +e.rangeSelectorButton.text + ' type:' + e.rangeSelectorButton.type);
                }
            }
        }
    },

http://jsfiddle.net/E6GHC/1/

https://stackoverflow.com/questions/15846859/which-rangeselector-button-is-selected-in-highcharts

转载注明原文:在highcharts中选择了rangeSelector按钮