代码之家  ›  专栏  ›  技术社区  ›  theGreatKatzul

在背景中加载闪亮的选项卡面板

  •  2
  • theGreatKatzul  · 技术社区  · 7 年前

    我有几个 tabPanel() ui.R 选项卡面板()

    在后台加载初始选项卡后,有没有办法预加载这些页面?

    我试图在服务器功能的底部包括以下内容:

    sapply(names(outputOptions(output)),function(x) outputOptions(output, x, suspendWhenHidden = FALSE))
    

    我尽量避免放置 renderPlot 在一个 observer reactiveVariable

    该转换用于一系列绘图。在结构上更容易放置 reactiveValue 观察者

      Data = reactivePoll(5479,
                   session,
                   checkFunc = function() {
                     if (file.exists(orderStatsPath))
                       file.info(orderStatsPath)$mtime[1]
                     else
                       ""
                   },
                   valueFunc = function() getData(orderStatsPath)
      )
    
      observe({
    
        Data = Data()
        Data = subset(Data, subset = Date >= Sys.Date() - 14)
        Data$Date = as.character(Data$Date)
        output$slippageRootTotalUSD = shiny::renderTable({
          result = dcast(Data,
                         Date ~ Symbol,
                         value.var = "slippageRootTotalUSD",
                         na.rm = T,
                         fun = sum,
                         margins = c("Date","Symbol"))
    
          rownames(result) = result[,1]
          result = signif(result[,-1],5)
          result
        },
        rownames = TRUE,
        hover = TRUE,
        digits = 2,
        spacing = 's'
        )
    
        output$SizeUSD = shiny::renderTable(
          {
            result = dcast(Data,
                           Date ~ Symbol,
                           value.var = "SizeUSD",
                           na.rm = T,
                           fun = sum,
                           margins = c("Date","Symbol"))
    
            rownames(result) = result[,1]
            result = round(result[,-1],0)
    
            result
          },
          rownames = TRUE,
          hover = TRUE,
          digits = 0,
          spacing = 's'
        )
        sapply(names(outputOptions(output)),function(x) outputOptions(output, x, suspendWhenHidden = FALSE))
     }
    
    1 回复  |  直到 7 年前
        1
  •  6
  •   Victorp    7 年前

    看看 ?outputOptions ,您可能想使用它:

    # Disable suspend for output$myplot
    outputOptions(output, "myplot", suspendWhenHidden = FALSE)