Changing the layout in CustomJS callback for a network graph

Hello everyone,

I have a network graph with filters that use CustomJS callbacks. When filtering I would like to change the layout of the nodes in the callback.
For my graph I use networkx and the spring_layout.
Once filtered, I would like to rearrange the individual nodes by initializing them in the callback with a new layout. For example with a planar_layout.
Is this possible?

Is it possible to call an external Python script in the callback (For example with Ajax)? So I could change the layout in this script and return it to the callback.

Thank you

I won’t say this is impossible, but I’ve never done that (so can’t offer any concrete advice) or seen anyone else do that, either. This use-case, executing real Python code in callbacks, is pretty much the main motivating reason the Bokeh server exists. Any solution along what you describe is just going to be a partial, untested, reimplementation of the Bokeh server. I think you’d be better either using the Bokeh server, or finding a JavaScript library you can adapt to use in a CustomJS

Thanks for the reply.

Unfortunately I can’t use the bokeh server in my case.
Did you have any suggestions for a JavaScript library? If I find a solution I will post it here.

I am afraid I don’t. It looks like there is a list of several with some comparisons here:

1 Like

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