小编ash*_*gar的帖子

替换我的代码中的 highcharts.each,因为它已被弃用

我有一些同步的高图,并使用以下代码在鼠标移动时同步十字准线:

//catch mousemove event and have all charts' crosshairs move along indicated values on x axis
function syncronizeCrossHairs(chart) {
['mousemove', 'touchmove', 'touchstart'].forEach(function(eventType) {
var container = $(chart.container),
  offset = container.offset(),
  x;

container[0].addEventListener(eventType,
  (function(evt) {
    x = evt.clientX - chart.plotLeft - offset.left;
    Highcharts.charts.forEach(ch => {
      var e = ch.pointer.normalize(evt), // Find coordinates within the chart   
        points = [];
      ch.series.forEach(s => {
        var point = s.searchPoint(e, true);
        if (point) {
          point.setState();
          if (s.visible) {
             points.push(point)
          }
        }
      })

      if (points) {
        var …
Run Code Online (Sandbox Code Playgroud)

highcharts

6
推荐指数
1
解决办法
2850
查看次数

标签 统计

highcharts ×1