【问题标题】:How to display custom or non-series data array on Highcharts tooltip on hover?如何在悬停时在 Highcharts 工具提示中显示自定义或非系列数据数组?
【发布时间】:2023-04-09 13:22:01
【问题描述】:

我正在使用带有系列范围数据的区域范围图来显示图表,但工具提示不需要任何系列数据,而是我需要将部分数据数组显示在相应的点上。我不确定哪个是正确的方法。我已经有 3 个数据点用于显示图表。当我将 5 个点添加到系列时,它变成了 8 个系列点。我无法获取动态添加的数据。来自系列的其他数据正在弄乱我的数据,我无法访问添加的确切数据。

所以,我试着加分

    tooltip: {
            formatter: function() {
                var points = this.points,
                    point,
                    pointValue,
                    i = 0,
                    j, z = 0,
                    seriesValueHolder = {};
                var bIndex = points[0].point.index;
                var midValue = midPercentiles[bIndex];
                points.push({
                    y: midValue,
                    series: {
                        name: "midSeries"
                    }
                });

                var len = this.points.length;
                for (var i = 0; i < len; i++) {
                    point = points[i];
                    pointValue = point.y;
                    for (j = i + 1; j < len - 1; j++) {
                        pointValue = pointValue + points[j].y;
                    }

                }

    tooltipText += this.renderTooltipLineItem(helper.getSeriesLabel('midSeries'),
                                        seriesValueHolder['midSeries']);
    return tooltipText;

                    },
                    shared: true
}

【问题讨论】:

    标签: javascript jquery highcharts


    【解决方案1】:

    按顺序推送您的自定义数据并使用工具提示将其取回

    this.point.custom
    

    【讨论】:

      【解决方案2】:

      一切都按预期进行。感谢您的答案,我也会尝试这些。 当我取出外线时工作

      for (j = i + 1; j < len - 1; j++) {
          pointValue = pointValue + points[j].y;
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-01-06
        • 2018-09-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-06-07
        • 1970-01-01
        相关资源
        最近更新 更多