我正在尝试在 highcharteR 中绘制每日值系列,在图表中标记垂直线(绘图线)和日期周期(绘图带)。
我研究了几个SO问题并达到了这个脚本,但我发现了以下问题:
1) 未绘制绘图区
2) 未绘制情节
3)x轴应该是以我不理解的方式转换的日期。
我的可重现代码是:
library(highcharter)
t <- seq(from=as.Date('2017-01-01'), to=as.Date('2018-06-30'), by='days')
d <- runif(n = 546, min = 1, max = 10)
df <- data.frame(t,d)
highchart(type = 'stock')%>%
hc_add_series(name = "Value", type='line', color = "blue",data = df$d) %>%
hc_xAxis(categories = df$t,
type = 'date',
plotLines = list(
list(
label = list(text = "This is a plotLine"),
color = "#FF0000",
width = 5,
value = datetime_to_timestamp(as.Date('2017-01-10', tz = 'UTC'))
)
),
plotBands = list(
list(
label = list(text = "This is a plotBand"),
color = "rgba(100, 0, 0, 0.1)",
from = datetime_to_timestamp(as.Date('2017-02-01', tz = 'UTC')),
to = datetime_to_timestamp(as.Date('2017-02-10', tz = 'UTC'))
)
)
)
获得的输出是:
任何帮助/建议将不胜感激!