One of my apps is displaying a ggplot via uiOutput('plot.ui') and plot.ui is rendered through renderUI().
output$plot.ui=renderUI({
plotOutput('plot', width=a function(), height=a function())
})
The code works, but it is very laggy. It seems that this is a two-step process. In my app, it first renders 'plot' (which is a ggplot rendered by renderPlot), then it resizes the plot according the specified width and height. The lag between the two steps is significant (about 3 seconds). I checked it by wrapping a withProgress() around plotOutput(), and the problem still exists. I am wondering why this problem exists and if there is any way to solve it.
A small example is attached to illustrate this problem.
library(shiny)
shinyApp(
ui=shinyUI(
pageWithSidebar(
titlePanel('test'),
sidebarPanel(
sliderInput('width','Width: ', min=0,max=1000,value=100),
sliderInput('height','Height: ', min=0,max=1000,value=100)
),
mainPanel(uiOutput('plot.ui'))
)
),
server=function(input,output){
output$plot.ui=renderUI({
plotOutput('plot',width=input$width,height=input$height)
})
output$plot=renderPlot({
plot(runif(100000,1,100),runif(100000,1,100))
})
}
)
Thank you very much for your help!
plot(runif(100000,1,100),runif(100000,1,100))takes a second or two on my machine. That's a lot of points to plot. - cory