【问题标题】:Shiny InfoBox Width not Applying闪亮的信息框宽度不适用
【发布时间】:2020-04-12 14:07:41
【问题描述】:

我试图让两个闪亮的 InfoBox 并排放置,在它们之间占据流动行内的整个宽度。为此,我指定宽度 = 6,即引导程序 12 的一半。

但是,width 参数对以 col-sm-4 (#shiny-html-output col-sm-4) 出现的 Div 类没有影响。结果,这两个盒子占据了 2/3 和(4+4 的十二分之一)。

作为一个附带问题,我还希望能够直接指定肤色,而不仅仅是黄色,这是我从可用肤色中最接近橙色的颜色。我怀疑我需要用 CSS 覆盖。

library(shiny)
library(shinydashboard)
dashboard_colour <- "orange"

sidebar <- dashboardSidebar(
    sidebarMenu(
        menuItem("Overview", tabName = "overview", icon = icon("dashboard"))
    )
)
body <- dashboardBody(
    tabItems(
        tabItem(tabName = "overview",
                h2("Overview"),
                fluidRow(
                    infoBoxOutput("boxLeft"),
                    infoBoxOutput("boxRight")
                )
        )
    )
)
ui <- dashboardPage(
    skin = "yellow",
    dashboardHeader(title = "Orange Dashboard"),
    sidebar,
    body
)

server <- function(input, output) {
    output$boxLeft <- renderValueBox({
        infoBox(
            123, "No on Left", 
            icon = icon("arrow-alt-circle-left", class = "infoIcon"),
            color = dashboard_colour,
            width = 6
        )
    })
    output$boxRight <- renderValueBox({
        infoBox(
            456, "No on Right", 
            icon = icon("arrow-alt-circle-right", class = "infoIcon"),
            color = dashboard_colour,
            width = 6
        )
    })
}

# Run the application 
shinyApp(ui = ui, server = server)

【问题讨论】:

    标签: css r shiny


    【解决方案1】:

    infoBoxOutput 的宽度设为 6 即可:

        fluidRow(
                  infoBoxOutput("boxLeft", width = 6),
                  infoBoxOutput("boxRight", width = 6)
                )
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-23
      • 1970-01-01
      • 2018-07-02
      • 2018-05-30
      • 1970-01-01
      相关资源
      最近更新 更多