Reputation: 5789
There is an option in Dygraphs to fill the aera under the lines:
library(dygraphs)
lungDeaths <- cbind(ldeaths, mdeaths, fdeaths)
dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
dySeries("fdeaths", stepPlot = TRUE, color = "red", fillGraph = TRUE)
My question is: how to fill the area above the lines?
Upvotes: 0
Views: 736
Reputation: 1058
This is the closest I can get, at this time. You've got to create the illusion of a shaded graph. You have to create a top dummy dataset to accomplish this to plot what you're asking about. After this, you can set the axis limits to get what you asked about.
Note: The bottom portion is rather tricky to include given we are stacking them onto top of each other. It's not ideal (what's posted below).
library(dygraphs)
top <- structure(rep(10000, 72), .Tsp = c(1974, 1979.91666666667, 12), class = "ts")
lungDeaths <- cbind(top, ldeaths, mdeaths, fdeaths)
dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
dyLegend(show = "never", hideOnMouseOut = FALSE)%>%
dyOptions(stackedGraph = TRUE)%>%
dyRangeSelector()%>%
dyAxis("y", valueRange = c(0, 8000))
If you want a large gap below, then try adding some other dummy values, like this.
lungDeaths <- cbind(top, ldeaths, mdeaths, fdeaths, top)
dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
dyLegend(show = "never", hideOnMouseOut = FALSE)%>%
dyOptions(stackedGraph = TRUE)%>%
dyRangeSelector()%>%
dyAxis("y", valueRange = c(8000, 20000))
Upvotes: 2