将导航器添加到高图图表后,我们如何阻止导航器更改图形的移动。 这有一个事件处理程序吗?
我希望导航器在屏幕上,但禁用它如何与图形一起工作。
你可以实现它覆盖其核心方法。
1)破坏整个功能:
(function(H) {
H.Navigator.prototype.addMouseEvents = function() {}
})(Highcharts);
演示:
2)防止移动导航器句柄时更改图表极值:
(function(H) {
H.Navigator.prototype.onMouseUp = function(e) {
var navigator = this,
chart = navigator.chart,
xAxis = navigator.xAxis,
scrollbar = navigator.scrollbar,
unionExtremes,
fixedMin,
fixedMax,
ext,
DOMEvent = e.DOMEvent || e;
if (
(navigator.hasDragged && (!scrollbar || !scrollbar.hasDragged)) ||
e.trigger === 'scrollbar'
) {
unionExtremes = navigator.getUnionExtremes();
// When dragging one handle, make sure the other one doesn't change
if (navigator.zoomedMin === navigator.otherHandlePos) {
fixedMin = navigator.fixedExtreme;
} else if (navigator.zoomedMax === navigator.otherHandlePos) {
fixedMax = navigator.fixedExtreme;
}
// Snap to right edge (#4076)
if (navigator.zoomedMax === navigator.size) {
fixedMax = navigator.reversedExtremes ?
unionExtremes.dataMin : unionExtremes.dataMax;
}
// Snap to left edge (#7576)
if (navigator.zoomedMin === 0) {
fixedMin = navigator.reversedExtremes ?
unionExtremes.dataMax : unionExtremes.dataMin;
}
ext = xAxis.toFixedRange(
navigator.zoomedMin,
navigator.zoomedMax,
fixedMin,
fixedMax
);
}
if (e.DOMType !== 'mousemove') {
navigator.grabbedLeft = navigator.grabbedRight =
navigator.grabbedCenter = navigator.fixedWidth =
navigator.fixedExtreme = navigator.otherHandlePos =
navigator.hasDragged = navigator.dragOffset = null;
}
}
})(Highcharts);
演示: