最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - highcharts how to catch and insert logic in click reset zoom button event - Stack Overflow

programmeradmin0浏览0评论

I'm using highcharts and would like to insert some logic in click reset zoom button event, but I didn't find a very good way. Searched in StackOverflow and found the best answer is:

event.srcElement.firstChild.data == "Reset zoom"

but this way has 1 problem that the event won't be triggered when we click the corner of 'Reset zoom' button. Only when we click on the tSpan of text 'Reset zoom' this way will work. Would like to ask if there's another solution.

I'm using highcharts and would like to insert some logic in click reset zoom button event, but I didn't find a very good way. Searched in StackOverflow and found the best answer is:

event.srcElement.firstChild.data == "Reset zoom"

but this way has 1 problem that the event won't be triggered when we click the corner of 'Reset zoom' button. Only when we click on the tSpan of text 'Reset zoom' this way will work. Would like to ask if there's another solution.

Share Improve this question asked Oct 19, 2013 at 6:14 AlexAlex 812 silver badges4 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 11

Just use setExtremes event, see: 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]
    }]
});

Highcharts provides a event called selection

chart:{
  events: {
    selection: function() { /* your code here */ }
  }
}

this fiddle will help you http://jsfiddle.net/M7cfm/

发布评论

评论列表(0)

  1. 暂无评论