Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
heatmap: clear plot on reset
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikSchultheis committed Jan 12, 2018
1 parent 9f71cb8 commit 3a81ef2
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions R/heatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ heatmap <- function(input, output, session, data, types, plot.method = "static",
}
})

#reset ui
# clear plot
clearPlot <- shiny::reactiveVal(FALSE)

# reset ui
shiny::observeEvent(input$reset, {
shinyjs::reset("cluster.distance")
shinyjs::reset("cluster.method")
Expand All @@ -223,6 +226,7 @@ heatmap <- function(input, output, session, data, types, plot.method = "static",
if(!is.null(custom.row.label)) {
custom_label <<- shiny::callModule(label, "labeller", data = custom.row.label, label = "Select row label", sep = label.sep, disable = shiny::reactive(!input$row.label))
}
clearPlot(TRUE)
})

columns <- shiny::callModule(columnSelector, "select", type.columns = types, columnTypeLabel = "Column types to choose from")
Expand Down Expand Up @@ -252,6 +256,7 @@ heatmap <- function(input, output, session, data, types, plot.method = "static",
plot <- shiny::eventReactive(input$plot, {
# enable downloadButton
shinyjs::enable("download")
clearPlot(FALSE)

#new progress indicator
progress <- shiny::Progress$new()
Expand Down Expand Up @@ -296,16 +301,20 @@ heatmap <- function(input, output, session, data, types, plot.method = "static",
})

output$interactive <- plotly::renderPlotly({
#new progress indicator
progress <- shiny::Progress$new()
on.exit(progress$close())
progress$set(0.2, message = "Render plot")
if(clearPlot()) {
return()
} else {
#new progress indicator
progress <- shiny::Progress$new()
on.exit(progress$close())
progress$set(0.2, message = "Render plot")

plot <- plot()$plot
plot <- plot()$plot

progress$set(1)
progress$set(1)

return(plot)
return(plot)
}
})
}else{
output$heatmap <- shiny::renderUI({
Expand All @@ -316,15 +325,19 @@ heatmap <- function(input, output, session, data, types, plot.method = "static",
width = shiny::reactive(plot()$width * (plot()$ppi / 2.54)),
height = shiny::reactive(plot()$height * (plot()$ppi / 2.54)),
{
#new progress indicator
progress <- shiny::Progress$new()
on.exit(progress$close())
progress$set(0.2, message = "Render plot")
if(clearPlot()) {
return()
} else {
#new progress indicator
progress <- shiny::Progress$new()
on.exit(progress$close())
progress$set(0.2, message = "Render plot")

plot <- plot()$plot
plot <- plot()$plot

progress$set(1)
return(ComplexHeatmap::draw(plot, heatmap_legend_side = "bottom"))
progress$set(1)
return(ComplexHeatmap::draw(plot, heatmap_legend_side = "bottom"))
}
})
}

Expand Down

0 comments on commit 3a81ef2

Please sign in to comment.