繁体   English   中英

如何在工具提示高图表中获取多个系列数据(不丢失工具提示指针箭头)

[英]How to get multiple series data in tooltip highcharts (Without loosing tooltip pointer arrow)

我的代码现在看起来像这样(下面的演示)

演示: http//jsfiddle.net/pintu31/AcNUM/2/

tooltip: {
        formatter: function() {
            var s = [];

            $.each(this.points, function(i, point) {
                s.push('<span style="color:#D31B22;font-weight:bold;">'+ point.series.name +' : '+
                    point.y +'<span>');
            });

            return s.join(' and ');
        },
        shared: true
    },

当shared为false时,我还有指针箭头! 如下所示: http : //jsfiddle.net/AcNUM/259/

但是,当我在第一个演示中使用共享版本时,会丢失工具提示上的指针箭头: 在此处输入图片说明

使用格式化程序并定义工具提示中应显示的内容。 在格式化程序中,您可以找到与悬停点具有相同类别的点。

tooltip: {
  formatter: function (tooltip) {
    const series = this.series.chart.series.find(series => series !== this.series);
    const point = series.points.find(point => point.category === this.x);

    if (point !== undefined) {
      return tooltip.defaultFormatter.call([point.getLabelConfig(), this], tooltip);
    }
  }
},

例如: http//jsfiddle.net/AcNUM/260/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM