【发布时间】:2018-10-18 14:35:02
【问题描述】:
我有一个使用 shinydashboardPlus 和 shinydashboard 制作的闪亮应用程序,我希望在用户单击带有我的绘图的 menuItem 时自动打开 rightSidebar。
我已经尝试了几个小时来寻找这个问题的答案,但我没有找到任何东西。我不确定这是否可能,但我想我会在这里询问是否有人对如何做到这一点有任何见解(如果可能的话)。
示例应用:
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
header<-dashboardHeaderPlus(enable_rightsidebar = TRUE,
rightSidebarIcon = "bars")
sidebar<- dashboardSidebar(
sidebarMenu(
menuItem("Data",
tabName = "data"),
menuItem("Plots",
tabName = "plots",
icon = icon("bar-chart-o"))))
body<-dashboardBody(
tabItems(
tabItem(tabName = "data","DATA"),
tabItem(tabName = "plots",
box(plotOutput("plot1")))))
rightsidebar<-rightSidebar(
background = "dark",
rightSidebarTabContent(
id=1,
title = "Customize Plots",
icon = "desktop",
active = T,
sliderInput("slider", "Number of observations:", 1, 100, 50)))
ui<- dashboardPagePlus(header = header,
sidebar = sidebar,
body = body,
rightsidebar = rightsidebar,
)
server<- function(input,output,session){
set.seed(122)
histdata <- rnorm(500)
output$plot1<- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
}
shinyApp(ui, server)
【问题讨论】:
标签: r shiny shinydashboard