Hi,
I have constructed below code from the previous questions asked in community.
I want to have a download option for the chart that I dynamically generate as HTMLWidgets.widget.
Unfortunately, I get a blank "chart.png" in the download.
Please help!
# ui.R
# --------------------------------------------------------
ui <- shinyUI(fluidPage(
title = 'Basic usage of D3Table in Shiny',
fluidRow(column(width = 12, downloadButton("downloadData", "Download"))),
fluidRow(column(width = 12, D3TableOutput('test'))
)
))
# server.R
# --------------------------------------------------------
server <- shinyServer(function(input, output, session) {
tbl <- readr::read_tsv("data.tsv")
table_1 <- D3Table(data = tbl);
gt <- renderD3Table({table_1})
output$test <- gt
output$downloadData <- downloadHandler(
filename = "chart.png",
content = function(file) {
saveWidget(table_1, "temp.html", selfcontained = TRUE)
webshot::webshot(url = "temp.html", file = file)
}
)
})