I am working on an app with a scrollable sidebarPanel where the the height of the mainPanel can vary, for example:
library(shiny)
ui <- fluidPage(
headerPanel('Iris k-means clustering'),
sidebarPanel(style = "overflow-y:scroll; max-height: 600px; position:relative;",
numericInput('clusters', 'Cluster count', 3, min = 1, max = 9),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('ycol', 'Y Variable', names(iris),
selected = names(iris)[[2]])
),
mainPanel(
plotOutput('plot1'),
conditionalPanel("input.clusters == 2",
plotOutput('plot2')
)
)
)
server <- function(input, output) {
output$plot1 <- renderPlot({
plot(x=iris$Sepal.Length, iris$Sepal.Width,
col = iris$Species, pch = 20, cex = 3)
})
output$plot2 <- renderPlot({
plot(x=iris$Petal.Length, iris$Petal.Width,
col = iris$Species, pch = 20, cex = 3)
})
}
shinyApp(ui = ui, server = server)
the height of mainPanel changes if cluster == 2. Is there a way to allow the height of the side-bar to automatically match the height of the mainPanel output? So that the sidebarPanel always goes to the bottom of the page, but still scrolls.
I assume it is something to do with the max-height css param but not sure where to go from there.
Thanks!