问题
I have a Highcharts line chart and have tooltips enabled, however, I would like to change the background color of tooltip for just a single data point on the chart.
Is it possible to do so?
What I have so fartooltip: {
formatter: function () {
return this.y;
},
backgroundColor: '#68BD49',
borderColor: '#000000',
borderWidth: '1'
},
回答1:
Yes it is possible, by using HTML option and define custom parameters. Obviously you can use CSS styles / classes disable padding/margins, but in the simplest way you can achive this in this way:
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/
来源:https://stackoverflow.com/questions/14991075/changing-backgroundcolor-of-tooltip-for-a-specific-data-point-in-highcharts