Skip to content

Instantly share code, notes, and snippets.

@jcheng5
Forked from charlesmilk/app.R
Created May 26, 2016 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcheng5/0d234bf8dd82a01e08c09ca155870d50 to your computer and use it in GitHub Desktop.
Save jcheng5/0d234bf8dd82a01e08c09ca155870d50 to your computer and use it in GitHub Desktop.
Shiny - The grey bar is not follow the size of the plots bigger than the window size
library(shiny)
library(shinyjs)
library(DT)
data("cars")
ui <- tagList(
useShinyjs(),
navbarPage("OSD",
tabPanel("Multi",
sidebarLayout(
sidebarPanel(
selectInput("select_size", "Select plot number", choices=c("1","2","3"))
),
mainPanel(
tags$h3("This is ok"),
plotOutput("plot", width = "auto", height = "auto")
)
)
)
)
)
server <- function(input, output, session) {
size <- reactive({
switch(input$select_size,
"1" = list(height = 300, width = 300),
"2" = list(height = 500, width = 500),
"3" = list(height = 800, width = 1200),
list(height = 300, width = 300)
)
})
output$plot <- renderPlot({
plot(cars)
},
height = function() { size()$height },
width = function() { size()$width }
)
}
shinyApp(ui, server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment