[英]How to get chart min and max values after Drag zooming in highChart chart?
http://jsfiddle.net/leongaban/0zuxtdcg/ http://jsfiddle.net/leongaban/0zuxtdcg/
I could not find a "Drag zoom" type event in the HighChart docs that would tell me that the user has finished zooming into a specific range on the chart, then give me the new min and max values.我在 HighChart 文档中找不到“拖动缩放”类型的事件,它会告诉我用户已完成缩放到图表上的特定范围,然后给我新的最小值和最大值。
$(function () {
$.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=usdeur.json&callback=?', function (data) {
$('#container').highcharts({
chart: {
zoomType: 'x'
},
title: {
text: 'USD to EUR exchange rate over time'
},
subtitle: {
text: document.ontouchstart === undefined ?
'Click and drag in the plot area to zoom in' : 'Pinch the chart to zoom in'
},
xAxis: {
type: 'datetime'
},
yAxis: {
title: {
text: 'Exchange rate'
}
},
legend: {
enabled: false
},
plotOptions: {
area: {
fillColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0, Highcharts.getOptions().colors[0]],
[1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
]
},
marker: {
radius: 2
},
lineWidth: 1,
states: {
hover: {
lineWidth: 1
}
},
threshold: null
}
},
series: [{
type: 'area',
name: 'USD to EUR',
data: data
}]
});
});
});
The zoom effects the extremes of the axis.缩放会影响轴的极值。 You can use the
setExtremes
or afterSetExtremes
events of the axis to catch this.您可以使用轴的
setExtremes
或afterSetExtremes
事件来捕获它。
For example ( JSFiddle ):例如( JSFiddle ):
xAxis: {
events: {
setExtremes: function(e) {
alert("Min: "+e.min+"\n"
+"Max: "+e.max);
}
}
}
The e
object contains the min and max, while this
in the function is the Axis object (which also has min and max). e
对象包含 min 和 max,而函数中的this
是 Axis 对象(也有 min 和 max)。 The minor difference between the two events is described in the API as:两个事件之间的细微差别在 API 中描述为:
afterSetExtremes
... As opposed to thesetExtremes
event, this event fires after the final min and max values are computed and corrected forminRange
.afterSetExtremes
... 与setExtremes
事件相反,此事件在计算并修正minRange
的最终最小值和最大值后minRange
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.