Flexdashboard slow with multiple ggplotly

I'm working on a dashboard using the flexdashboard package. I have few tabs and in each tab I have around 12 plots. In total I have about 60 plots. I started out using plotly but when the dashboard got big it took really long time to run so I switched to ggplot instead of plotly.

My question is. Is there any kind of maximum amount of plotly plots that I can have in one dashboard?

plotly is a javascript library. So it loads lots of stuff, including data for the graph into the client browser to print the graph. Combining with flexdashboard, depending on how you set it up, it could mean that you have a BIG html that includes all the 60 graph with their data ! That could lead to some loading time.
If you used self_contained = FALSE, you should have a smaller html file because some of the stuff are into folders. But even in this case the loading time could be heavy because everything loads in client side.

To minimize the loading time, you could have an approach of client/server when you load data in the server when needed to print a plot and render the plot on the server to send to the client. I think the app will have a smaller loading time but you will have (small ?) computation more often.
Also, with this approach, you can have some menu for user to choose which data to look at, and instead of having 60 graph, you may have less. For example, it seems you have 5 tabs. I assume each tab have the same graphs but different data here. If you replace the tabs, by a drop-down menu to select what to see, you can have a one page dashboard with 12 graphs and change the underlying data when needed to rerender the 12 graphs. All this is achievable using shiny, on its own or into Flexdashboard

Just some ideas I wanted to share - Hopes it helps

1 Like

Thank you so much for the help. I think I'll try the Shiny solution.

If you have a bunch of graphs of the same type which attempt to render lots of things like points, lines, etc, you could try leveraging toWebGL() and partial_bundle()

@vidaringa

If speed is an issue, I would suggest using the plotting functions from base R that are much much faster than ggplot2. If paneling is required, the lattice package offers such functionality and creates plots faster than ggplot2 (but not as fast as base R graphics).