我正在处理这个例子: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;
}
}
您可以使用this.series.someAttr
获取series
数据
因此,请执行以下操作:
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;
}
演示
试试这个:
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;
}
}