Shinydashboard的问题-DashboardSidebar和DashboardBody

时间:2018-11-10 17:33:06

标签: r shiny shinydashboard

我是Shiny和Shinydashboard的新手。请考虑以下代码片段(巨大代码的一小部分):

dbsidebar <- dashboardSidebar(
  sidebarMenu(
    menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")), 
    menuItem("Rank List", icon = icon("th"), tabName = "Widgets1", badgeColor = "green"),
    menuItem("Build Your", icon = icon("th"), tabName = "Widgets2", badgeColor = "green"),
    menuItem("Groups", icon = icon("th"), tabName = "Widgets3", badgeColor = "green")

  )
)


dbBody <- dashboardBody(
  tabItems(  
    tabItem(tabName = "dashboard",
      fluidRow(

        #Pie Charts
        splitLayout(
          #cellWidths = c("50%", "50%"),
          style = "border: 1px solid silver;",
          cellWidths = 450,
          cellArgs = list(style = "padding: 6px"),
          plotlyOutput("Piechart1", width = "400px", height = "200px"),
          plotlyOutput("Piechart2", width = "400px", height = "200px"),
          plotlyOutput("Piechart3", width = "400px", height = "200px")
        )
      )
    ),
    tabItem(tabName = "Widgets1",
        #Sidebar with a slider input for number of bins
        sidebarLayout(
          sidebarPanel(
            sliderInput("TCScore","TCScore:",min = 0, max = 100, value = c(0,100))
          ),

          # Show a plot of the generated distribution
          mainPanel(
            tabPanel("Heading", plotlyOutput("tbTable"))
          )

        ),
        downloadButton('downloadData', 'Download')


    ),
    tabItem(tabName = "Widgets2", "XX"

            # #Data Table
            # sidebarLayout(
            #   sidebarPanel(
            #     sliderInput("TCCScore","TCCScore:",min = 0, max = 100, value = c(0,100)),
            #   ),
            # 
            #   # Show a plot of the generated distribution
            #   mainPanel(
            #     tabPanel("Heading", dataTableOutput("tbTable1"))
            #   )
            # 
            # ),
            # downloadButton('downloadData', 'Download')


    ),
    tabItem(tabName = "Widgets3", "third"


    )
  )
)

在仪表板侧栏上,我添加了4个选项卡-仪表板,Widget1,Widget2,Widget3。最初,对于每个选项卡,我都使用简单的文本来呈现UIdashboardBody并正确显示。我开始填写这些部分中的每一个-“ dashboard”,“ Widget1”,显示对我来说都是正确的。不幸的是,对于“ Widget2-当我删除“ XX”并取消注释上面显示的代码时,UI完全失真。看起来仪表板中的主要UI元素未呈现?有人可以告诉我我做错了什么吗? ?请帮忙,对不起,我还没有发布完整的工作代码,但是它太长了,因此我只需要提供一个小代码段即可。

提前谢谢!欢呼!

0 个答案:

没有答案