Giter VIP home page Giter VIP logo

Comments (11)

juba avatar juba commented on August 25, 2024 1

PNG export would indeed be really useful, but it is much harder to implement than SVG export, because you need a complete HTML renderer (such as a browser) to convert to a bitmap image file.

Maybe I'll try to see how other libraries implement this.

from pyobsplot.

harrylojames avatar harrylojames commented on August 25, 2024 1

Observable use this. Happy to try adding a function to pyobsplot-js if you think that would make sense

from pyobsplot.

juba avatar juba commented on August 25, 2024

Oh I didn't know about this, it seems really promising ! Where did you see that Observable uses it ?

If you want to try to integrate it in pyobsplot, of course don't hesitate. Maybe the difficulty will be to make it work in both the jsdom and widget renderers, but it is definitely worth a try.

from pyobsplot.

harrylojames avatar harrylojames commented on August 25, 2024

Great - I'll give that a go. It was mentioned in a discussion here.

from pyobsplot.

harrylojames avatar harrylojames commented on August 25, 2024

This was unfortunately the case for html-to-image "but it is much harder to implement than SVG export, because you need a complete HTML renderer (such as a browser) to convert to a bitmap image file.". In Observable notebooks the figure has already been rendered in the browser so export to png via html-to-image is possible.

I've had a look at what other visualisation libraries do and they all appear to take a similar approach as described here. A simple approach that worked but proved limited was using the python package html2image. The issue I had was getting the correct width and height. If the html just contains an SVG tag then there's no issue we can grab the width and height attributes. However, if there is a title/legend/caption etc. then the height will be too small.

Bokeh has an implementation to dynamically get the width and height which we could try and borrow when the figure is a HTML object (export_to_png and dynamically estimate width & height )?

Not ideal, there would also need to be an additional docs section similar to this.

Let me know what you think

from pyobsplot.

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.