有没有办法在 highcharter 包中按组关联 dashStyle。我希望以“预测”为类型的行被虚线。
library(highcharter)
# Create sample data frame
sample_df <- data_frame(sku = c(rep("12",40)),
type = c(rep("actuals",20), rep("forecast",20)),
calendar_week = rep(seq(as.Date("2017-09-08"), as.Date("2018-01-23"), by=7),2),
units = round(c(rnorm(11, mean=50, sd=10), rep(0, 9), c(rnorm(20, mean=100, sd=10))),0))
# Create colours vector
custom_colours <- c("#4286f4", "#d66048")
# Chart
hchart(sample_df, "line", hcaes(calendar_week, units, group = type)) %>%
hc_yAxis(title = list(text = "Units")) %>%
hc_xAxis(title = list(text = "Week"), type = "datetime", tickInterval = 7* 24 * 3600 * 1000) %>%
hc_colors(custom_colours)
此外,是否可以将颜色与组关联,例如使用带有 ifelse 的 mutate 来创建包含数据框中颜色的列?