在Highcharts/Highstock中获得错误的point.plotY位置 [英] Get wrong point.plotY position in Highcharts / Highstock
问题描述
在Highstock中单击RangeSelector
时,我总是会错误地找到point.plotY
位置.
I always get wrong point.plotY
position when I click RangeSelector
in Highstock.
请参阅此 小提琴 .
我尝试捕获setExtremes: function (e)
中的范围更改事件.当我在rangeselector中单击6m
时,在Firebug控制台中,我同时打印了最后一个点对象和point.plotY
I try to catch range change event in setExtremes: function (e)
. When I click 6m
in rangeselector, in firebug console I print both last point object and point.plotY
您可以看到点对象中的PlotY值与plotY有所不同.我也画
从[chart.plotLeft + chart.plotWidth, chart.plotTop + point.plotY]
开始的路径,似乎与系列的最后一点不匹配.
You can see that the value of PlotY in the point object and the plotY is different. I also draw
a path start from [chart.plotLeft + chart.plotWidth, chart.plotTop + point.plotY]
, it seems it does not match the last point of the series.
xAxis: {
events: {
setExtremes: function (e) {
console.log('change');
$("#test").remove();
$(chart.series).each(function (i, serie) {
point = serie.data[serie.data.length - 1];
if (point) {
console.log(point);
console.log(point.plotY);
chart.renderer.path(['M', chart.plotLeft + chart.plotWidth, chart.plotTop + point.plotY, 'l', 1, 1])
.attr({
'stroke-width': 10,
stroke: 'red',
id: 'test'
})
.add();
}
});
}
}
},
推荐答案
我将您的代码更改为使用 xAxis.events.setExtremes
可能是指视口中的最后一点,将serie.data
更改为serie.points
I changed your code to use xAxis.events.afterSetExtremes
instead of xAxis.events.setExtremes
Also since you probably are referring to the last point in the view port, changed serie.data
to serie.points
$(chart.series).each(function (i, serie) {
point = serie.points[serie.points.length - 1];
if (point) {
console.log(point);
console.log(point.plotY);
chart.renderer.circle(chart.plotLeft + chart.plotWidth, chart.plotTop + point.plotY, 5)
.attr({
'stroke-width': 5,
stroke: 'red',
id: 'test'
}).add();
}
});
这篇关于在Highcharts/Highstock中获得错误的point.plotY位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!