#' downloadImage UI Function
#'
#' @description A shiny Module.
#'
#' @param id,input,output,session Internal parameters for {shiny}.
#'
#' @noRd
#'
#' @importFrom shiny NS tagList
mod_downloadImage_ui <- function(id){
ns <- NS(id)
tagList(
downloadButton(ns("downloadPlot"), "Download the plot"))
}
#' downloadImage Server Function
#'
#' @noRd
mod_downloadImage_server <- function(input, output, session, treePlotOut){
ns <- session$ns
#
output$downloadPlot <- downloadHandler(
filename = function() {
paste("data-", Sys.Date(), ".png", sep="")
},
content = function(file) {
ggplot2::ggsave(file, plot = treePlotOut(), device = "png")
}
)
}
## To be copied in the UI
# mod_downloadImage_ui("downloadImage_ui_1")
## To be copied in the server
# callModule(mod_downloadImage_server, "downloadImage_ui_1")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.