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

Commit

Permalink
global_cor_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 3a81ef2 commit c8da6c4
Showing 1 changed file with 31 additions and 17 deletions.
48 changes: 31 additions & 17 deletions R/global_cor_heatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ global_cor_heatmap <- function(input, output, session, data, types, plot.method
}

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

# reset ui
shiny::observeEvent(input$reset, {
shinyjs::reset("calc")
Expand All @@ -233,6 +236,7 @@ global_cor_heatmap <- function(input, output, session, data, types, plot.method
columns <<- shiny::callModule(columnSelector, "select", type.columns = types, columnTypeLabel = "Column types to choose from")
transform <<- shiny::callModule(transformation, "transform", data = shiny::reactive(as.matrix(data_r()[, columns$selectedColumns(), with = FALSE])))
colorPicker <<- shiny::callModule(colorPicker2, "color", distribution = shiny::reactive(tolower(input$distribution)), winsorize = shiny::reactive(equalize(result_data()[, -1])))
clearPlot(TRUE)
})

# warning if plot size exceeds limits
Expand Down Expand Up @@ -311,6 +315,8 @@ global_cor_heatmap <- function(input, output, session, data, types, plot.method
plot <- shiny::eventReactive(input$plot, {
# enable downloadButton
shinyjs::enable("download")
# show plot
clearPlot(FALSE)

# progress indicator
progress <- shiny::Progress$new()
Expand Down Expand Up @@ -365,34 +371,42 @@ global_cor_heatmap <- function(input, output, session, data, types, plot.method
width = shiny::reactive(plot()$width * (plot()$ppi / 2.54)),
height = shiny::reactive(plot()$height * (plot()$ppi / 2.54)),
{
if(clearPlot()) {
return()
} else {
# progress indicator
progress <- shiny::Progress$new()
on.exit(progress$close())
progress$set(0.2, message = "Rendering plot")

# get plot
plot <- plot()$plot

# update progress indicator
progress$set(1)

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

# get plot
plot <- plot()$plot

# update progress indicator
progress$set(1)

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

plot <- plot()$plot

# update progress indicator
progress$set(1)

return(plot)
})
}

Expand Down

0 comments on commit c8da6c4

Please sign in to comment.