【发布时间】:2016-07-14 19:59:15
【问题描述】:
我的闪亮应用中有大约 10 个从 ggplot 转换而来的绘图图,它每 10 秒刷新一次。 Plotly 可以正常刷新几次,但随后显示 ERROR too many open devices。
我的代码如下(简称为只显示一张图):
服务器.R
pullData 是从数据库中提取数据的函数。
library(lubridate)
library(shinyjs)
library(ggplot2)
library(plotly)
server <- function(input, output, session) {
d <- reactive({
invalidateLater(10000, session)
pullData() %>% filter(!is.na(time))
})
output$Run <- renderPlotly({
pdf(NULL)
ggplotly(ggplot(d(), aes(x = as.POSIXlt(time) , y = mile)) +
geom_point() +
theme_bw() +
xlab('Time') +
ylab('mile'))
})
ui.R
library(shinydashboard)
library(shiny)
library(shinyjs)
library(plotly)
ui <- dashboardPage(
dashboardHeader(title = "Analytics DashBoard")
,skin = 'green'
,dashboardSidebar(
tags$head(
tags$style(HTML("
.sidebar { height: 90vh; overflow-y: auto; }
" )
)
),
# sidebarSearchForm(label = "Search...", "searchText", "searchButton"),
sidebarMenu(
, menuItem("Real Time Graphs", tabName = "RealTimeG", icon = icon("cog"))
)
)
,dashboardBody(
tabItems(
,tabItem(
tabName = "RealTimeG"
,fluidRow(
box(
title = "total Run Time"
,plotlyOutput("Run")
, width = 6
)
)
)
))
什么是问题?以及如何解决?
【问题讨论】: