2

我正在研究这个例子:http ://www.highcharts.com/demo/combo

当我将鼠标悬停在一些彩色饼图上时,即蓝色的工具提示是

Jane: 13 fruits

但是,当我将鼠标悬停在第一个列(苹果处的蓝色列)时,工具提示是:

Apples: 3

它是简的苹果。那么我怎样才能将其更改为:

Jane : 3 apples

有任何想法吗?

PS

示例中使用的工具提示格式化程序是:

    tooltip: {
        formatter: function() {
            var s;
            if (this.point.name) { // the pie chart
                s = ''+
                    this.point.name +': '+ this.y +' fruits';
            } else {
                s = ''+
                    this.x  +': '+ this.y;
            }
            return s;
        }
    }
4

2 回答 2

5

您可以series使用this.series.someAttr.
因此,请执行以下操作:

formatter: function() {
    var s;
    if (this.point.name) { // the pie chart
        s = this.point.name +' '+ this.y +' fruits';
    } else {
        s = this.series.name + ' : ' +
            this.x  +': '+ this.y;
    }
    return s;
}

演示

于 2012-09-03T23:57:47.753 回答
0

尝试这个:

tooltip: {
        formatter: function() {
            var s;
            if (this.point.name) { // the pie chart
                s = ''+
                    this.point.name +': '+ this.y +' fruits';
            } else {
                s = ''+
                    this.series.name  +': '+ this.y+' '+this.x;
            }
            return s;
        }
    }
于 2012-09-04T11:55:59.100 回答