Ale*_*lex 4 javascript jquery highcharts
我正在使用highcharts,并希望在点击重置缩放按钮事件中插入一些逻辑,但我没有找到一个非常好的方法.在StackOverflow中搜索并找到最佳答案是:
event.srcElement.firstChild.data == "Reset zoom"
Run Code Online (Sandbox Code Playgroud)
但这种方式有一个问题,当我们点击"重置缩放"按钮的一角时,不会触发事件.只有当我们点击文本的tSpan'重置缩放'时,这种方式才有效.想问一下是否有另一种解决方案.
Paw*_*Fus 11
只需使用setExtremes事件,请参阅:http://jsfiddle.net/BlackLabel/pjy9682s/3/
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
zoomType: 'x'
},
xAxis: {
events: {
setExtremes: function (e) {
if(typeof e.min == 'undefined' && typeof e.max == 'undefined'){
console.log('reset zoom clicked');
} else {
console.log('zoom-in');
}
}
}
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 29.9, 71.5, 106.4, 129.2, 144.0, 176.0]
}]
});
Run Code Online (Sandbox Code Playgroud)
Highcharts提供称为选择的事件
chart:{
events: {
selection: function() { /* your code here */ }
}
}
Run Code Online (Sandbox Code Playgroud)
这个小提琴将帮助你http://jsfiddle.net/M7cfm/
| 归档时间: |
|
| 查看次数: |
7005 次 |
| 最近记录: |