Skip to content

Instantly share code, notes, and snippets.

@fbreitwieser
Last active April 20, 2016 18:34
Show Gist options
  • Save fbreitwieser/c08710f1a4a13aab34d54e1609a8516f to your computer and use it in GitHub Desktop.
Save fbreitwieser/c08710f1a4a13aab34d54e1609a8516f to your computer and use it in GitHub Desktop.
Example demonstrating dynamic resizing of d3heatmap uing renderUI
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