3
我有大约10个从ggplot转换的密谋图在我的闪亮的应用程序,这是每10秒刷新一次。 Plotly可以很好地进行刷新,但是会显示错误太多的开放设备。密谋图显示错误太多闪亮的开放设备
我的代码如下(短路到只显示一个曲线图):
server.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
)
)
)
))
是什么问题?以及如何解决它?
谢谢你,它的工作! –