2013-02-20 36 views
1

我有一个Highcharts折线图并启用了工具提示,但是,我想更改工具提示的背景颜色,使其只显示图表上的单个数据点。
是否有可能这样做?
我有什么到目前为止
tooltip: { formatter: function() { return this.y; }, backgroundColor: '#68BD49', borderColor: '#000000', borderWidth: '1' },在Highcharts中更改特定数据点的工具提示的背景颜色

回答

1

是的,它是可能的,通过使用HTML选项,并指定自定义参数。很明显,你可以使用CSS样式/班禁用填充/利润率,但最简单的方法,你可以用这种方式实现这一目标:

tooltip: { 
     useHTML:true, 
     formatter: function() { 
      console.log(this); 
      if(this.point.customBck) 
       return '<div style="background-color:red;">The value for <b>'+ this.x + '</b> is <b>'+ this.y +'</b></div>'; 
      else 
       return '<div>The value for <b>'+ this.x + '</b> is <b>'+ this.y +'</b></div>'; 
     } 
    }, 

http://jsfiddle.net/XnLpH/1/

+0

真棒!谢谢塞巴斯蒂安。 – smons 2013-02-22 00:20:40

+0

有没有办法动态设置整个工具提示的背景颜色?这只会设置工具提示文字的背景。 – es3735746 2017-03-13 17:55:33

+0

在哪种情况下应该应用?每个点应该有自己的backogrund或每个系列? – 2017-03-22 09:37:57

相关问题