【问题标题】:(R shiny) cannot change the width of infoBox(R shiny) 无法改变 infoBox 的宽度
【发布时间】:2016-03-24 04:25:49
【问题描述】:

我使用库 shinydashboard 来编写我的 ui.R。在我的dashboardBody部分,我写道:

fluidRow(infoBoxOutput("dri"))

然后在我的 server.R 中,我写道:

output$dri = renderInfoBox({
    infoBox(
        width = 2,
        title = tags$b("Score"),
        value = tags$b("100"),
        color = "aqua",
        fill = TRUE,
        icon = icon("edit")
    )
})*

但宽度不会变为 2;它仍然使用默认值,即 4(整个网页宽度的 1/3)。 有人会帮我解决这个问题吗?非常感谢!

【问题讨论】:

  • 您的infoBox 是基于列还是基于行的布局?

标签: r shiny shinydashboard


【解决方案1】:

也许你可以自己style

rm(list = ls())
library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(fluidRow(infoBoxOutput("dri")),tags$style("#dri {width:200px;}"))
)

server <- function(input, output) { 
  output$dri <- renderInfoBox({
    infoBox(
      title = tags$b("Score"),
      value = tags$b("100"),
      color = "aqua",
      fill = TRUE,
      icon = icon("edit")
    )    
  })
}
shinyApp(ui, server)

200 像素

1000 像素

【解决方案2】:

我在 github 上找到了这个答案,它也对我有用:

您可以使用 renderUI,而不是使用 renderInfoBoxinfoBoxOutputuiOutput 这对我有用。这让我觉得有一个 renderInfoBox 函数的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-17
    • 1970-01-01
    • 2015-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-18
    相关资源
    最近更新 更多