Coder Social home page Coder Social logo

Comments (15)

timelyportfolio avatar timelyportfolio commented on May 6, 2024 1

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?

from plotly.js.

sglyon avatar sglyon commented on May 6, 2024

Ping, any update on this?

from plotly.js.

etpinard avatar etpinard commented on May 6, 2024

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.

from plotly.js.

etpinard avatar etpinard commented on May 6, 2024

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.

from plotly.js.

gramster avatar gramster commented on May 6, 2024

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)

from plotly.js.

sglyon avatar sglyon commented on May 6, 2024

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

from plotly.js.

gramster avatar gramster commented on May 6, 2024

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?

from plotly.js.

gramster avatar gramster commented on May 6, 2024

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

from plotly.js.

ifll avatar ifll commented on May 6, 2024

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.

from plotly.js.

etpinard avatar etpinard commented on May 6, 2024

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.

from plotly.js.

jackparmer avatar jackparmer commented on May 6, 2024

Related discussion: http://community.plot.ly/t/use-plotly-offline-to-save-chart-as-image-file/408/8

from plotly.js.

sglyon avatar sglyon commented on May 6, 2024

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.

from plotly.js.

etpinard avatar etpinard commented on May 6, 2024

@timelyportfolio have you made any progress on this one?

from plotly.js.

timelyportfolio avatar timelyportfolio commented on May 6, 2024

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

from plotly.js.

etpinard avatar etpinard commented on May 6, 2024

done in #446

from plotly.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.