繁体   English   中英

R闪亮的仪表板选项卡

[英]R shiny dashboard tabItems not apparing

这是我的ui.R和server.R。 我不确定为什么dashboardBody中的标题没有显示。

server.R

shinyServer(function(input, output){
})

ui.R

dashboardPage(
  dashboardHeader(title = "Analysis"),
  dashboardSidebar(
    sidebarMenu(
      menuItem("Data Pull", tabName = "dataPull", icon = icon("database"),
        dateInput("startDateInput", "What is the starting date?", value = NULL, min = NULL, max = NULL, format = "yyyy-mm-dd", startview = "month", weekstart = 0, language = "en"),
        dateInput("endDateInput", "What is the ending date?", value = NULL, min = NULL, max = NULL, format = "yyyy-mm-dd", startview = "month", weekstart = 0, language = "en")
      ),
      menuItem("View Data", tabName = "dataView", icon = icon("table"),
               selectInput("dataViewSelectionInput", label = "Selection of Interest?", choices = c(1,2,3), multiple = TRUE),
               checkboxInput("dataViewAll", label = "View all pulled", value = TRUE)
               )
    )
  ),
  dashboardBody(
    tabItems(
     tabItem(tabName = "dataPull",
            h1("Data Selected")
     ),
     tabItem(tabName = "dataView",
             h2("Viewing Data")
     )
   )
  )
)

当前,仪表板似乎不允许切换到选项卡并使用下拉菜单,我在这里找到了针对其的修复程序:

将此函数添加到您的UI或全局变量的开头:

convertMenuItem <- function(mi,tabName) {
    mi$children[[1]]$attribs['data-toggle']="tab"
    mi$children[[1]]$attribs['data-value'] = tabName
    mi
}

那么您的ui文件将变为:

ui.R

dashboardPage(
  dashboardHeader(title = "Analysis"),
  dashboardSidebar(
    sidebarMenu(
      convertMenuItem(menuItem("Data Pull", icon = icon("database"),
                               dateInput("startDateInput", "What is the starting date?", value = NULL, min = NULL, max = NULL, format = "yyyy-mm-dd", startview = "month", weekstart = 0, language = "en"),
                               dateInput("endDateInput", "What is the ending date?", value = NULL, min = NULL, max = NULL, format = "yyyy-mm-dd", startview = "month", weekstart = 0, language = "en"), 
                               tabName = "dataPull"),
                      tabName="dataPull"),
      convertMenuItem(menuItem("View Data", icon = icon("table"),
                               selectInput("dataViewSelectionInput", label = "Selection of Interest?", choices = c(1,2,3), multiple = TRUE),
                               checkboxInput("dataViewAll", label = "View all pulled", value = TRUE),
                               tabName = "dataView"),
                      tabName="dataView")
    )
  ),
  dashboardBody(
    tabItems(
      tabItem(tabName = "dataPull",
              h1("Data Selected")
      ),
      tabItem(tabName = "dataView",
              h2("Viewing Data")
      )
    )
  )
)

之所以可行,是因为menuitem中有一些默认行为,如果menuItem具有子项,它将不会设置数据切换或数据值标签,因此我手动设置它们。 (编辑以消除错字)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM