-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Download data button #2171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@jackparmer @chriddyp @alexcjohnson what do you think, is this within the scope of plotly.js? |
I'm tempted to say we could add this if/when we create separate data and trace definitions, but the way plotly.js works at present this would be tricky and a bit ambiguous. Also note that plotly cloud does this already - I realize that this is a few extra steps and not possible in all cases, but I bring it up because a) it may be useful in some cases, and b) knowing what went into its system for splitting the data out makes me more hesitant to build this into plotly.js. |
As a first step, we could add an optional button that dumps the JSON representation of the plot to a file. This would be easy to implement since there's already a "save and edit this plot in the cloud" button (which many of us can't use). |
+1 @amellnik What do you think of having the JSON show as indented plaintext within the plot view, that you could copy/paste, instead of downloading to file (or maybe buttons at the top of this plaintext view to download JSON or CSV)? I'd love to be able to quickly inspect the JSON in a JS or embedded graph without being required to download a file. |
I think even with missing data or obscure src tags this would still be useful for quickly inspecting how the plot was constructed. |
Is this really necessary? Typing something like var gd = document.getElementById('graph')
gd.data // => [{ /* ... */ }]
gd.layout // => { /* */ } in the console should be easy enough. |
I'm thinking more about non-JS users here. |
@jackparmer I would agree with that or even just to copy the serialized JSON to the clipboard. I also think this should be end-user friendly (and not require using any js). |
Oh sorry, my #2171 (comment) should have said: Is this really necessary in plotly.js proper? |
Hi, any updates on this issue? It'd really make my life easier since right now I add a download button at the end of all my dashboards but still not the most ideal/user_friendly... |
@dfernan no updates. We're still debating (albeit not very intensively during the holidays 😉 ) whether this request has its place in the library. |
yes of course, makes sense, please enjoy the holidays :-) |
Please do u.u |
Hi guys, is there any update on if this is planned to be done or not? would be a big help. thank you! |
In the meanwhile, here is a function I use that provides this feature. I hope it's helpful: modeBarButtonsToAdd: [{ name: 'downloadCsv', title: 'Download data as csv', icon: Plotly.Icons.disk, click: function(){ |
@RichardNeill I'd love to use your code. I've copied it in, but am getting an undefined on numSeries. Is that what you call your rows? |
yes, that's right. I've just quoted the code as I used it. Essentially, csvData[] needs to be a 2D array of arrays, generated from your data as you use it, with a header row if you want one. The way to do this is:
there is also an error in the above: HTH |
For those that are interested, I've successfully added a data download button in R plotly/ggplotly. |
Is there a way to adapt this to Python? |
This issue has been tagged with A community PR for this feature would certainly be welcome, but our experience is deeper features like this are difficult to complete without the Plotly maintainers leading the effort. Sponsorship range: $5k-$10k What Sponsorship includes:
Please include the link to this issue when contacting us to discuss. |
Here is a function that provides this feature. It works for 1-x 1-y scatter
|
This will work, but there are a few possible gotchas if you are unlucky with quoted data, data that contains a quote itself, or data that is null. Once I've got the CSV data (and header) into a 2D array, I use:
You need to decide how you want to represent the four awkward types ("", null, true, false) in your CSV, should they occur. If you want null to be "NULL" rather than "", then change HTH :-) |
@alessandroblaco Is there a way to export a specific trace that is not hidden instead of the first trace? |
@alessandroblaco thank you! That example is definitely a fine addition to the javascript plotly docs. Are you familiar with |
Hi,
Would it be possible to add a download data button? Right now the default's option is a png image of the plot but I think it'd be very nice if one could also download the data inside the graph. Thus having a download data in graph button would be really cool.
It'd be a new button in here:
https://github.com/plotly/plotly.js/blob/2ba7bdf30d605794de42d560cab41ebbc8681d29/src/components/modebar/buttons.js
I am not familiar with JS so it's hard for me to make a pull request on this but I do think it'd be a great option.
The text was updated successfully, but these errors were encountered: