admin管理员组文章数量:1400998
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.
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.
Share Improve this question asked Jan 28, 2013 at 14:45 GideonGideon 1,8864 gold badges41 silver badges71 bronze badges1 Answer
Reset to default 7I 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(%)' ? '%' : '');
}
}
版权声明:本文标题:javascript - Highcharts: Conditional tooltip based on multiple series names (OR logic operator) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744211173a2595424.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论