☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Update text in Label/widget with callback

Community Support
Peter-Metz
Peter-Metz

Hi Bokeh community,

I’m making a bar chart with two bars, the values of which are controlled by widgets/a callback. My goal is to create either a Label or a Div widget (or a different object that contains text) that updates with the values of the bar chart (i.e. "Bar 1: {Value 1}; Bar 2: {Value 2}). Any help would be appreciated!

⌁   Link to post
p-himik
p-himik

You can’t link labels or divs to a data source, but you can change their value in a JS callback:

from bokeh.layouts import column
from bokeh.models import Button, CustomJS, ColumnDataSource, Div
from bokeh.plotting import show

ds = ColumnDataSource(dict(value=[0]))

d = Div(text=f"Value: {ds.data['value'][0]}")

ds.js_on_change('data', CustomJS(args=dict(d=d),
                                 code="d.text = `Value: ${cb_obj.data['value'][0]}`;"))

b = Button(label="Increment")
b.js_on_click(CustomJS(args=dict(ds=ds),
                       code="ds.data['value'][0] += 1; ds.properties.data.change.emit();"))

show(column(d, b))
⌁   Link to post

End of archived discussion · Replies are disabled