Y-ticks/y-range error while changing from 2-dimensional x_range-factors to 1-dimensional

Hello!

I need your help once again :slight_smile:

There’s some strange behaviour of y-ticks while changing from 2-dimensional x_range-factors to 1-dimensional.
The code is here - from bokeh.io import showfrom bokeh.layouts import column, rowfrom bokeh.mod - Pastebin.com.

It works good when you click the 1st button (1d-factors) and then the 2nd one (2d-factors), but if you click on the 1st button again, you’ll see that y-ticks dissappeared and in console.log there error “TypeError: t is undefined” will appear, on the next iteration you’ll see an additional error.
This can be seen here - https://gifyu.com/image/dJuG.

Could you help me please with that?
Thank you!

It’s a bug, I’ve reported it: [BUG] Impossible to change FactorRange to a lower dimension with different number of factors · Issue #9879 · bokeh/bokeh · GitHub

As a workaround, you can try swapping full instances of FactorRange instead of changing one in place. I didn’t test it though.

I’ve already tried doing it this way, but I guess I’m missing something.

My code:

And the error I have - https://imgur.com/a/c5wtyZh

Could you look into it please?

Replace lines like fig.x_range.factors = new FactorRange(...); with fix.x_range = new FactorRange(...).
Well, the exception is gone with that change, but now the plot is just empty, except for the top left corner. Judging by the Bokeh code, it doesn’t want you to change the ranges at all. You might as well recreate the whole plot then.

Maybe it would be cheaper to have 2 completely overlapped figures (one with 1d-range and the 2nd with 2d-range) and hide/show them when it’s neccessary.

Thank you very much!