Skip to content

Commit

Permalink
Hold rendering until a plot has been fully updated (#6265)
Browse files Browse the repository at this point in the history
Co-authored-by: Simon Høxbro Hansen <[email protected]>
  • Loading branch information
philippjfr and hoxbro authored Jun 6, 2024
1 parent e87f38c commit bfadd80
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
get_ticker_axis_props,
glyph_order,
hold_policy,
hold_render,
match_ax_type,
match_dim_specs,
match_yaxis_type_to_range,
Expand Down Expand Up @@ -2228,6 +2229,7 @@ def _reset_ranges(self):
if isinstance(s, RangeXY) and not s._triggering:
s.reset()

@hold_render
def update_frame(self, key, ranges=None, plot=None, element=None):
"""
Updates an existing plot with data corresponding
Expand Down Expand Up @@ -3379,6 +3381,7 @@ def initialize_plot(self, ranges=None, plot=None, plots=None):

return self.handles['plot']

@hold_render
def update_frame(self, key, ranges=None, element=None):
"""
Update the internal state of the Plot to represent the given
Expand Down
15 changes: 15 additions & 0 deletions holoviews/plotting/bokeh/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,21 @@ def wrapper(self, *args, **kwargs):
return wrapper


def hold_render(f):
"""
Decorator that will hold render on a Bokeh ElementPlot until after
the method has been called.
"""
def wrapper(self, *args, **kwargs):
hold = self.state.hold_render
self.state.hold_render = True
try:
return f(self, *args, **kwargs)
finally:
self.state.hold_render = hold
return wrapper


def categorize_array(array, dim):
"""
Uses a Dimension instance to convert an array of values to categorical
Expand Down

0 comments on commit bfadd80

Please sign in to comment.