How to change factor_cmap-factors in js-callback?


I would like to change fill_color.factors feature of vbar in a js-callback so that grouped bar was colored by groups [“0”, “1”].
My code:

I guess, “bar.glyph.fill_color.factors = ***” is not a correct way of doing it. All columns become gray if their x-values don’t correspond to default fill_color.factors with which vbar was created.

Haven’t checked the code yet, but at this point, given the previous discussion, I start to think that what you want may better be handled differently.
Have you considered just using tabs that each have their own factors? This way, you don’t have to switch any values - you just update what you have to, and the 1D or 2D factors can be selected by switching to different tabs.

The problem with switching from 2d to 1d is gone - I’ve created 2 separated figures and they subsititute each other if user wants to plot single-groupedby array or double-groupedby one.

So, 1st figure (and vbar/line) for 1d-factors.
2nd figure is for 2d-factors. And it works good. I want that different groups had their own colors to show. For example, here - - group “0” can have green color and group “1” must have red color. And I can do it if I set fill_color parameter to vbar like:
fill_color=factor_cmap(‘Column’, palette=[‘green’, ‘red’], factors=[“0”,“1”], start=1, end=2)
But I can’t be confident that there always will be [“0”, “1”] as the factors. I must change them according to the 2nd column (2nd grouped-by column) of data aggregated.

And I didn’t find any method how to change these vbar.glyph.fill_color.factors.

I should’ve provided a better example.
New one -