Learn R Programming

rAmCharts (version 2.1.16)

rAmCharts-shinymodules: Shiny module to export rAmCharts graphics on server-side

Description

This function need the base64enc package to save image.

Usage

rAmChartsExportServerUI(id)

rAmChartsExportServer( input, output, session, list_am_graph, path = shiny::reactive(tempdir()), mode = "single", progress = T, message = "Calculation in progress", detail = "This may take a while..." )

Value

a reactive expression

Arguments

id

character, used to specify namesapce, see shiny::NS

input

standard, shiny input

output

standard, shiny output

session

standard, shiny session

list_am_graph

named list, reactive expression with all amCharts to export

  • "graph" rAmCharts object to export

  • "name" character, name of file, with ".jpg" extension

  • "width" Optionnal, character. Linked to amChartsOutput

  • "height" Optionnal, character. Linked to amChartsOutput

  • "type" Optionnal, character. Linked to amChartsOutput

path

character, directory. tempdir() by Defaut

mode

character, 'single' : graphics are rendered and saved one by one. 'multiple' all at same time

progress

boolean, set a progress bar or not ?

message

character, if progress, message. Defaut to "Calculation in progress"

detail

character, if progress, detail. Defaut to "This may take a while...'

Examples

Run this code

if (FALSE) {

# ui
rAmChartsExportServerUI("export_server_graphs")

# server

mult_amgraph <- reactive({
 if(input$goSave > 0){
   isolate({
     list(
       list(graph = amPie(data = data_pie), name = "pie.jpg", height = "200px", width = "300px"),
       list(graph = amBarplot(x = "country", y = "visits", data = data_bar, main = "example") %>%
         setExport(), name = "bar.jpg", height = "600px")
     )
   })
 } else {
   NULL
 }
})


callModule(rAmChartsExportServer, "export_server_graphs", mult_amgraph, 
          reactive("/home/benoit/amchart_export"))

}

Run the code above in your browser using DataLab