【发布时间】:2018-01-19 17:27:57
【问题描述】:
我每秒都在更新一个从 sql 数据库读取的文本输出,它只需要一些时间。在仪表板中,我只想看看输出如何在没有花哨的动画/闪烁的情况下发生变化。是否可以删除动画并在等待更新时仅显示文本?
这是一些代码示例,您可以在其中看到更新的闪烁:
# ui.R
library(shiny)
shinyUI(fluidPage(
# App title ----
titlePanel("Title"),
# Sidebar layout with input and output definitions ----
sidebarLayout(
# Sidebar panel for inputs ----
sidebarPanel(),
# Main panel for displaying outputs ----
mainPanel(
# Output: Data file ----
# Output: Tabset w/ plot, summary, and table ----
tabsetPanel(type = "tabs",
tabPanel("Main",
textOutput("foo"))
)
)
)
)
)
# server.R
library(shiny)
check_for_update <- function() {
Sys.time()
}
get_data <- function() {
df <- data.frame(replicate(20000,sample(0:1000,rep=TRUE)))
}
shinyServer(
function(input, output, session) {
# checks for new data every 1 seconds
data <- reactivePoll(50, session,
checkFunc = check_for_update,
valueFunc = get_data)
# the outputs will only be refreshed in case the data changed
output$foo <- renderText({
df <- data()
df[[2]]
})
}
)
提前致谢!
【问题讨论】:
-
你能做一个minimal和reproducible的例子吗?
-
更新了问题!
-
快到了,我们无法测试您的代码。你能让它重现吗?
-
成功了!你能把它作为答案发布,这样我就可以给你和乔的功劳了吗?