【问题标题】:How can I set decimal width for a column in R Shiny?如何为 R Shiny 中的列设置小数宽度?
【发布时间】:2021-01-10 19:27:37
【问题描述】:

我想在我的 R Shiny 仪表板中为 column() 元素设置小数宽度。例如,我需要 5 列,因此我需要每列 2.4 的宽度。

有办法吗?

【问题讨论】:

    标签: css r shiny dashboard


    【解决方案1】:

    Shiny 的列宽基于Bootstrap 12-wide grid system。您只能指定整数。但是,您可以nest multiple columns 来实现细粒度的布局。

    这是一个关于嵌套列的示例:

    library(shiny)
    
    ui <- fluidPage(fluidRow(
      p(),
      column(4, p(), style = "background-color: red;"),
      column(4, p(), style = "background-color: green;"),
      column(
        4,
        column(4, p(), style = "background-color: red;"),
        column(7, p(), style = "background-color: green;"),
        column(1, p(), style = "background-color: blue;")
      ),
    ))
    
    server <- function(input, output, session) {}
    
    shinyApp(ui, server)
    

    作为替代方案,您可能需要检查接受 CSS 单元的?splitLayout

    library(shiny)
    
    ui <- fluidPage(splitLayout(
      p("red", style = "background-color: red;"),
      p("green", style = "background-color: green;"),
      p("blue", style = "background-color: blue;"),
      p("yellow", style = "background-color: yellow;"),
      p("orange", style = "background-color: orange;"),
      cellWidths = "20%"
    ))
    
    server <- function(input, output, session) {
    }
    
    shinyApp(ui, server)
    

    【讨论】:

      猜你喜欢
      • 2014-06-16
      • 2019-08-08
      • 2019-12-08
      • 2021-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-05
      • 1970-01-01
      相关资源
      最近更新 更多