我有这样的工具提示格式:
tooltip: {
formatter: function() {
return Highcharts.dateFormat('%A, %b %e, %Y',new Date(this.x)) +'<br/>'+ this.series.name + ': ' + '<b>'+ this.y +'</b>';
}
};我怎样才能给我的series.name添加颜色,因为现在它们都是黑色的。在我绘图后的图表中,不同的series.name有不同的颜色。
谢谢
发布于 2015-11-26 13:15:55
用这个:
tooltip: {
formatter: function() {
var toolTipTxt = '<b>'+ this.x +'</b>';
toolTipTxt += '<br/><span style="color:'+ this.point.series.color +'"> ' + this.point.series.name + ': ' + this.y+' </span>';
return toolTipTxt;
}
}看这里工作的小提琴
如果您的工具提示是共享的,那么使用以下代码
tooltip: {
formatter: function() {
var toolTipTxt = '<b>'+ this.x +'</b>';
$.each(this.points, function(i, point) {
toolTipTxt += '<br/><span style="color:'+ point.series.color +'"> ' + point.series.name + ': ' + point.y+'</span>';
});
return toolTipTxt;
} ,shared:true
}请参阅工具提示中不同颜色的演示以获取共享工具提示
https://stackoverflow.com/questions/33938646
复制相似问题