在 Shiny Dashboard 中填充整个 tabItem window

Fill entire tabItem window in Shiny Dashboard

我看过一些类似的问题,但没有找到其他解决方案。我试图让 Shiny Dashboard 中的 tabItem 的 uiOutput/htmlOutput 显示包 netCoin 中的完整网络。对于我的一生,我无法弄清楚为什么这行不通。下面的可重现示例:


library(shinydashboard)
library(netCoin)

ui = dashboardPage(
  dashboardHeader(title = "Example"),
  dashboardSidebar(
    sidebarMenu(
      menuItem("Example", tabName = "example", icon = icon("user"))
    )
  ),
  dashboardBody(
    tabItems(
      tabItem(tabName = "example",
              fillPage(
                tags$style(type = "text/css", "#fullpage {height: calc(100vh - 80px) !important;}"),
                uiOutput("fullpage")
              )
      )
    )
  )
)

server = function(input, output) {
  output$fullpage = renderUI({
    frame <- data.frame(A = c("Man; Women", "Women; Women",
                              "Man; Man", "Undet.; Women; Man"))
    data <- dichotomize(frame, "A", sep = "; ")[2:4]
    C <- coin(data) # coincidence matrix
    N <- asNodes(C) # node data frame
    E <- edgeList(C) # edge data frame
    net = netCoin(N, E) # netCoin object
    shinyCoin(net)
  })
}

shinyApp(ui, server)

当前的输出看起来像这样,虽然我的目标是让它填满整个页面:

想通了。我不得不修改位于 /Library/Frameworks/R.framework/Versions/4.0/Resources/library/netCoin/www 的 include.html netCoin 包文件夹中的 iframe 标签,并包含参数 height:100%.

现在是:

<iframe class="netcoin" style="border:none;overflow:hidden;width:100%;height:100%;min-height:400px;" src="index.html"></iframe>
<script type="text/javascript">
window.onload = function(){
  var iframe = document.querySelector('iframe.netcoin');
  iframe.style.height = iframe.offsetWidth/1.41 + "px";
}
</script>