Skip to content
Advertisement

Bokeh Networkx graph slider not updating correctly

Here is a minimal working example for the problem I am facing:

I am building a simple graph with Networkx and then displaying it with Bokeh, adding a slider to show only the edges whose weight is greater than the slider value. Unfortunately, this works perfectly when the value increases, i.e., the slider moves to the right, whereas it stops working (some edges reappear, but then, when clicking on the graph, everything blows up) when the slider value decreases. In the customJS callback function I am modifying the edge data, and also when printing to the console every part of it, they work as expected, but in browser console I get a Shape Mismatch error, even if it is not specified what two shapes are being compared.

JavaScript

image of the networkx graph and the slider

Advertisement

Answer

I found out that this is actually due to a bug: https://discourse.bokeh.org/t/dynamic-layout-behavior-changes-between-bokeh-2-2-3-and-bokeh-2-3-0/7594

To solve this until the bokeh library is not updated (I am using version 2.4.0) I modified the customJS code to add placeholder data to match the initial datasource dimension:

JavaScript
Advertisement