Client Side Callback

I’m trying to implement a callback on the extra x_ranges and y_ranges of a plot.
The plot was created client side in javascript.
The code for creating the plot looks like this:

 var error_plot = Bokeh.Plotting.figure({
            plot_width: 800,
            plot_height: 600,
            title: seriesM + ': ' + interval + ': ' + metric,
            tools: "pan,box_zoom,reset,save",
            toolbar_location: "below",
            sizing_mode:"stretch_both",
            y_axis_label: metric,
            x_axis_label: "Horizons",
        });

In python I can create the callback like this:

plot.extra_x_ranges['logo_x_range'].js_on_change("start",CustomJS(args=dict(plot=self.plot),code=callback))

I do not see .js_on_change in the javascript API, or anything that works equivalently.

Are there any online resources that demonstrate how to do this?

Any help would be appreciated.

Thanks in advance

I believe the best way to accomplish this would be

range.connect(range.properties.start.change, () => callback_func())

cc @mateusz

Thanks Bryan!

That was incredibly helpful.
Do you happen to know of any online resources/docs that outline this type of interaction with the Javascript API. I don’t see any on https://docs.bokeh.org/, but maybe I’m missing it.

Again, thanks so much!

Best
Sean Oughton

@seanoughton I am afraid there simply isn’t as much yet. In the very early days, BokehJS was purely a hidden implementation detail, so there were no public docs at all. Over time it’s become more user-facing, and here has been some material added here and there, but it is not nearly as highly developed as “Python Bokeh” is in the area of documentation. We would very much like to make BokehJS a first-class project in its own right, with excellent docs and examples, but are also currently resource-limited and could really use more people helping with that goal.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.