4

Is renderPlot in server.R paired with plotOuput in ui.R slow? It seems like it is because I have tried two plotting methods. The first involved using rCharts high charts library. My plotting function using high charts rendered each plot in about 0.007 to 0.01 seconds, whereas my plotting function using lattice rendered each plot in about 0.003 to 0.004 seconds, faster than my high charts plotting function as expected. However, when I use lattice in shiny, I use renderPlot and plotOutput (the standard way of displaying plots in shiny), and it renders more slowly than my high charts version which involves renderChart2 and showOutput as described here:

rCharts with Highcharts as shiny application

I can tell it renders more slowly because I am using making an animation, with a new plot rendering per tick of the animation. In other words I have a slider like this:

  sliderInput("animation",
              "Animation",
                  min = 1,
               max = 20000,
                 value = 1,
                  step = 1,
                  animate = animationOptions(interval = 30, 
                            playButton = icon('play', "fa-3x"),
                            pauseButton = icon('pause', "fa-3x")))

Thus, the ticks are occuring once every 30 milliseconds, and given that the plot renders in 4 milliseconds, I was surprised when my plots still lagged in between ticks, whereas the slower plotting function with rCharts high charts has no lag whatsoever. Is there a solution to this? If more information is needed, I will happily edit this post to include it, but I am pretty sure that it has to do with the renderPlot paired with plotOutput (used for the plotting function with lattice) compared to renderChart2 paired with showOutput (used for the plotting function with rCharts high charts) because those are the only two things I changed in my shiny app besides of course the plotting functions. I also microbenchmarked and the mean, median, min, and max were all faster for the lattice plotting function compared to the high charts rCharts plotting function. Any help would be greatly appreciated! Thanks!

Community
  • 1
  • 1
johnny838
  • 922
  • 7
  • 15
  • 1
    The lattice/ggplot plots in R are rendered as images and are updated after every update/tick. Whereas rCharts/HighCharts plots are not images, instead they are html objects. I guess that is the reason why your plots are lagging. – Shiva Jul 10 '15 at 18:05
  • Awesome thanks Shiva! Do you happen to have any suggestions for packages that do similar rendering to rCharts/HighCharts but are completely free? Thanks! – johnny838 Jul 10 '15 at 19:07
  • rCharts is absolutely opensource ! – Shiva Jul 10 '15 at 19:09
  • the problem though is that high charts is not available for commercial usage, and the other libraries I found to either have bugs (nvd3 problematic on linux) or have much slower plot rendering speed. – johnny838 Jul 10 '15 at 19:28
  • 1
    As of now, I do not have any idea on other packages. If you happen to know Front-end scripting, it is not difficult to achieve the desired functionality as Shiny has support for native HTML, CSS and JS. – Shiva Jul 10 '15 at 19:47
  • Okay thank you for your suggestions! I will take a look into it. – johnny838 Jul 10 '15 at 19:52

0 Answers0