fbreitwieser
4/20/2016 - 6:11 PM

Example demonstrating dynamic resizing of d3heatmap uing renderUI

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)