rstudio / shinydashboard

Shiny Dashboarding framework
https://rstudio.github.io/shinydashboard/
Other
892 stars 300 forks source link

grid.arrange plot not rendering until resize window #245

Open mitul-patel opened 6 years ago

mitul-patel commented 6 years ago

Hello, I have been working on shiny App. I have problem regarding grid.arrange plot. It doesn't render plot until I resize the window. Then again to update the plot I have to resize window again.

Any ideas why I have not been able to render multiplots in shiny?

I have tried with ....

# R script........

scatterPlot <- function(
  data.plot,
  pt.size,
  pch.use,
  cols.use,
  min.cutoff,
  max.cutoff,
  no.axes,
) {
p <- ggplot(data = data.plot, mapping = aes(x = x, y = y))

p <- p + geom_point(
        mapping = aes(color = col),
        size = pt.size,
        shape = pch.use
      ) + scale_color_brewer(palette = cols.use)
return(p)
}

sPlot <- function(
  object,
  min.cutoff = NA,
  max.cutoff = NA,
  pt.size = 1,
  cols.use = c("yellow", "red"),
  pch.use = 16,
  nCol = NULL,
  no.axes = FALSE,
  ) {
pList <- mapply(
      FUN = scatterPlot,
      min.cutoff = min.cutoff,
      max.cutoff = max.cutoff,
      MoreArgs = list(
        data.use = data.use,
        pt.size = pt.size,
        pch.use = pch.use,
        cols.use = cols.use,
        no.axes = no.axes,
      ),
      SIMPLIFY = FALSE
    )

print(x = cowplot::plot_grid(plotlist = pList, ncol = nCol))
}

# shiny app 

plot1 <- sPlot(object = data)

grid.arrange(grobs = plot1, ncol=3)

plot_grid(plotlist = plot1, ncol=3)

But both failed to render plot.

bborgesr commented 6 years ago

I'll look into this as soon as I start working on this package again, thanks for the report!

bborgesr commented 6 years ago

Although, let me just ask you, is this a Shiny issue or a shinydashboard issue? Because if it is general to all shiny apps, you should close this issue and open a new one in rstudio/shiny/issues.

Also, it would help tremendously, if you have a minimal reproducible example of the app itself (so I can copy paste the code, run it and see what the problem is immediately).