Using One Figure to Interact with Another

I have two figures, fig1(source=pref_ds=Prefecture map) and fig(source=subpref_ds=Sub Prefecture Map)
When I click on a Prefecture, I want to change the range of the sub-Prefecture plot.

The range changes (I can tell because I am printing subpref_fig.x_range.start both before and after changing and I can see the changes in the console.
However, the figure doesn’t update no matter what I try.
Oddly enough when I add code that is wrong like subpref_fig.emit(“change”) (TypeError subpref_fig.emit is not a function), the figure updates as expected!

So obviously I want the figure to actually update without throwing errors. How do I do this?

def createTapTool(pref_patch_renderer, pref_ds, subpref_ds, subpref_fig):
    tap_tool = TapTool(renderers=[pref_patch_renderer])
    tap_tool.callback = CustomJS(
        args=dict(pref_ds = pref_ds, subpref_ds = subpref_ds, subpref_fig=subpref_fig,), 
        code="""
        
        const min_x = pref_ds.data['min_x'][index];
        const max_x = pref_ds.data['max_x'][index];
        const min_y = pref_ds.data['min_y'][index];
        const max_y = pref_ds.data['max_y'][index];
        
        console.log("Selected min(x,y): ", min_x, ",", min_y);
        console.log("Selected max(x,y): ", max_x, ",", max_y);
        console.log("Start: ", subpref_fig.x_range.start);
        
        // Update subpref plot range
        subpref_fig.x_range.start = min_x;
        subpref_fig.x_range.end = max_x;
        subpref_fig.y_range.start = min_y;
        subpref_fig.y_range.end = max_y;
        
        console.log("Start: ", subpref_fig.x_range.start);
        //What should I put here?!

        //More code below..

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