问题
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: ??' ;}"))
How do I add Value2 to show in the tooltip?
回答1:
Just add + this.point.Value2
. Here is the example in pure JS: https://jsfiddle.net/zgq72mc1/
Kind regards!
来源:https://stackoverflow.com/questions/52636801/additional-data-to-highcharter-tooltip