本文介绍了在highcharts中选择了rangeSelector按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的rangeSelector按钮:

pre> 按钮:[{
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'
},{
类型:'year',
count:1,
text:'1 YEAR'
},{
类型:'all',
text:'ALL '
}],

举例来说,我点击我的第一个1个月的rangeSelector。我想知道这个按钮是否被选中。



是否有任何事件?



您可以捕获setExtremes()(),然后在事件obejct中,您可以使用count.textSelector和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);
}
}
}
},


I want to know how to determine which rangeSelector button is selected in highstock.

my rangeSelector buttons:

   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'
        }],

for example I click on my first rangeSelector that is 1 MONTH. I want to know if this button is selected or not.

Is there any event?

Thanks

解决方案

You can catch setExtremes() (http://api.highcharts.com/highstock#xAxis.events.setExtremes), and then in event obejct you have access to event.rangeSelectorButton object with count, text and type property.

 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/

这篇关于在highcharts中选择了rangeSelector按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 23:12