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

Ensure updates to the bokeh visible style property are applied #5063

Merged
merged 2 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions holoviews/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import param

# Python 2 builtins
basestring = str
long = int
unicode = str
cmp = lambda a, b: (a>b)-(a<b)
Expand Down
2 changes: 2 additions & 0 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,8 @@ def _update_glyphs(self, element, ranges, style):
if glyph:
properties = self._glyph_properties(plot, element, source, ranges, style)
renderer = self.handles.get('glyph_renderer')
if 'visible' in style and hasattr(renderer, 'visible'):
renderer.visible = style['visible']
with abbreviated_exception():
self._update_glyph(renderer, properties, mapping, glyph, source, data)
elif not self.static_source:
Expand Down
12 changes: 12 additions & 0 deletions holoviews/tests/plotting/bokeh/test_elementplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from ...utils import LoggingComparisonTestCase

try:
import panel as pn

from bokeh.document import Document
from bokeh.models import tools
from bokeh.models import (FuncTickFormatter, PrintfTickFormatter,
Expand Down Expand Up @@ -185,6 +187,16 @@ def hook(plot, element):
plot = bokeh_renderer.get_plot(curve)
self.assertEqual(plot.state.title.text, 'Called')

def test_element_update_visible(self):
checkbox = pn.widgets.Checkbox(value=True)
scatter = Scatter([]).apply.opts(visible=checkbox)
plot = bokeh_renderer.get_plot(scatter)
assert plot.handles['glyph_renderer'].visible
checkbox.value = False
assert not plot.handles['glyph_renderer'].visible
checkbox.value = True
assert plot.handles['glyph_renderer'].visible

def test_element_xformatter_string(self):
curve = Curve(range(10)).options(xformatter='%d')
plot = bokeh_renderer.get_plot(curve)
Expand Down