Patrik_P
Patrik_P

Reputation: 3200

How do I make stable displaying multiple dygraphs in one shiny?

I am using 2 R dygraphs in one Shiny App. I observe a problem returning the graphs, that is, sometimes it doesn't load/display one of the dygraphs, sometimes it does. Weird behaviour. Anyone experienced something similar?

Contexts:

ui

library(zoo)
library(dygraphs) 

...
tabName="time",
  fluidRow(
    tabBox(width = 350,
           tabPanel(title="Product", dygraphOutput("dygraph1")),
           tabPanel(title="Segment", dygraphOutput("dygraph2")) 
...

server

  })

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

  })

I am running R Studio v. 0.99.484, R v. 3.2.3, Windows Machine, Dygraphs Package v. 0.7

Upvotes: 0

Views: 1069

Answers (1)

Patrik_P
Patrik_P

Reputation: 3200

So, from support from RDygraphs on GitHub (Issue Closed @ https://github.com/rstudio/dygraphs/issues/62) these problems are not so uncommon. The solution includes updates of all dependency packages to latest versions, in my case htmlwidgets to v. 0.6. Now the dygraphs display 98% correctly (2% something goes wrong, should be possibly solved by new version of htmlwidgets in few days).

Upvotes: 1

Related Questions