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 以显示在工具提示中?
解决方案
只需添加+ this.point.Value2
. 这是纯 JS 中的示例:https ://jsfiddle.net/zgq72mc1/
亲切的问候!
推荐阅读
- database - 锁定和更新数据库中数据集中的记录
- javascript - array.push 没有根据序列推送对象,而某些对象使用 await 执行操作
- java - Listview - 单击标题以显示描述
- python - Python-下拉更改内容颜色
- docker - 尝试使用 docker-compose 构建 Docker 映像时出现“无法找到匹配错误”
- python - 有没有一种方法可以通过 input() 绘制多项式方程?
- tensorflow - 为什么 Conv2D 在每一层有不同数量的过滤器
- php - 如何安装 DomPDF
- flutter - 使用颤振,每次我重新加载 ListView 时,我的带有 MemoryImage 的 CircleAvatar 都会闪烁
- r - 使用 ggplot2 和 log2_trans() 进行 log_2 缩放的问题