甜甜圈馅饼上的共享工具提示?

时间:2013-05-20 01:10:41

标签: javascript jquery highcharts

我在Highcharts的甜甜圈里乱糟糟的馅饼,我似乎无法获得传奇或共享的工具提示。它工作得很好with non-shared tooltips

tooltip: {
            formatter: function () {
                return this.point.name + ': ' +this.y 
                    + ' units (' + Highcharts.numberFormat(this.percentage, 0) + '%)'
                ;  

            },
        },

但如果我尝试将其转换为shared tooltip,则不会出现任何内容。

    tooltip: {
        formatter: function () {
            var s = this.series.name + this.point.name;
            $.each(this.points, function (i, point) {
                s += point.name + ' ' + point.y + ' ' + point.percentage;
            });
            return s;
        },
        shared: true
    },

我无法弄清楚我做错了什么。

1 个答案:

答案 0 :(得分:1)

只是看看格式化程序函数中的highchartsthis)对象。不确定您要完成的任务,但看起来highcharts对象包含series数组points

$.each(this.series.points, function (i, point) {
    s += point.name + ' ' + point.y + ' ' + point.percentage + '<br/>';
});

Fiddle

编辑:为良好指标添加换行符= D