【问题标题】:How to center values in boxvalues for shiny/flexdashboard?如何在闪亮/flexdashboard的boxvalues中居中?
【发布时间】:2021-05-07 14:23:56
【问题描述】:

我的仪表板顶部有这些框值。我想将标题和值居中对齐。

【问题讨论】:

    标签: r r-markdown flexdashboard


    【解决方案1】:

    为了重现您的示例,我使用了一个闪亮的仪表板骨架,我将 infobox 放在了 column() 中,而 fluidRow 则放在了 fluidRow 中。诀窍是在列中添加 width = 3,align="center"

    library(shiny)
    library(shinydashboard)
    
    ui <- dashboardPage(
      dashboardHeader(),
      dashboardSidebar(),
      dashboardBody(fluidRow(
        # A static infoBox
       column( infoBox("New Orders", 10 * 2, icon = icon("credit-card")), width = 3,align="center"),
    
        ),)
    )
    
    server <- function(input, output) { }
    
    shinyApp(ui, server)
    
    • 我的信息框居中

    要在Rmd 文件中呈现它,只需使用它

    ---
    title: "Untitled"
    author: "Daniel"
    date: "5/6/2021"
    output: html_document
    runtime: shiny
    ---
    
    ```{r}
    library(shiny)
    library(shinydashboard)
    
    ui <- dashboardPage(
      dashboardHeader(),
      dashboardSidebar(),
      dashboardBody(fluidRow(
        # A static infoBox
       column( infoBox("New Orders", 10 * 2, icon =     icon("credit-card")), width = 3,align="center"),
    
        ),)
    )
    
    server <- function(input, output) { }
    
    shinyApp(ui, server)
    ```
    

    您必须放大 Rmarkdown 文件闪亮窗口才能获得响应效果。

    【讨论】:

    • 谢谢,这是写成块还是在markdown文件的顶部区域?
    • 你可以把它保存为一个普通的 R 文件,RStudio 会知道它是一个闪亮的应用程序
    • 我更新了我的答案以将其显示在 Rmarkdown 文件中。
    猜你喜欢
    • 2017-05-28
    • 2017-03-29
    • 2022-01-21
    • 2018-01-25
    • 2019-12-21
    • 2020-09-20
    • 2021-03-02
    • 1970-01-01
    • 2016-09-18
    相关资源
    最近更新 更多