CustomJS callbacks

Hello @AlZ11, your code is relatively long, so the chance that a community member takes time to go through it is rather low.
I encourage you to reduce your code to the smallest possible portion of code that reproduces your problem, in a form that can be easily run by the reader, see MRE.

At the same time, I recommend to start from a JavaScript callback example from the documentation (JavaScript callbacks — Bokeh 2.4.2 Documentation) and progressively modify it to match your needs.
This will take you some time but if you proceed this way, the probability is high that you find the problem yourself.