javascript - 在 Tooltip R Highcharts 中添加附加信息
问题描述
我有一些数据想用 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")
解决方案
如果您在函数中传入,dat
则可以访问参数中的其他列,例如:data
hc_add_series
tooltip
type
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}"))
推荐阅读
- wpf - 如何用曲线环绕我的 WPF Datagrid 标题?
- javascript - 有没有更好的方法来合并 Javascript 中的对象数组?
- sql-server - 为了显示(描述)表的结构,我正在使用 DESC 命令,但出现错误,显示“关键字'DESC'附近的语法不正确”。
- c++ - 是否有任何可能的方法在结构中包含 if else 条件?
- python - python asyncio.gather 使用输入作为返回值的一部分
- machine-learning - 如何直接优化AUC?
- r - 在 R 中对分类变量进行分组
- flutter - 如果我更改应用程序的包名称,Truecaller 不起作用
- typescript - VueJS 项目和 TypeScript 中的范围错误
- javascript - Storybook 为单个故事预定义的视口/参数