*高图*工具提示格式 [英] *Highcharts* Tooltip format

查看:40
本文介绍了*高图*工具提示格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的工具提示格式:

I have a tooltip format like this:

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具有不同的颜色.

How can I add color to my series.name because now they all black. In my chart after drawing, different series.name has different colors.

谢谢

推荐答案

使用此:

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
 }

在此处查看共享工具提示中不同颜色的演示

这篇关于*高图*工具提示格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆