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

[FEATURE] add "template" to io.export_png #10300

Open
fstalm opened this issue Jul 14, 2020 · 2 comments
Open

[FEATURE] add "template" to io.export_png #10300

fstalm opened this issue Jul 14, 2020 · 2 comments

Comments

@fstalm
Copy link

fstalm commented Jul 14, 2020

Is your feature request related to a problem? Please describe.
For our use-case we need to be able to generate png files with io.export_png that look exactly like the interactive html. Currently this means that we can not make use of the very nice and extremely powerful 'template' functionality that io.save provides.

Describe the solution you'd like
It would be fantastic if the 'template' functionality could also be added to io.export_png

@fstalm fstalm changed the title [FEATURE] add "template" to io.export_png [FEATURE] add "template" to io.export_png label:Triage Jul 15, 2020
@fstalm fstalm changed the title [FEATURE] add "template" to io.export_png label:Triage [FEATURE] add "template" to io.export_png Jul 15, 2020
@bryevdv
Copy link
Member

bryevdv commented Jul 26, 2020

Tentatively marking as feature. Offhand it seems like it should not be too difficult, but some actual investigation will be needed. @fstalm Certainly if you are able to conduct some experiments on your own that may help speed up things.

@fstalm
Copy link
Author

fstalm commented Sep 7, 2020

@bryevdv Attached is a new export.py (sorry, I am not allowed to create a pull request it seems: "Permission to bokeh/bokeh.git denied"). This file essentially only declares 'template' as optional argument to export_png and then hands it down the chain to get_screenshot_as_png and then to get_layout_html.

The optional template is added to template string that get_layout_html is creating: + str(template or ''). This latter bit probably will have to be modified so that it also handles jinja2 templates and not only strings. Maybe somebody with such expertise could have a look.

Passing for example
template="{% block postamble %} <style>.bk-root .bk-tabs-header .bk-tab { padding-top: 12px; padding-bottom: 12px; padding-left: 24px; padding-right: 24px; } </style> {% endblock %}"
as template to export_png now will draw larger Tabs and produce a png file that is a copy of the html file created with save(...,template=template).

export.py.zip

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

No branches or pull requests

2 participants