首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >HighCharts同步工具提示对其他图表的影响

HighCharts同步工具提示对其他图表的影响
EN

Stack Overflow用户
提问于 2017-11-25 10:05:42
回答 1查看 200关注 0票数 0

我在仪表板页面中使用多个highChart,例如行区、样条、饼图和多个图表的同步

为原型设置工具提示同步

代码语言:javascript
运行
复制
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
};

但以上功能影响所有高图,如线面积、样条图等,我只想应用于同步。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-11-28 09:59:43

请参阅本实况演示: http://jsfiddle.net/kkulig/eec3mg9t/

我把每个图表放在一个单独的容器里--那么操作它们就更容易了。class="sync"表示应该同步图表:

代码语言:javascript
运行
复制
<div id="container0"></div>
<div id="container1" class="sync"></div>
<div id="container2" class="sync"></div>

然后,我使用这个类设置公共事件:

代码语言:javascript
运行
复制
$('.sync').bind('mousemove touchmove touchstart', function(e) {
   (...)

我应用了包装,而不是对Highcharts.Pointer.prototype.reset函数进行覆盖,以便默认操作触发不同步图表。

代码语言:javascript
运行
复制
  // Custom wrap
  Highcharts.wrap(Highcharts.Pointer.prototype, 'reset', function(proceed, allowMove, delay) {
    if (!this.chart.options.chart.isSynchronized) {
      proceed.apply(this, allowMove, delay);
    }
  });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47484745

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档