我在highcharter中有一个折线图,我想在工具提示中添加其他信息 . 数据和代码如下:
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 + '
Value1: ' + this.point.y +
'
Value2: ??' ;}"))
如何在工具提示中添加Value2?
1 回答
只需添加
+ this.point.Value2
即可 . 以下是纯JS中的示例:https://jsfiddle.net/zgq72mc1/亲切的问候!