gpt4 book ai didi

javascript - 在工具提示中添加附加信息 R Highcharts

转载 作者:行者123 更新时间:2023-12-02 21:54:29 24 4
gpt4 key购买 nike

我有一些数据想要使用 highcharts 绘制图表。当我将鼠标悬停在给定点上时,我希望工具提示也包含“类型”列。这是我当前可重现的示例。

library(highcharts)
dat = data.frame(first = rnorm(10), second = rnorm(10), type = rep(c("AAPL", "MSFT"),5))

highchart()%>%
hc_xAxis(categories = dat$Open_Date)%>%
hc_add_series(name = "first", data = dat$first, type = "column")%>%
hc_add_series(name = "second", data = dat$second, type = "line")

enter image description here

最佳答案

如果您在 hc_add_series 函数中将 dat 作为 data 传递,则可以访问 tooltip 中的其他列> 参数,如类型:

library(highcharter)

dat = data.frame(first = rnorm(10), second = rnorm(10), type = rep(c("AAPL", "MSFT"),5))

highchart()%>%
#hc_xAxis(categories = dat$Open_Date)%>%
hc_add_series(name = "first", data = dat, hcaes(y = first), type = "column",
tooltip = list(pointFormat = "{point.type}: {point.first}"))%>%
hc_add_series(name = "second", data = dat, hcaes(y = second), type = "line",
tooltip = list(pointFormat = "{point.type}: {point.second}"))

highcharter with custom tooltip

关于javascript - 在工具提示中添加附加信息 R Highcharts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60044393/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com