Search code examples
rggplot2shinydygraphsr-dygraphs

Is it possible to make a fan chart with dygraphs?


I'm wanting to combine multiple lower/value/upper style series in one graph with shaded bars. Is it possible to create?

For example, for xts object "new_df" below:

df <- data.frame("value" = c(1,2,3,4,5), "upper1" = c(1.2, 2.3, 3.1, 4.6, 5.9), "lower1" = c(0.5, 1.8, 2.6, 3.7, 4.9), "upper2" = c(1.2, 2.1, 3.5, 4.8, 5.9), "lower2" = c(0.3, 1.4, 2.7, 3.5, 4.8))
dates <- c("2014-10-01", "2014-11-01", "2014-12-01", "2015-01-01", "2015-02-01")
time <- as.Date(dates)
new_df <- as.xts(df, order.by = time)

This is new_df:

enter image description here

This is example of plot that I want to get, but I want to get multiple in one graph enter image description here


Solution

  • Are you looking for this?

    dygraph(new_df, main = "testing") %>%
      dySeries(c("lower1", "value", "upper1"), label = "num1") %>% 
      dySeries(c("lower2", "value", "upper2"), label = "num2")