本文介绍了HighCharter工具提示的其他数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在highcharter中有一个折线图,我想在工具提示中添加其他信息.数据和代码如下:
I have a line chart in highcharter that I would like to add additional information in the tooltip to. Data and code is as follows:
library("dplyr")
library("highcharter")
data<- data.frame(Company = c("A", "A", "A", "B", "B", "B"),
Year = c(1,2,3,1,2,3),
Value1 = c(100, 150, 170, 160, 150, 180),
Value2 = c(3, 1, 7, 6, 5, 4))
data<- data %>%
group_by(name = Company) %>%
do(data = .$Value1, Value2 = .$Value2)
series<- list_parse(data)
highchart()%>%
hc_chart(type="line")%>%
hc_add_series_list(series)%>%
hc_tooltip(formatter= JS("function () { return 'Company: ' +
this.series.name + ' <br /> Value1: ' + this.point.y +
'<br /> Value2: ??' ;}"))
如何添加Value2以在工具提示中显示?
How do I add Value2 to show in the tooltip?
推荐答案
只需添加+ this.point.Value2
.这是纯JS中的示例: https://jsfiddle.net/zgq72mc1/
Just add + this.point.Value2
. Here is the example in pure JS: https://jsfiddle.net/zgq72mc1/
亲切的问候!
这篇关于HighCharter工具提示的其他数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!