如何在一个光泽中稳定显示多个dygraph?

时间:2016-02-26 09:38:48

标签: r shiny dygraphs shinydashboard

我在一个Shiny App中使用2个R dygraphs。我观察到返回图形时出现问题,也就是说,有时它不会加载/显示其中一个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.7。

1 个答案:

答案 0 :(得分:1)

因此,根据GitHub上的RDygraphs的支持(问题已关闭@ https://github.com/rstudio/dygraphs/issues/62),这些问题并不少见。该解决方案包括所有依赖包到最新版本的更新,在我的情况下,htmlwidgets到v.6.6。现在dygraphs显示98%正确(2%出错了,应该可以在几天内通过新版本的htmlwidgets解决)。