Can a CustomJS modify a bokeh layout (column, row, etc...)?

I’m trying to create a standalone report and add some kind of filtering/organization functionality, the report has a collection of figures/datatables assign to multiple column layouts. I tried implementing a CustomJS callback like the snippet below in order to change the children of a column layout. by inspecting the console, the change seems to take place however it is not rendered. Is something like this even possible? I don’t know what I’m missing.

Any help, pointers would be much appreciated.

cjs[i] = CustomJS(args=dict(column_layout=col[i], select=index, all_figures=figcol), code="""
// try to replace with appropiate figure?
column_layout.children[1] = all_figures.children[index]
""")

It should be, can you provide a complete toy example to test with?

Sure can, I have a more complete explanation of what I’m trying to achieve in this post:
(CustomJS callback to modify layout (organize report))

Thanks!

I missed that you were updating the list in place up above. I think mateusz answered in the other topic, but to have an answer here in both places: Bokeh can only automatically detect changes “inside” containters on the Python side.

Just to update on the solution of this thread. Per mateuz suggestion (on this thread CustomJS Callback), after modifying the callback

cjs[i] = CustomJS(args=dict(column_layout=col[i], select=index, all_figures=figcol), code="""
// Replace with appropriate figure
var children = [...column_layout.children]
children[1] = allfigs.children[index]
column_layout.children = children
""")

It now works as intended.

Thank you guys.

1 Like