【问题标题】:Shiny UI not reading dashboard format闪亮的 UI 不读取仪表板格式
【发布时间】:2020-03-01 08:51:52
【问题描述】:

我有一个这样的 UI 文件:

library(dplyr)
library(tidyr)
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinythemes)
library(shinyjs)
library(flexdashboard)
library(DT)

ui <- dashboardPage(
  dashboardHeader(
    title = "Sales and Leads"),


  #sidebar content
  dashboardSidebar(
    sidebarMenu(
      menuItem("Breakdown by Day", tabName = "overview", icon = icon("dashboard")),
      menuItem("Breakdown by Month", tabName = "borders", icon = icon("th")),
      menuItem("Breakdown by Year", tabName = "sectors", icon = icon("th"))
    )
  ),

  #body content
  dashboardBody(
    tags$head(tags$style(HTML('
                              .content-wrapper, .main-body {
                              font-weight: normal;
                              font-size: 18px;
                              } '))),

    tabItems(

      #first tab content
      tabItem(tabName = "overview",

              fluidRow(
                infoBoxOutput("DialsYesterday"),
                infoBoxOutput("SalesYesterday"),
                infoBoxOutput("LeadsYesterday")
              )
      ),

      #second tab content
      tabItem(tabName = "borders",
              fluidRow(
                infoBoxOutput("DialsMonth"),
                infoBoxOutput("SalesMonth"),
                infoBoxOutput("LeadsMonth"))
      ),

      #third tab content
      tabItem(tabName = "sectors",
              fluidRow(
                infoBoxOutput("DialsYear"),
                infoBoxOutput("SalesYear"),
                infoBoxOutput("LeadsYear"),
                fluidRow(
                  infoBoxOutput("DialsAll"),
                  infoBoxOutput("SalesAll"),
                  infoBoxOutput("LeadsAll"))
              )
      )
    )
    )
    )

不过,当我运行代码时,出现的只是第一个输入框(“DialsYesterday”)。

我没有出现的所有其他输入。当您单击其他选项卡时,它只是一个空白。我一定做错了什么,但不确定是什么。我没有收到任何错误消息,所以这不是服务器端问题。我只是认为订单操作的构建方式有误。

【问题讨论】:

    标签: r shiny shinydashboard shiny-server shinyapps


    【解决方案1】:

    您好,我已经根据您的 UI 代码进行了尝试,因为您没有提供足够的代码来重现相同的代码。这是我的代码,它运行良好。您可以根据自己的要求进行更改。

    library(shiny)
    library(shinydashboard)
    library(shinydashboardPlus)
    library(DT)
    
    ui <- dashboardPage(
      dashboardHeader(
        title = "Sales and Leads"),
    
    
      #sidebar content
      dashboardSidebar(
        sidebarMenu(
          menuItem("Breakdown by Day", tabName = "overview", icon = icon("dashboard")),
          menuItem("Breakdown by Month", tabName = "borders", icon = icon("th")),
          menuItem("Breakdown by Year", tabName = "sectors", icon = icon("th"))
        )
      ),
    
      #body content
      dashboardBody(
        tags$head(tags$style(HTML('
                                  .content-wrapper, .main-body {
                                  font-weight: normal;
                                  font-size: 18px;
                                  } '))),
    
        tabItems(
    
          #first tab content
          tabItem(tabName = "overview",
    
                  fluidRow(
                    infoBoxOutput("DialsYesterday"),
                    infoBoxOutput("SalesYesterday"),
                    infoBoxOutput("LeadsYesterday")
                  )
          ),
    
          #second tab content
          tabItem(tabName = "borders",
                  fluidRow(
                    infoBoxOutput("DialsMonth"),
                    infoBoxOutput("SalesMonth"),
                    infoBoxOutput("LeadsMonth"))
          ),
    
          #third tab content
          tabItem(tabName = "sectors",
                  fluidRow(
                    infoBoxOutput("DialsYear"),
                    infoBoxOutput("SalesYear"),
                    infoBoxOutput("LeadsYear")
                  ),
                    fluidRow(
                      infoBoxOutput("DialsAll"),
                      infoBoxOutput("SalesAll"),
                      infoBoxOutput("LeadsAll")
                  )
    
          )
        )
      )
    )
    
    
    server <- function(input, output,session) {
    
      output$DialsYesterday<-renderInfoBox({
        infoBox(" TAB 1 Title 1 DialsYesterday", value = 100,subtitle = "subtitile 1")
      })
    
      output$SalesYesterday<-renderInfoBox({
        infoBox("TAB 1 Title 2 SalesYesterday", value = 100,subtitle = "subtitile 2")
      })
    
      output$LeadsYesterday<-renderInfoBox({
        infoBox("TAB 1 Title 3 LeadsYesterday", value = 100,subtitle = "subtitile 3")
      })
    
    
    
      output$DialsMonth<-renderInfoBox({
        infoBox("TAB 2 Title 1 DialsMonth", value = 100,subtitle = "subtitile 1")
      })
    
      output$SalesMonth<-renderInfoBox({
        infoBox("TAB 2 Title 2 SalesMonth", value = 100,subtitle = "subtitile 2")
      })
    
      output$LeadsMonth<-renderInfoBox({
        infoBox("TAB 2 Title 3 LeadsMonth", value = 100,subtitle = "subtitile 3")
      })
    
    
      output$DialsYear<-renderInfoBox({
        infoBox("TAB 3 Title 1 DialsYear", value = 100,subtitle = "subtitile 1")
      })
    
      output$SalesYear<-renderInfoBox({
        infoBox("TAB 3 Title 2 SalesYear", value = 100,subtitle = "subtitile 2")
      })
    
      output$LeadsYear<-renderInfoBox({
        infoBox("TAB 3 Title 3 LeadsYear", value = 100,subtitle = "subtitile 3")
      })
    
      output$DialsAll<-renderInfoBox({
        infoBox("TAB 3 Title 3 DialsAll", value = 100,subtitle = "subtitile 3")
      })
    
      output$LeadsAll<-renderInfoBox({
        infoBox("TAB 3 Title 3 LeadsAll", value = 100,subtitle = "subtitile 3")
      })
    
      output$SalesAll<-renderInfoBox({
        infoBox("TAB 3 Title 3 SalesAll", value = 100,subtitle = "subtitile 3")
      })
    
    
    
    
    }
    
    
    
    shinyApp(ui = ui, server = server)][1]][1]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-22
      • 1970-01-01
      • 2019-02-12
      • 1970-01-01
      • 2016-05-02
      • 2016-03-06
      • 2019-07-26
      相关资源
      最近更新 更多