【发布时间】:2015-08-03 15:56:21
【问题描述】:
我的一个应用程序通过uiOutput('plot.ui') 显示一个ggplot,而plot.ui 通过renderUI() 呈现。
output$plot.ui=renderUI({
plotOutput('plot', width=a function(), height=a function())
})
代码有效,但非常滞后。这似乎是一个两步的过程。在我的应用程序中,它首先渲染“绘图”(这是由 renderPlot 渲染的 ggplot),然后根据指定的宽度和高度调整绘图的大小。两个步骤之间的延迟很明显(大约 3 秒)。我通过在 plotOutput() 周围包裹一个 withProgress() 来检查它,问题仍然存在。我想知道为什么会存在这个问题,以及是否有任何方法可以解决它。
附上一个小例子来说明这个问题。
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))
})
}
)
非常感谢您的帮助!
【问题讨论】:
-
它不是闪亮的......只是在我的机器上运行
plot(runif(100000,1,100),runif(100000,1,100))需要一两秒钟。有很多要点要绘制。