Hi All,
I have written a shiny application which has Plotly bar plot as UI output. How can i add a download button in tooltip to download data required for plotting the chart?
Hi All,
I have written a shiny application which has Plotly bar plot as UI output. How can i add a download button in tooltip to download data required for plotting the chart?
Can you elaborate on how specifically this could/should work? Regardless, it probably won't be very straightforward to do this via a tooltip. It would be easiest (and most accessible) to do this via an actual button:
library(shiny)
ui <- fluidPage(
downloadButton("download"),
plotlyOutput("p")
)
server <- function(input, output, session) {
data <- reactive(mtcars)
output$p <- renderPlotly({
plot_ly(data(), x = ~wt, y = ~mpg)
})
output$download <- downloadHandler(
filename = "data.csv",
content = function(file) {
readr::write_csv(data(), file)
}
)
}
shinyApp(ui, server)
Another option would be to add a custom download icon in plotly's modebar, but again, it won't be super straightforward and will require some JavaScript+SVG knowledge -- 26 Control the modebar | Interactive web-based data visualization with R, plotly, and shiny
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.