问题描述
例如,如果我有一个包含三个系列的图表,并且工具提示设置为共享,我希望更多地控制格式化工具提示。目前我使用格式化程序:somefunction()并创建自己的html以在显示的工具提示中使用。现在,这个工作非常好,但现在我希望能够知道格式化函数什么时候触发了哪个系列,以便在工具提示中的三个系列中,我可以格式化相应显示的文本。
共享工具提示:
标题标签
当然,如果 this.series.index (或 this.series.options .index )与上面的 index 相同,然后生成粗体文本。
If for example I have a chart with three series in it and the tooltips are set to shared, I would like more control over formatting the tooltips. Currently I use the formatter: somefunction() and create my own html to use in the tooltip that is displayed. Now this works very nicely, but now I would like to be able to know when the formattor function fires which series I am over so that out of the three series in the tooltip I can format the text I show accordingly.
Shared Tooltip:
Header Label
Series 1 Series 2 (If I am hovering over this item I want to bold it in the formatter function) Series 3解决方案There isn't such info in shared tooltip - simply you can hover empty space on a chart (none of series) and it will be displayed, see: http://jsfiddle.net/LBsL5/
Solution which may work for you is to disable shared tooltip and get values from other series using:
var xIndex = this.series.xData.indexOf(this.x), allSeries = this.series.chart.series;Now loop over all series and use allSeries[index].yData[xIndex] to get value from each series.
Of course, if this.series.index (or this.series.options.index ) is the same index above, then generate bold text.
这篇关于Highcharts工具提示格式化共享工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!