【问题标题】:Getting Shiny (RMarkdown) to use full browser window让 Shiny (RMarkdown) 使用完整的浏览器窗口
【发布时间】:2014-09-01 22:56:14
【问题描述】:

在 Windows 7 64 位的 R 3.1.1 上使用 RStudio 0.98.1028,使用 Shiny 的 fluidPage、sidebarLayout 和 sidebarPanel 创建交互式文档。它们都玩得很好,正如在小窗口尺寸上所描述的那样,但是当我使用 RStudio 的内置浏览器或网络浏览器(IE 11)全屏显示时,有一个巨大的(大约 40%)区域只是我的窗口左侧没有被使用的空白。我该怎么做才能让 Shiny 使用我所有的浏览器窗口宽度?

测试用例:

---
title: "TestBed"
author: "Derek Slone-Zhen"
date: "Tuesday, September 02, 2014"
output: html_document
runtime: shiny
---

```{r echo=FALSE}
shinyUI(fluidPage(
  titlePanel("title panel"),

  sidebarLayout(
    sidebarPanel(

            actionButton("goButton", label="Submit")
      ),
    mainPanel(
        renderDataTable({
          input$goButton
          mx <- 1:10000
          dim(mx) <- c(100,100)
          mx <- as.data.frame(mx)
          mx
        } 
      )
    )
  )
))
```

我不喜欢的样子:

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    你可能需要运行开发版的 rmarkdown 所以

    devtools::install_github("rstudio/rmarkdown") 
    

    https://github.com/rstudio/rmarkdown/issues/135

    将您的 yaml 标头更改为:

    ---
    title: "TestBed"
    author: "Derek Slone-Zhen"
    date: "Tuesday, September 02, 2014"
    runtime: shiny
    output:
      html_document:
        css: my.css
    ---
    

    然后,您可以在 .Rmd 文件所在的同一目录中添加 CSS my.css。 默认情况下,markdown 被放置在一个引导 fluid 容器中,该容器具有class = main-container 和默认样式margin-left: auto;。例如,您可以更改此设置

    我的.css:

    .main-container{
      margin-left: 0px !important;
      } 
    

    导致:

    【讨论】:

    • 这些天,我还发现自己添加了 margin-right: 8px !important;max-width: 98% !important; 以使用完整的窗口。
    • 如何最大化高度? @dsz
    猜你喜欢
    • 2012-03-08
    • 1970-01-01
    • 1970-01-01
    • 2022-01-08
    • 2014-04-16
    • 2018-03-16
    • 1970-01-01
    • 1970-01-01
    • 2013-06-15
    相关资源
    最近更新 更多