By default bokeh plots offer a direct png export without any additional dependencies.
However for the export_png or get_screenshot_as_png function a selenium + ChromeDriver dependency is required.
I am wondering if that can be avoided because the JS code for the direct png export is basically already available. In other words I’d like to use the get_screenshot_as_png functionality without the additional depencencies.
I probably wasn’t really precise what I actually need. The browser is still available in my case and I’d like to transfer the png image back to Python from the JS part for further processing (embedding png images into pdf/powerpoints, etc.).
Oh I see. That should be technically possible, but there are no APIs built-in to Bokeh to make it happen. An very rough toutline of what you might do:
- Use a
CustomJS callback to locate the canvas DOM element and call
toBlob to get its data
- Use a CDS (or
DataModel) as a dd to synchronize canvas binary data back to Python