HighCharts在工具提示中添加另一个系列值

时间:2013-12-02 18:00:48

标签: highcharts

我有一个箱线图,上面绘有原始值的散点图。我想更改boxplot工具提示(鼠标悬停时)以显示散点图系列中的总点数。

       tooltip: {
                    useHTML: true,
                    headFormat: '{point.key}',
                    pointFormat: 'Median: {point.median}'
                 }

点和系列是针对boxplot的,有没有办法引用像系列[1]这样的另一个系列,你会怎样得到总数。或者我可以引用具有总值的数组。

How to edit the tooltip text in a highcharts boxplot类似

2 个答案:

答案 0 :(得分:1)

根据formatter,您可以通过this.series引用系列对象。因此,对于系列中的总点数,您可以尝试

tooltip: {
    formatter: function() {
        return this.series.data.length;
    }
},

似乎共享工具提示不适用于分散https://github.com/highslide-software/highcharts.com/issues/1431。所以我不知道如何引用另一个系列。否则你可以使用this.points [i] .series。

答案 1 :(得分:1)

this.series包含对图表对象的引用,而该图表对象又引用了chart.series数组。

    tooltip: {
        formatter: function() {
            var arrayOfSeries = this.series.chart.series;
            console.log(arrayOfSeries); // doing something with all the series!
        }
    },

小提琴here

相关问题