esteh
esteh

Reputation: 13

Highcharts pie get series color in tooltip headerFormat

While I use another Highcharts chart type (column, bar), I can get the color in tooltip headerFormat with {series.color}. But I could not get it with pie chart. I also tried to use {point.color} and it returned nothing.

tooltip: {
     borderWidth: 0,
     backgroundColor: "#EBEBEB",
     headerFormat: '<span style="background:{series.color}; color:white;">{point.color}{point.key}</span><br/><br/>',
     pointFormat: '<span>{point.color}{point.percentage:.2f}%</span>({point.y:.2f})<br/>',
     useHTML: true,
     style: {
         padding: 10
     }
}

Do we have another way to access color in pie header tooltip? or did I do something wrong? Here's fiddle of the problem. http://jsfiddle.net/k61fotnr/3/

Any help is appreciated, thanks in advance :)

Upvotes: 1

Views: 1569

Answers (2)

Paweł Fus
Paweł Fus

Reputation: 45079

This way you can access to the original point: {point.point._propertyName}

So in your case:

headerFormat: '<span style="background:{point.point.color}; color:white;">{point.color}{point.key}</span><br/><br/>',

Working demo: http://jsfiddle.net/k61fotnr/5/

Upvotes: 1

Toodoo
Toodoo

Reputation: 223

You have to use rgba format :

backgroundColor: 'rgba(244, 127, 40, 0.85)'

0.85 is the opacity of your tooltip

JSFiddle : http://jsfiddle.net/k61fotnr/4/

Upvotes: 2

Related Questions