首页 > 解决方案 > Shiny 应用程序中的“SummaryTools”使用“bootswatch”应用自定义主题

问题描述

我正在使用“Shiny”创建一个网络应用程序,并且曾经summarytools::dfSummary打印出我的数据摘要。我曾经bs_theme使用选择的十六进制值来主题化应用程序。

我正在努力格式化来自 的输出summarytools::dfSummary,它最终只格式化了摘要的图形部分,而其余的输出没有主题化。

我可以DT::datatable通过添加来设置我的主题style = "bootstrap",但是无法获得相同的效果dfsummary

应用程序主题:查看我的主题在我的应用程序的其他部分中的工作方式

查看我的“dfSummary”输出

服务器代码

shinyServer(function(input, output, session) {
    
    output$data_dt <- DT::renderDataTable({
        DT::datatable(data = as.data.frame(data_a2),
                      style = "bootstrap")
    })
    
    output$Summary <- renderUI({
        
        summary_stats <- data_a2 %>%
            summarytools::dfSummary() %>%
            print(method = "render",
                  plain.ascii = FALSE,
                  graph.magnif = 0.8,
                  headings = TRUE,
                  bootstrap.css = FALSE,
                  style= "bootstrap")
    })
    
})

用户界面代码

shinyUI(
    navbarPage(
        title = ("stuff"),
        #Raw data
        tabPanel("raw data",
                 DT::dataTableOutput(outputId= "data_dt")
        ),
        #summary
        tabPanel("summary",
                 htmlOutput(outputId= "Summary")
        ),
        #theme
        inverse = TRUE,
        theme = bs_theme(version = 4,
                         bg = "#1A1A1A",
                         fg = "#BC7B7D",
                         primary = "#CFB1B3",
                         base_font = font_google("Space Mono"))
    )
)

对此的任何帮助将不胜感激,谢谢!

标签: rbootstrap-4shinysummarytools

解决方案


推荐阅读