Closed jchan-scc closed 9 years ago
That should already be possible.
Is this the syntax for instance? It doesnt work for me
sidebarMenu(
menuItem("A", tabName = "a", icon = icon("group", lib="font-awesome"))
,menuItem("B", tabName = "b", icon = icon("check-circle", lib = "font-awesome"))
,menuItem("C", tabName = "c", icon = icon("coffee", lib = "font-awesome"))
,helpText("hello!")
)
You're right, that didn't work right before - the content had to go outside of the sidebarMenu. I've made it more tolerant in aac931c. Here's an example app that shows how to place content in a number of different places.
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(id = "sidebarmenu",
menuItem("A", tabName = "a", icon = icon("group", lib="font-awesome")),
menuItem("B", tabName = "b", icon = icon("check-circle", lib = "font-awesome")),
sliderInput("b", "Under sidebarMenu", 1, 100, 50),
menuItem("Sub-items C",
sliderInput("c1", "Under menuItem 1", 1, 100, 50),
sliderInput("c2", "Under menuItem 2", 1, 100, 50)
)
),
sliderInput("x", "Outside of menu", 1, 100, 50)
),
dashboardBody()
)
server <- function(input, output) {}
shinyApp(ui, server)
Hi Hope this is the correct spot for this. I'm working on a ShinyDashboard with input in sidebarMenu / MenuItem. Content comes up perfectly but cannot get it to connect with dashboardBody. Large plot (output$Sum1) detailed below works perfectly when input is within dashboardBody.
Any help would be greatly appreciated.
JW
library(shiny) library(shinydashboard) library(shinythemes) library(shinyWidgets) library(dplyr) library(tidyverse) library(readxl) library(writexl) library(formattable) library(DT) library(zoo) library(lubridate) library(plotly) library(shinycssloaders) library(shinydashboardPlus)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(id="tabs",
menuItem("Load Summary", tabName = "LoadS", icon = icon("dashboard"),
selectInput(inputId = "SQD",
label = "Select Squad",
choice = c("Senior", "Academy")),
selectInput(inputId = "LoadSum",
label = "Load Summary",
choice = c("Distance", "AvgSpeed", "HSR", "Sprints", "COD_Load")))
dashboardBody(tabItems( tabItem(tabName = "LoadS", fluidRow( box(plotlyOutput("Sum1", height = 400) %>% withSpinner(color="#0dc5c1")
)#box
)#fluidRow
),#tabItem
)#dashboardBody )#tabItems )#dashboardPage
server <- function(input, output) {
output$Sum1 <- renderPlotly({
SQ1 <- input$SQD
VAR <- input$LoadSum
TG3 <- RG3 %>% filter(Squad == SQ1) %>%
filter(Type == "All Session") %>%
filter(Variable == VAR)
TG4 <- TG3 %>% group_by(Date) %>%
summarize(Avg_Var = mean(Data),
Var_sd = sd(Data)) %>%
mutate(Event = "Training") %>%
mutate_if(is.numeric, round, digits = 2)
###########################################################
#Summarize Game
GA1 <- RG3 %>% filter(Type == "Game") %>%
filter(Squad == SQ1) %>%
filter(Variable == VAR)
GA2 <- GA1 %>% group_by(Name, Date) %>%
summarize(Sum_Var = sum(Data))
Date <- GA2 %>% pull(Date)
Variable <- GA2 %>% pull(Sum_Var)
BI <- bind_cols(Date, Variable) %>%
rename(Date = c(1), Variable = c(2))
BI2 <- BI %>% group_by(Date) %>%
summarize(Avg_Var = mean(Variable),
Var_sd = sd(Variable)) %>%
mutate(Event = "Game") %>%
mutate_if(is.numeric, round, digits = 2)
############################################################
#Full data set + add TSB Variables
FD <- bind_rows(BI2, TG4)
GF <- FD %>% filter(Date >= as.Date("2020-12-04") & Date <= as.Date("2020-12-16"))
GFa <- GF %>% mutate(Avg_Var = Avg_Var - Avg_Var) %>%
mutate(Var_sd = Var_sd - Var_sd)
FG <- FD %>% filter(Date <= as.Date("2020-12-04") | Date > as.Date("2020-12-16"))
FD <- bind_rows(GFa, FG)
FD2 <- FD %>% arrange(Date) %>%
mutate(A_Load = zoo::rollmean(Avg_Var, k = 7, fill = NA, align = "right"),
C_Load = zoo::rollmean(Avg_Var, k = 28, fill = NA, align = "right")) %>%
mutate(TSB = A_Load / C_Load) %>%
mutate(Date = as.Date(Date)) %>%
mutate_if(is.numeric, round, digits = 2)
############################################################
p <- ggplot(FD2, aes(Date, Avg_Var, label = Event)) +
geom_smooth(method = 'loess', alpha = 0.1, show.legend = FALSE, fill = "lightsteelblue", colour = "grey99", span = 0.3) +
geom_point(size=2.5, shape=21, colour = "slategrey", fill="slategrey") +
geom_point(data=subset(FD2, Event == "Game"), color = "red", fill = "red") +
geom_errorbar(aes(ymin=Avg_Var-Var_sd, ymax=Avg_Var+Var_sd), width=.2,
position=position_dodge(0.05), alpha = 0.4)+
geom_line(aes(y = A_Load), color = "green", size = 1.2, alpha =0.5) +
geom_line(aes(y = C_Load), color = "blue", size = 1.2, alpha =0.3) +
theme_classic()
fig <- ggplotly(p)
fig
})}
shinyApp(ui, server)
Can we allow the sidebar inputs to be under menuItem & menuSubItem?