Dygraphs:填充系列上方的区域

问题描述 投票:0回答:1

Dygraphs中有一个选项可以填充以下区域:

library(dygraphs)
lungDeaths <- cbind(ldeaths, mdeaths, fdeaths)
dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
  dySeries("fdeaths", stepPlot = TRUE, color = "red", fillGraph = TRUE)   

我的问题是:如何填补线上方的区域?

r dygraphs
1个回答
2
投票

这是我目前最接近的。你必须创建一个阴影图的幻觉。您必须创建一个顶级虚拟数据集来完成此操作以绘制您所询问的内容。在此之后,您可以设置轴限制以获得您所询问的内容。

注意:底部部分相当棘手,因为我们将它们堆叠在一起。这不太理想(下面发布的内容)。

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))

enter image description here

如果你想要一个大的间隙,那么尝试添加一些其他虚拟值,像这样。

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))

enter image description here

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.