我有使用命名值两个数据系列highcharts表。 在我提示一个系列,我想从系列引用一个数据点。 因此,在这个答案的解决方案: 如何使用上Highcharts不同的格式在相同的图形的每一条曲线? 不帮我。 我需要的不仅仅是更多的ToolTipText,我需要格式化:
对于一个:
formatter: function() {
return this.x + ': ' + this.series.name +
'<br> $' + Highcharts.numberFormat(this.y, 0);
}
而对于其他:
formatter: function() {
return 'In ' + this.x + ' the median value was' + this.median +
'and the total $' + Highcharts.numberFormat(this.y, 0);
}
里面格式化this
reffers该关注意甲,您可以添加if/else
格式里面,并返回一个字符串的每一个,像下面这样。
tooltip: {
shared: false,
formatter: function() {
var text = '';
if(this.series.name == 'MSFT') {
text = this.x + ': ' + this.series.name +
'<br> $' + Highcharts.numberFormat(this.y, 0);
} else {
text = 'In ' + this.x + ' the median value was' + this.median +
'and the total $' + Highcharts.numberFormat(this.y, 0);
}
return text;
}
}
演示
您可以轻松地定义toolip格式化每个系列-在这里看到: http://api.highcharts.com/highcharts/plotOptions.series.tooltip
{
tooltip: {
shared: true
},
series: {
name: 'some series name',
data: mydata,
tooltip: {
valueSuffix: ' bar'
}
}
}
例如: http://jsfiddle.net/28qzg5gq/
下面是一个例子。 小提琴的例子是在这里 :
tooltip: {
formatter: function () {
var s = '<b>' + Highcharts.dateFormat('%A, %b %e, %Y', this.x) + '</b>';
$.each(this.points, function () {
s += '<br/>1 USD = ' + this.y + ' EUR';
});
return s;
}
},