Ensure rangesupdate event fires on all plots with linked axes
@@ -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:
