问题描述
我想在工具提示框内添加额外的自定义统计数据行,该行显示在鼠标悬停上方.据我了解,它只显示对象数组中名为series:
和tooltip:
的数据.
I want to add extra custom statistic data lines inside Tooltip Box, which appears over mouse hover. As far as i've learned, it shows only the data inside the object arrays called series:
and tooltip:
.
我只想将更多自定义数据(放入工具提示框),其中每个工具提示的值都用单独的值(不常见).
I just wanna put more custom data (into Tooltip Box) with seperated values for each of Tooltip (NOT COMMON ONE).
例如:
条1 ========================== 41%Tooltip: Water: 7.86%
条2 ================= 33%Tooltip: Salt: 5.2%, Water: 80%
条3 ====================== 35%Tooltip: Caffeine: 51%, Alcohol: 31%, Water: 4%
For example:
Bar 1 =========================== 41% Tooltip: Water: 7.86%
Bar 2 ================= 33% Tooltip: Salt: 5.2%, Water: 80%
Bar 3 ====================== 35% Tooltip: Caffeine: 51%, Alcohol: 31%, Water: 4%
工具提示项和每个条形的值都不同.我该怎么办?
推荐答案
您可以使用series
存储此信息,如下所示.
You can store this information with the series
, like the following.
{
type: 'bar',
name: 'Bar3',
composition: {
'Caffeine': '51%',
'Alcohol': '31%',
'Water': '4%'
},
data: [35]
}
然后,您可以通过工具提示格式化程序获取它.使用this
引用该系列.
Then you can get it through the tooltip formatter. Use this
to reference the series.
tooltip: {
formatter: function() {
console.log(this.series.options.composition);
}
}
然后,您只需要根据需要设置文本格式即可.
Then you only have to format the text according to what you want.
参考:
这篇关于(jQuery Highchart)有什么方法可以在工具提示框中放入额外的自定义数据吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!