我在R中使用highcharter
库作为项目,并且真的需要能够在图表上绘制手绘线。我看到highcharts库可以为图表添加注释。有没有办法使用highcharter
库在我的图表上启用注释按钮?
https://www.highcharts.com/plugin-registry/single/17/Annotations
以下是使用hc_annotations()
的代码示例。我不确定需要在hc_annotations()
添加什么来启用按钮。
library("highcharter")
data("citytemp")
hc <- highchart() %>%
hc_xAxis(categories = citytemp$month) %>%
hc_add_series(name = "Tokyo", data = citytemp$tokyo) %>%
hc_add_series(name = "New York", data = citytemp$new_york)
hc
hc %>%
hc_add_series(name = "London", data = citytemp$london, type = "area") %>%
hc_rm_series(name = "New York") %>%
hc_annotations(list(enabledButtons=TRUE, xValue = 10, yValue = 10, title =list(text = 'Annotated chart!')))
答案 0 :(得分:0)
以下是如何在highcharter
中添加默认注释按钮的示例。在使用hc_annotations()
进行几次尝试之后,似乎只是将选项列表传递到初始highchart()
来电可能会更容易。
library("highcharter")
data("citytemp")
hc_opts <- list(enabledButtons=TRUE)
hc <- highchart(hc_opts) %>%
hc_xAxis(categories = citytemp$month) %>%
hc_add_series(name = "Tokyo", data = citytemp$tokyo) %>%
hc_add_series(name = "New York", data = citytemp$new_york)
hc