Skip to content

Commit

Permalink
Ensure rangesupdate event fires on all plots with linked axes (#5465)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Oct 4, 2022
1 parent 4b6aacf commit 3e5ea6c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions holoviews/plotting/bokeh/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,25 @@ class RangeXYCallback(Callback):
'y1': 'cb_obj.y1'
}

_js_on_event = """
const plot = this.origin
const plots = plot.x_range.plots.concat(plot.y_range.plots)
const updated = [plot]
for (const p of plots) {
if (updated.indexOf(p) >= 0 || p.tags.indexOf('ranges-updating') >= 0)
continue
p.tags.push('ranges-updating')
const event = new this.constructor(p.x_range.start, p.x_range.end, p.y_range.start, p.y_range.end)
p.trigger_event(event)
p.tags = p.tags.filter(x => x !== 'ranges-updating')
updated.push(p)
}
"""

def set_callback(self, handle):
super().set_callback(handle)
handle.js_on_event('rangesupdate', CustomJS(code=self._js_on_event))

def _process_msg(self, msg):
data = {}
if 'x0' in msg and 'x1' in msg:
Expand Down

0 comments on commit 3e5ea6c

Please sign in to comment.