I have a plotly graph, and would like to download the data.
- Option 1 is a download button outside the graph to a data object (e.g CSV, or a table). For example
Download output file csv. It works, but not that neat.
Options 2 and 3 use a custom modebar button.
plotly book - custom modebar button has a nice example with code to make the custom button.
-
Option 2, is a download button (eg csv) as a plotly custom modebar button. Presumably this would be done in javascript and passed through, similar to example below in option 3? Suggestions for how to do this?
-
Option 3 is a button that links to a table (possibly an appendix or other website with a datatable object), where that datatable has a download button. The download button for datatable is easy (see here). The javascript code for a website link should look something like this (javascript link to website)
Am I missing something simple in this code?
#devtools::install_github('cpsievert/plotly_book') #for octocat image
library(tidyverse)
library(DT)
library(plotly)
data(octocat_svg_path, package = "plotlyBook")
octocat <- list(
name = "octocat",
icon = list(
path = octocat_svg_path,
transform = 'matrix(1 0 0 1 -2 -2) scale(0.7)'
),
click = htmlwidgets::JS(
"function(gd) {window.location.href = 'http://www.google.com';
}"
)
)
plot_ly() %>%
config(modeBarButtonsToAdd = list(octocat))
*edited to include code for making octocat image available