diff --git a/holoviews/tests/plotting/bokeh/test_plot.py b/holoviews/tests/plotting/bokeh/test_plot.py index 18bc2941d7..7be351249c 100644 --- a/holoviews/tests/plotting/bokeh/test_plot.py +++ b/holoviews/tests/plotting/bokeh/test_plot.py @@ -1,3 +1,4 @@ +import numpy as np import pyviz_comms as comms from param import concrete_descendents @@ -5,12 +6,14 @@ from holoviews.core.element import Element from holoviews.core.options import Store from holoviews.element.comparison import ComparisonTestCase +from holoviews import Curve from bokeh.models import ( - ColumnDataSource, LinearColorMapper, LogColorMapper, HoverTool + ColumnDataSource, CustomJS, LinearColorMapper, LogColorMapper, HoverTool ) from holoviews.plotting.bokeh.callbacks import Callback from holoviews.plotting.bokeh.element import ElementPlot + bokeh_renderer = Store.renderers['bokeh'] from .. import option_intersections @@ -76,3 +79,21 @@ def _test_hover_info(self, element, tooltips, line_policy='nearest', formatters= print(renderers, hover) for renderer in renderers: self.assertTrue(any(renderer in h.renderers for h in hover)) + + +def test_sync_legends(): + curve = lambda i: Curve(np.arange(10) * i, label="ABC"[i]) + plot1 = curve(0) * curve(1) + plot2 = curve(0) * curve(1) * curve(2) + combined_plot = plot1 + plot2 + + grid_bkplot = bokeh_renderer.get_plot(combined_plot).handles["plot"] + for p, *_ in grid_bkplot.children: + for r in p.renderers: + if r.name == "C": + assert r.js_property_callbacks == {} + else: + k, v = next(iter(r.js_property_callbacks.items())) + assert k == "change:muted" + assert isinstance(v[0], CustomJS) + assert v[0].code == "dst.muted = src.muted"