如何稳定地在一个 shiny 中显示多个 dygraphs?
How do I make stable displaying multiple dygraphs in one shiny?
我在一个 Shiny App 中使用了 2 个 R dygraphs。我观察到返回图表的问题,也就是说,有时它不会 load/display 其中一个 dygraphs,有时它会。奇怪的行为。有人经历过类似的事情吗?
上下文:
ui
library(zoo)
library(dygraphs)
...
tabName="time",
fluidRow(
tabBox(width = 350,
tabPanel(title="Product", dygraphOutput("dygraph1")),
tabPanel(title="Segment", dygraphOutput("dygraph2"))
...
服务器
})
zoo<-structure(c(2252L, 2256L, 2256L, 2257L, 2259L, 2262L, 2262L,
2262L, 765L, 767L, 767L, 769L, 768L, 769L, 774L, 706L,
16239L, 16220L, 26184L, 26148L, 26091L, 26099L, 26118L,
12607L), .Dim = c(8L, 3L), .Dimnames = list(NULL, c("A",
"B", "C")), index = structure(c(16849, 16853, 16854,
16855, 16856, 16857, 16858, 16859), class = "Date"), class =
"zoo")
zoo2<-structure(c(52L, 56L, 56L, 57L, 59L, 62L, 62L,
62L, 65L, 67L, 67L, 69L, 68L, 69L, 74L, 76L,
162L, 162L, 261L, 261L, 260L, 260L, 261L,
126L), .Dim = c(8L, 3L), .Dimnames = list(NULL, c("D", "E",
"F")), index = structure(c(16849, 16853, 16854,16855,
16856, 16857, 16858, 16859), class = "Date"), class = "zoo")
output$dygraph1<-renderDygraph({
dygraph(zoo)%>%
dyOptions(stackedGraph = TRUE, drawGrid = FALSE) %>%
dyRangeSelector(height = 20)%>%
dyHighlight(highlightSeriesOpts = list(strokeWidth = 3))
})
output$dygraph2<-renderDygraph({
dygraph(zoo2) %>%
dyOptions(stackedGraph = TRUE,drawGrid = FALSE) %>%
dyRangeSelector(height = 20) %>%
dyHighlight(highlightSeriesOpts = list(strokeWidth = 3))
})
我是 运行 R Studio v. 0.99.484,R v. 3.2.3,Windows Machine,Dygraphs Package v. 0.7
因此,根据 RDygraphs 在 GitHub 上的支持(问题已关闭 @ https://github.com/rstudio/dygraphs/issues/62),这些问题并不少见。该解决方案包括将所有依赖包更新到最新版本,在我的例子中是 htmlwidgets 到 v.0.6。现在 dygraphs 正确显示 98%(2% 出了点问题,应该可以在几天内通过新版本的 htmlwidgets 解决)。
我在一个 Shiny App 中使用了 2 个 R dygraphs。我观察到返回图表的问题,也就是说,有时它不会 load/display 其中一个 dygraphs,有时它会。奇怪的行为。有人经历过类似的事情吗?
上下文:
ui
library(zoo)
library(dygraphs)
...
tabName="time",
fluidRow(
tabBox(width = 350,
tabPanel(title="Product", dygraphOutput("dygraph1")),
tabPanel(title="Segment", dygraphOutput("dygraph2"))
...
服务器
})
zoo<-structure(c(2252L, 2256L, 2256L, 2257L, 2259L, 2262L, 2262L,
2262L, 765L, 767L, 767L, 769L, 768L, 769L, 774L, 706L,
16239L, 16220L, 26184L, 26148L, 26091L, 26099L, 26118L,
12607L), .Dim = c(8L, 3L), .Dimnames = list(NULL, c("A",
"B", "C")), index = structure(c(16849, 16853, 16854,
16855, 16856, 16857, 16858, 16859), class = "Date"), class =
"zoo")
zoo2<-structure(c(52L, 56L, 56L, 57L, 59L, 62L, 62L,
62L, 65L, 67L, 67L, 69L, 68L, 69L, 74L, 76L,
162L, 162L, 261L, 261L, 260L, 260L, 261L,
126L), .Dim = c(8L, 3L), .Dimnames = list(NULL, c("D", "E",
"F")), index = structure(c(16849, 16853, 16854,16855,
16856, 16857, 16858, 16859), class = "Date"), class = "zoo")
output$dygraph1<-renderDygraph({
dygraph(zoo)%>%
dyOptions(stackedGraph = TRUE, drawGrid = FALSE) %>%
dyRangeSelector(height = 20)%>%
dyHighlight(highlightSeriesOpts = list(strokeWidth = 3))
})
output$dygraph2<-renderDygraph({
dygraph(zoo2) %>%
dyOptions(stackedGraph = TRUE,drawGrid = FALSE) %>%
dyRangeSelector(height = 20) %>%
dyHighlight(highlightSeriesOpts = list(strokeWidth = 3))
})
我是 运行 R Studio v. 0.99.484,R v. 3.2.3,Windows Machine,Dygraphs Package v. 0.7
因此,根据 RDygraphs 在 GitHub 上的支持(问题已关闭 @ https://github.com/rstudio/dygraphs/issues/62),这些问题并不少见。该解决方案包括将所有依赖包更新到最新版本,在我的例子中是 htmlwidgets 到 v.0.6。现在 dygraphs 正确显示 98%(2% 出了点问题,应该可以在几天内通过新版本的 htmlwidgets 解决)。