【发布时间】:2017-05-04 16:16:58
【问题描述】:
在绘制时间序列时,在 highcharter 库的 plotLines 和 plotBands 中指定值的正确方法是什么?使用以下代码,绘图线出现在图表的左端,而波段根本不出现。如果我不指定type = 'stock',即使情节线也不会出现。这似乎是时间序列数据的问题,只有其他类型的数据才能正常工作。所以我相信我可能没有以正确的格式指定值。除了代码中的那个之外,我还尝试了时间序列格式,例如from = c(1990,1) 但它也不起作用。
library(highcharter)
data =ts(data = sample(c(50:100),360, replace = TRUE), start = c(1987,1), frequency = 12, names = 'index')
highchart(type = 'stock')%>%
hc_add_series_ts(data) %>%
hc_xAxis(type = 'datetime',
plotLines = list(
list(
label = list(text = "This is a plotLine"),
color = "#FF0000",
width = 5,
value = as.Date('1990-01-01', tz = 'UTC')
)
),
plotBands = list(
list(
label = list(text = "This is a plotBand"),
color = "rgba(100, 0, 0, 0.1)",
from = as.Date('1995-01-01', tz = 'UTC'),
to = as.Date('1996-01-01', tz = 'UTC')
)
)
)
【问题讨论】:
标签: r highcharts