在以下示例中,我如何格式化两个系列和标志的工具提示?
http://jsfiddle.net/gh/get/jquery/1.7.1/highslide-software/highcharts.com/tree/master/samples/stock/plotoptions/flags/
我想在系列工具提示中显示额外信息,在标志工具提示中显示其他数据。
最佳答案
使用以下功能作为工具提示格式化程序 -
tooltip: {
shared:true,
formatter: function(){
var p = '';
console.log(this);
if(this.point) {
p += '<b>'+ Highcharts.dateFormat('%A, %b %e, %Y', this.point.x) +'</b><br/>';
p += this.point.config.text // This will add the text on the flags
}
else {
p += '<b>'+ Highcharts.dateFormat('%A, %b %e, %Y', this.x) +'</b><br/>';
$.each(this.points, function(i, series){
p += '<span style="color:' + this.series.color + '">' + this.series.name + '</span>: <b>'+ this.y + ' kWh ($' + Highcharts.numberFormat(this.y * rate, 0) + ')</b><br/>';
});
}
return p;
}}
另请参阅此 JSFiddle:http://jsfiddle.net/aTcFe/
关于highcharts - 用于系列和标志的 Highchart/stock 工具提示格式化程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10535549/