javascript 如何检测 highcharts 中的缩放事件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12323978/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 15:55:22  来源:igfitidea点击:

How do I detect a zoom event in highcharts?

javascripthighcharts

提问by Andrey

Is it possible to detect a zoom event in Highcharts? My use case is that I have some state external to the chart, and when the user zooms in on part of it I want to detect what the new time range on the x-axis is and update the corresponding external state.

是否可以在 Highcharts 中检测缩放事件?我的用例是我在图表外部有一些状态,当用户放大其中的一部分时,我想检测 x 轴上的新时间范围是什么并更新相应的外部状态。

回答by Jugal Thakkar

Have you tried going through the Highcharts API?

你试过通过Highcharts API吗?

You may want to look @ xAxis.events.setExtremesAnd/Or chart.events.selection

你可能想看看@ xAxis.events.setExtremes和/或 chart.events.selection

回答by Ayoub

You want to look at the redraw event as well. When you zoom, the chart is redrawn to reflect the changes. chart.events.redraw

您还想查看重绘事件。缩放时,图表会重新绘制以反映更改。chart.events.redraw

events: {
    redraw: function(){
        console.log(this.xAxis);
        console.log(this.yAxis);
    }
}