Skip to content
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

Snapshot routines should allow users to specify image width/height #83

Closed
etpinard opened this issue Dec 7, 2015 · 15 comments
Closed
Labels
feature something new

Comments

@etpinard
Copy link
Contributor

etpinard commented Dec 7, 2015

Motivated by #42 (comment)

At the moment, the Snapshot.toImage has hard-coded width and height parameters.

Something like:

Plotly.Snapshot.toImage(gd, {format: 'png', width: 1000, height: 800});

Moreover, maybe the on-success handler used by the modebar toImage button could be used as the default on-success handler to Snapshot.toImage

@etpinard etpinard added the feature something new label Dec 7, 2015
@etpinard etpinard changed the title Snapshot routines should allow uses to specify image width/height Snapshot routines should allow users to specify image width/height Dec 7, 2015
@sglyon
Copy link

sglyon commented Jan 26, 2016

Ping, any update on this?

@etpinard
Copy link
Contributor Author

We're still doing experiments with potential APIs. No serious work has gone into this to date.

That said, once we figure out how to expose things to the users, this should be a 2-day project.

@etpinard
Copy link
Contributor Author

Once we're comfortable with the API, we should expose the toImage on the Plotly directly.

Moreover, we'll need toImage to return a promise, like the other Plotly async methods.

@gramster
Copy link

gramster commented Feb 4, 2016

Is there a way to get raw PNG data from a plot snapshot? We would like to do this so that we can generate a PNG output in an IPython notebook so that when viewing the .ipynb file in Github or elsewhere where Javascript is not executed there is a static fallback version that gets displayed.

(and we need to do this in the Javascript code, not Python)

@sglyon
Copy link

sglyon commented Feb 4, 2016

You should be able to do Plotly.Snapshot.toImage(gd, {"format": "png"}), which will return a promise you then have to deal with resolving.

@gramster
Copy link

gramster commented Feb 5, 2016

Thanks. I don't see docs on Plotly promises. I tried this:

var idata;
Plotly.Snapshot.toImage(model.dom.id, {"format": "png"}).then(function(d) { idata=d; })

but I get:

Plotly.Snapshot.toImage(...).then is not a function(…)

toImage() is returning an EventEmitter.

What am I missing?

@gramster
Copy link

gramster commented Feb 5, 2016

Ah, I see. I need to use ...toImage(...).once('success', function(url) { ...})

@ifll
Copy link

ifll commented Feb 11, 2016

I think that for the user it would be really interesting to be able to choose the image size. But also it could be too much features on the plot and reduce simplicity...

I would suggest that the coder who is buiding the plot could choose if the users (the ones who will be watching the plot) are capable to change or not the PNG image from the plot.

To do so I would suggest to add inside the layout variable an option which involves the modebar, and where it could be such a variable like "snapshotsize" which could admit a vector including a fixed size: snapshotsize = [1000 1000] or either the auto option snapshotsize = "auto"

Regarding the "auto" functionality I would suggest that a dialog box appears on the plot allowing to choose the dimension of it. Somehow similar to the message box which appears when you click the snapshot button and it tells you that Taking snapshot - this may take a few seconds

With this implementation the current way that snapshots are being done right now can be kept (as the coder can decide the output size) but also the new feature of being able to choose the plot size can be implemented.

@etpinard
Copy link
Contributor Author

Unfortunately other obligations came up for the plotly.js team members and this issue will remain on hold until at least April 1.

Our apologies.

@jackparmer
Copy link
Contributor

@sglyon
Copy link

sglyon commented Apr 7, 2016

For what it is worth, in PlotlyJS.jl I can get true vector image pdf/eps/svg export as well as configurable png/jpeg exporting by getting the svg data from plotly, using librsvg to load that into cairo, and using cairo to render to the desired file type.

@etpinard
Copy link
Contributor Author

etpinard commented Apr 7, 2016

@timelyportfolio have you made any progress on this one?

@timelyportfolio
Copy link
Contributor

Yes, I just started working through this. Here is the very preliminary set of thoughts. By the end of the week, I hope to have a full plan to address this. Is that ok?

@timelyportfolio
Copy link
Contributor

timelyportfolio#1 (comment) is my first attempt, and it seems we now have both 2) promises and 3) resize. I would appreciate any thoughts.

@etpinard
Copy link
Contributor Author

done in #446

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

No branches or pull requests

6 participants