Hi,
Just in case an example is easy to understand the issue. I am referring to shinyJsTutorials/tutorials/materials2/C3_demo at master · FrissAnalytics/shinyJsTutorials · GitHub</titl
Lets say that I want to give the user an option to download one of the several widgets as image that are built in server.R
I added a download button in ui.R as below
fluidRow(column(width = 12, downloadButton("downloadData", "Download"))),
and now in server.R i want to have something like below.
There is a widget called C3StackedAreaChart. I want to fill the place for widget_to_be_saved in saveWidget of downloadHandler.
output$stackedAreaChart <- renderC3StackedAreaChart({
dataset <- data.frame(Time = Data()$Time,
GREEN = Data()$Perc$GREEN,
AMBER = Data()$Perc$AMBER,
RED = Data()$Perc$RED)
colors <- list(GREEN = "#2CA02C", AMBER = "#FF7F0E", RED = "Red")
C3StackedAreaChart(dataset,colors)
})
output$downloadData <- downloadHandler(
filename = "chart.png",
content = function(file) {
saveWidget(widget_to_be_saved, "temp.html", selfcontained = TRUE)
webshot2::webshot(url = "temp.html", file = file)
}
)
Or please guide me where am I wrong in my understanding of how it should be done.
Thanks in advance.