HighCharter工具提示的其他数据

时间:2018-10-03 23:02:42

标签: r highcharts r-highcharter

我在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  + ' <br /> Value1: ' + this.point.y +
                       '<br /> Value2: ??' ;}"))

如何添加Value2以在工具提示中显示?

1 个答案:

答案 0 :(得分:0)

只需添加+ this.point.Value2。这是纯JS中的示例:https://jsfiddle.net/zgq72mc1/

亲切的问候!