Figure after JS callback does not update

Hey all,

I would like to change the canvas size of a whole figure. That is done interactively with a slider widget which sets correctly the ‘plot_width’ property of the figure as I can verify with ‘console.log()’, but the figure does not update. I am sure I have to emit the change in some way like ‘source.change.emit()’ when I change the source in js.

JS Part is like that:

if ( === 'canvas_x') {
    cx = canvas_x_w.value;
    p.plot_width = cx;
     // p.emit(); --> not working  
     // p.source.emit();  --> not working

Can s.o. give an advice?
How can I find out by myself what I have to ‘emit’ to trigger a change of a property in JS in general?


1 Like

p.source.emit is not meaningful in this context. Plots don’t have a source property, and also the layout is not connected to the contents of data sources in any way, in any case. This is not something I can recall anyone having asked for, but it turns out there are some complications due to historical development. (i.e. plot_width probably would have been better if it were width to match the general pattern, but it has always been plot_width and is too late to change now). In any event the upshot is that just setting the property, which is normally all that is necessary, is not sufficient in this particular case.

The following code works for me on Bokeh 1.2:

b = Button()
b.js_on_click(CustomJS(args=dict(p=p), code="""
    p.plot_width = 400