Additional data to highcharter tooltip

孤街浪徒 提交于 2019-12-24 09:14:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!