Last active
April 20, 2016 18:34
-
-
Save fbreitwieser/c08710f1a4a13aab34d54e1609a8516f to your computer and use it in GitHub Desktop.
Example demonstrating dynamic resizing of d3heatmap uing renderUI
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) | |
ui <- fluidPage( | |
sidebarLayout( | |
sidebarPanel( | |
sliderInput("obs", "Number of rows:", min = 10, max = 100, value = 50) | |
), | |
mainPanel(uiOutput("hm_o")) | |
) | |
) | |
server <- function(input, output) { | |
output$hm_o <- renderUI({ | |
d3heatmap::d3heatmapOutput('hm',width="50%", height=paste0(50+input$obs*10,"px")) | |
}) | |
output$hm <- renderD3heatmap({ | |
dat <- matrix(rnorm(input$obs*4),ncol=4) | |
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