显示多个菜单项,每个菜单项都有子菜单项

时间:2019-06-24 17:42:25

标签: r shiny shinydashboard

我正在创建一个网站,其中包含供下载的数据集和可动态可视化数据的图表。当我仅将一个菜单项与2个子菜单​​项一起使用时,代码可以完美运行。但是,当我突然添加其他菜单项时,我的绘图都无法完全渲染。

当我添加带有子菜单的第二个菜单项时,它会在边栏中正确显示菜单项和子菜单项;但是,没有一个图可以完全显示在体内,即使是以前经过重新调整的图也是如此(当只有一个菜单项时)。

ui <- dashboardPage(
  dashboardHeader(title = "OpiDB", titleWidth = 100),
  dashboardSidebar(
    sidebarMenu(id = "tabs",
                menuItem(text = "About", tabName = "About", icon = icon("clipboard")),
                menuItem("VDH", tabName = "VDH", 
                         icon = icon("dashboard"),
                         menuSubItem("Data",
                                     tabName = "Data",
                                     icon = icon('database')),
                         menuSubItem("Plots",
                                     tabName = "Plots",
                                     icon = icon('line-chart'))),
                menuItem("SAMHSA", tabName = "SAMHSA",
                         icon = icon("dashboard")),
                menuItem("myGithub", href = "https://google.com", icon = icon("code"))
                # https://fontawesome.com/icons?d=gallery
    )
  ),
  dashboardBody(
    # within tabitems(), define the pages for sidebar menu items
    tabItems(
      tabItem(tabName = "About",
              h2("This is the about page!!")),
      tabItem(tabName = "VDH",
              fluidRow(
                box(plotlyOutput("SAMHSAp1")))),
      ## Using box to display plots
      tabItem(tabName = "Data",
              sidebarPanel(
                selectInput("dataset", "Select the dataset", choices = c("VDH Data")),
                br(),
                helpText(" Select the download format"),
                radioButtons("type", "Format type:",
                             choices = c("Excel (CSV)", "Text (TSV)","Text (Space Separated)", "Doc")),
                br(),
                helpText(" Click on the download button to download the dataset observations"),
                downloadButton('downloadData', 'Download')
              ),
              fluidRow(
                box(title = "Virginia Department of Heath Drug Overdose Data", tableOutput("VDHTable"), width = 6,
                    solidHeader = T, status="primary")
              )
      ),
      tabItem(tabName = "Plots",
              sidebarPanel(width = 2,
                           selectInput('var', 'Drug Type Selector', choices = c("All Opioids"=1, "Heroin"=2, "Fetanyl"=3, "Perscription Opioids"=4, "Benzos"=5, "Cocaine"=6, "All Drugs"=7, width = 2))
              ),
              mainPanel(
                fluidRow(
                  box(title = "Box with a plot", plotlyOutput("myhist", height = 375), width = 10)),
                box(title = "Summary Statistics", tableOutput("summary"), width = 4),
                box(title = "Multiple Line Graph", plotlyOutput("stackedL", height = 250), width = 8)
              )
      ),
     tabItem(tabName = "SAMHSA",
                fluidRow(
                  box(title = "Grouped Box Plot", plotlyOutput("SAMHSAp1", height = 350), width = 8)
                )
              )

    )
  )
)
'''

I expected to see the plot which I have specified in the last line of the code in the plotlyOutput. I see "SAMHSA" tab in the sidebar under the "VDH" tab but now none of the plots or data load at all. I do not receive any error message from R it just doesn't show any of my main body UI items when I click on any of the tabs. It merely shows an unrendered outline of the UI elements.

0 个答案:

没有答案