Last active
April 20, 2016 18:34
-
-
Save fbreitwieser/6acfc5c138c7f394d579302251169d10 to your computer and use it in GitHub Desktop.
Example demonstrating dynamic resizing of d3heatmap using renderUI inside shinydashboard
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(d3heatmap) | |
library(shinydashboard) | |
ui <- dashboardPage( | |
dashboardHeader(title="resizing d3heatmap"), | |
dashboardSidebar( | |
sliderInput("obs", "Number of rows:", min = 10, max = 100, value = 50) | |
), | |
dashboardBody( | |
tabBox( | |
tabPanel("Heatmap",uiOutput("hm_o")), | |
tabPanel("Data",verbatimTextOutput("dat_print")) | |
) | |
) | |
) | |
server <- function(input, output) { | |
dat <- reactive({ matrix(rnorm(input$obs*4),ncol=4) }) | |
output$dat_print <- renderPrint({ dat() }) | |
output$hm_o <- renderUI({ | |
d3heatmap::d3heatmapOutput('hm',width="50%", height=paste0(50+input$obs*10,"px")) | |
}) | |
output$hm <- renderD3heatmap({ | |
d3heatmap(dat(), Colv=FALSE, | |
colors=colorRampPalette(c("blue", "white", "red"))(100)) | |
}) | |
} | |
shinyApp(ui = ui, server = server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment