Update figure

Hi Bokehers,

If have a couple of circles that I want to update the color (for my specific problem I have thousand of circles) .
Using Slider or TextInput it is quite easy:

plot = figure(plot_width = 300, plot_height = 300)
src=ColumnDataSource(dict(x=[1, 2, 3],y=[3, 7, 5],color=3*['blue']))
circ_slider = Slider(start=0, end=2, value=1, step=1)

plot.circle('x', 'y', size = 20, color = 'color', alpha = 0.6, source=src)
def thecallback(): 
    return  CustomJS(args=dict(source=src,circ=circ_slider),
    code="""
    const data = source.data;
    var col = data['color']
    var i = circ.value;
    for (let i = 0; i < col.length; i++) {
        col[i] = 'blue'
    }
    col[i] = 'red';
    source.change.emit();
""")

circ_slider.js_on_change('value', thecallback())
show(row(plot,circ_slider))

In order to make an animation I don’t want to use Slider, TextInput …
Is there a Bokeh Python command to inject some JS ?
The order of the circle color are depending from a parameter defined in a pandas DataFrame.

Thanks :pray:

PS:
I have posted the question on stack but I think It wasn’t clear

Is there some user action to start/stop the animation? e.g. click a button to toggle animation on or off? Or do you just want it animating immediately and continuously? If so, then I think you will have to wait for this issue t be complete for a clean solution:

There is an open WIP Pull Request already, so hopefully for 3.1 in a couple of months. The issue itself has various suggestions for workarounds from users, I am not sure how up to date / workable they are though, you’d just have to try them out.

1 Like

thanks for your answer … then I think I have to wait for the issue :smiling_face_with_tear:
cheers

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.