Highcharts工具提示格式化共享工具提示 [英] Highcharts Tooltip formatting for shared Tooltips

查看:109
本文介绍了Highcharts工具提示格式化共享工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,如果我有一个包含三个系列的图表,并且工具提示设置为共享,我希望更多地控制格式化工具提示。目前我使用格式化程序:somefunction()并创建自己的html以在显示的工具提示中使用。现在,这个工作非常好,但现在我希望能够知道格式化函数什么时候触发了哪个系列,以便在工具提示中的三个系列中,我可以格式化相应显示的文本。



共享工具提示:

标题标签

 系列1 
系列2(如果我悬停在这个项目上,我想在格式化函数中加粗它)
系列3
http://jsfiddle.net/LBsL5/



可能适用于您的解决方案是禁用共享工具提示并从其他系列获取值:

  var xIndex = this.series.xData.indexOf(this.x),
allSeries = this.series.chart.series;

现在遍历所有系列并使用 allSeries [index] .yData [xIndex ] 来获得每个系列的价值。

当然,如果 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工具提示格式化共享工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆