Created
May 26, 2016 16:31
-
-
Save charlesmilk/4394e80e899444fa9c011443d0bf982e 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( | |
uiOutput("mplots") | |
) | |
) | |
) | |
) | |
) | |
server <- function(input, output, session) { | |
output$plot1 <- renderPlot({ | |
plot(cars) | |
}, height = 300, width = 300) | |
output$plot2 <- renderPlot({ | |
plot(cars) | |
}, height = 500, width = 500) | |
output$plot3 <- renderPlot({ | |
plot(cars) | |
}, height = 800, width = 1200) | |
output$mplots <- renderUI({ | |
if(input$select_size=="1"){ | |
list( | |
tags$h3("This is ok"), | |
plotOutput("plot1") | |
) | |
}else if(input$select_size=="2"){ | |
list( | |
tags$h3("This is also ok"), | |
plotOutput("plot2") | |
) | |
}else if(input$select_size=="3"){ | |
list( | |
tags$h3("This is not ok"), | |
tags$p("Imagine that this is a heatmap. They are big, from that follows the need to generate the plot in this way"), | |
plotOutput("plot3") | |
) | |
} | |
}) | |
} | |
shinyApp(ui, server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment