2015-04-27 57 views
1

它可以添加backgroundColor作爲懸停線的工具提示?Highcharts工具提示backgroundColor從繼承元素繼承

例如,當藍色的提示的backgroundColor懸停是藍色

tooltip: { 
      borderWidth: 0, 
      backgroundColor: "rgba(255,255,255,0)", 
      borderRadius: 0, 
      shadow: false, 
      useHTML: true, 
      percentageDecimals: 2, 
      backgroundColor: "rgba(255,255,255,1)", 
      formatter: function() { 
       return '<div class="tooltop">'+this.point.name + '<br />' + '<b>' + Highcharts.numberFormat(this.y).replace(",", " ") + ' Kč [' + Highcharts.numberFormat(this.percentage, 2) + '%]</b></div>'; 
      } 
     } 

http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/tooltip/style/

回答

1

你可以使用一系列的mouseOver事件改變提示的填充顏色。

看到這個代碼演示:

plotOptions: { 
    series: { 
     events: { 
      mouseOver: function(event) { 
       $(".highcharts-tooltip > path:last").attr("fill", this.color); 
      } 
     } 
    } 
} 

而且在行動的它this JSFiddle example

0

您可以將useHTML設置爲true,禁用填充並在div中添加樣式參數。例如:http://jsfiddle.net/50pvg4b3/

tooltip: { 
      useHTML:true, 
      style:{ 
       padding:0 
      }, 
      formatter: function() { 
       return '<div class="tooltip" style="background-color:'+this.series.color+';">'+this.point.name + '<br />' + '<b>' + Highcharts.numberFormat(this.y).replace(",", " ") + ' Kč [' + Highcharts.numberFormat(this.percentage, 2) + '%]</b></div>'; 
      } 
     },