簡體   English   中英

HighCharter工具提示的其他數據

[英]Additional data to highcharter tooltip

我在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以在工具提示中顯示?

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

親切的問候!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM