It is usual to be able to adjust the tooltip format based on the the name of the series in highchart, using the following type of code:
tooltip: {
formatter: function() {
return ''+
this.x +': '+ this.y +
(this.series.name == 'Recovered' ? '%' : '');
}
}
The above says in the last line, if this series name is 'Recovered' then add '%' else don't add anything.
However I want two of my series to have % not just one, so I want to add an OR operator in, something like
tooltip: {
formatter: function() {
return ''+
this.x +': '+ this.y +
(this.series.name == 'Recovered'||'Targeted' ? '%' : '');
}
}
So that both those series have the % added. But the above method does not work for me. Any ideas? Thanks very much.
I have discovered how to do this - leaving question up in case it helps anyone else. The correct syntax for this is:
tooltip: {
formatter: function() {
return ''+
this.x +': '+ this.y +
(this.series.name == 'Recovered(%)'||this.series.name =='Defaulted(%)' ? '%' : '');
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With