I have an app that I made with shinydashboardPlus and shinydashboard that I would like to have the rightSidebar automatically open when the menuItem with my plots are clicked by the user.
I have been trying to find an answer to this for a couple hours now and I haven't found anything. I am not sure if this is possible but I figured I'd ask on here to see if anyone has any insight on how to do this (If possible).
Sample App:
UI
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:
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)