我在仪表板页面中使用多个highChart,例如行区、样条、饼图和多个图表的同步
为原型设置工具提示同步
Highcharts.Pointer.prototype.reset = function () {
return undefined;
};
Highcharts.Point.prototype.highlight = function (event) {
this.onMouseOver(); // Show the hover marker
this.series.chart.tooltip.refresh(this); // Show the tooltip
this.series.chart.xAxis[0].drawCrosshair(event, this); // Show the crosshair
};但以上功能影响所有高图,如线面积、样条图等,我只想应用于同步。
发布于 2017-11-28 09:59:43
请参阅本实况演示: http://jsfiddle.net/kkulig/eec3mg9t/
我把每个图表放在一个单独的容器里--那么操作它们就更容易了。class="sync"表示应该同步图表:
<div id="container0"></div>
<div id="container1" class="sync"></div>
<div id="container2" class="sync"></div>然后,我使用这个类设置公共事件:
$('.sync').bind('mousemove touchmove touchstart', function(e) {
(...)我应用了包装,而不是对Highcharts.Pointer.prototype.reset函数进行覆盖,以便默认操作触发不同步图表。
// Custom wrap
Highcharts.wrap(Highcharts.Pointer.prototype, 'reset', function(proceed, allowMove, delay) {
if (!this.chart.options.chart.isSynchronized) {
proceed.apply(this, allowMove, delay);
}
});https://stackoverflow.com/questions/47484745
复制相似问题