【问题标题】:Mouse wheel event in highchart reduce xaxis heighthighchart中的鼠标滚轮事件减少xaxis高度
【发布时间】:2018-11-15 05:38:27
【问题描述】:
我在 highcharts 中添加了一个鼠标滚轮事件,参考如下:
http://jsfiddle.net/d3r8pb7c/
但是当我继续移动鼠标滚轮 xaxis 条高度降低时,我发现了一个滚轮事件问题。请在下面找到图片。
我尝试通过向图表添加高度来解决此问题,但没有解决任何问题。如果有人知道,请帮忙。以下代码我尝试在没有任何效果时提高图表的高度。
chart: {
height: 500}
【问题讨论】:
标签:
javascript
jquery
highcharts
mousewheel
【解决方案1】:
当您滚动到边缘时,您的 wrap 函数会错误地计算轴极值。您应该使用以下计算:
if (chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) {
extr = axis.getExtremes();
step = (extr.max - extr.min) / 5 * delta;
if ((extr.min + step) <= dataMin) {
newExtrMin = dataMin;
newExtrMax = dataMin + (extr.max - extr.min);
} else if ((extr.max + step) >= dataMax) {
newExtrMin = dataMax - (extr.max - extr.min);
newExtrMax = dataMax;
} else {
newExtrMin = extr.min + step;
newExtrMax = extr.max + step;
}
axis.setExtremes(newExtrMin, newExtrMax, true, false);
}
现场演示:http://jsfiddle.net/BlackLabel/9mbycpqu/