From e6a54d96c2009a104b1f10d32cb13f2ec04fd217 Mon Sep 17 00:00:00 2001 From: Kumi Date: Mon, 22 Feb 2021 20:10:37 +0100 Subject: [PATCH] Fix Bokeh output Lock Y axis of Bokeh HTML output --- common/templatetags/images.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/common/templatetags/images.py b/common/templatetags/images.py index 51d57a1..eaa72a1 100644 --- a/common/templatetags/images.py +++ b/common/templatetags/images.py @@ -4,6 +4,10 @@ from io import BytesIO import holoviews as hv +from bokeh.embed import file_html +from bokeh.resources import INLINE +from bokeh.models.tools import PanTool, WheelZoomTool + import base64 register = template.Library() @@ -17,9 +21,15 @@ def pildata(image): @register.simple_tag def hvhtml(hvobject): - renderer = hv.renderer('bokeh') - html = renderer.html(hvobject, resources="inline") + bokeh = hv.render(hvobject) + pan_tool = bokeh.select(dict(type=PanTool)) + pan_tool.dimensions = "width" + + zoom_tool = bokeh.select(dict(type=WheelZoomTool)) + zoom_tool.dimensions = "width" + + html = file_html(bokeh, INLINE) html = html.replace("http://localhost:5006/static/extensions/panel/css", "/static/frontend/vendor/panel") return html