How to update data of contour in CustomJS fun?

Hi @swpper1 While it is technically possible, in principle, to update a contour glyph from a CustomJS, in practice it is really not possible in any reasonable way. That is because, unlike many other things in Bokeh, the work is not done on the JavaScript side. Bokeh uses the contourpy library, which is actually a Python binding for a C++ library, to do the actual contour computations. So, it’s fairly straightforward to update Bokeh contour plots from Python (and there is an example that demonstrates this), but in order to update from JS the only options would be:

  • Compute new contour data manually in JavaScript. You would need to find or write a JavaScript contouring algorithm (e.g. “marching squares”) yourself, to use inside the CustomJS
  • Pre-compute all possible contour data for every contour level you expect to need up front in Python, and ship all that hard-coded data inside the CustomJS to switch between (probably expensive in terms of data size).

cc @Ian_Thomas to comment on any future possibilities, such as possibly adding a contouring algorithm directly to BokehJS (and to correct anything I got wrong above).

1 Like