☰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

Why the plot did not update?

Community Support
Bryan
Bryan

@yvechang FYI I’ve deleted the link to the code because the file appeared to leak actual credentials and connection information.

I don’t see anything offhand wrong with the code, but it’s really impossible to know what the state of the database updates is. My suggestion is to start doing what I would do in this situation, which is to add lots of print/logging statements to verify that callbacks are executing when you want them to, that data base connections are actually successful, that in general the program state is what you expect it to. At some point, it won’t be, and that will point the way to what the immediate problem is.

⌁   Link to post
Bryan
Bryan

@yvechang This is the data update:

source.data = dict(x=xs, y=ys, color=colors, label=labels)

Those are the important values, but they are not being printed out in the code you linked earlier. Have you actually looked at those? What about any log or error messages, both in the app console log, and also in the browser’s JS console log?

As an aside, it looks like you are infinitely accumulating Label objects. This is a serious resource leak that will eventually adversely affect performance.

⌁   Link to post
yvechang
yvechang

I added a print statement after the for loop just now. The following is the output.
“”""""""""""""""""""""""""""""""""""""""""""""""""""""
Id= T000 state= 255 x= 0 y= 0
Id= T019 state= 119 x= 1 y= 0
Id= T020 state= 119 x= 2 y= 0
Id= T021 state= 254 x= 3 y= 0
Id= T022 state= 255 x= 4 y= 0
Id= T023 state= 119 x= 0 y= 1
Id= T024 state= 100 x= 1 y= 1
Id= T025 state= 119 x= 2 y= 1
Id= T026 state= 120 x= 3 y= 1
Id= T030 state= 255 x= 4 y= 1
Id= T031 state= 120 x= 0 y= 2
Id= T203 state= 254 x= 1 y= 2
Id= T204 state= 254 x= 2 y= 2
Id= T205 state= 255 x= 3 y= 2
Id= T210 state= 254 x= 4 y= 2
xs= [4, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4]
ys= [2, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]
colors= [’#ffff33’, ‘#e41a1c’, ‘#e41a1c’, ‘#ffff33’, ‘#4daf4a’, ‘#e41a1c’, ‘#a65628’, ‘#e41a1c’, ‘#a65628’, ‘#4daf4a’, ‘#a65628’, ‘#ffff33’, ‘#ffff33’, ‘#4daf4a’, ‘#ffff33’]
labels= [Label(id=‘2202’, …), Label(id=‘1003’, …), Label(id=‘1004’, …), Label(id=‘1005’, …), Label(id=‘1006’, …), Label(id=‘1007’, …), Label(id=‘1008’, …), Label(id=‘1009’, …), Label(id=‘1010’, …), Label(id=‘1011’, …), Label(id=‘1012’, …), Label(id=‘1013’, …), Label(id=‘1014’, …), Label(id=‘1015’, …), Label(id=‘1016’, …)]
“”""""""""""""""""""""""""""""""""""""""""""""""""""""

⌁   Link to post
yvechang
yvechang

The output above is just after an iteration. The following output was caught after I change the value of state form 0 to 119 in the record “Id= T023”. We can see that state value printed was changed. However, the 6th color didn’t be changed! The if statements seems not actually worked!
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’
Id= T000 state= 255 x= 0 y= 0
Id= T019 state= 119 x= 1 y= 0
Id= T020 state= 119 x= 2 y= 0
Id= T021 state= 254 x= 3 y= 0
Id= T022 state= 255 x= 4 y= 0
Id= T023 state= 119 x= 0 y= 1
Id= T024 state= 100 x= 1 y= 1
Id= T025 state= 119 x= 2 y= 1
Id= T026 state= 120 x= 3 y= 1
Id= T030 state= 255 x= 4 y= 1
Id= T031 state= 120 x= 0 y= 2
Id= T203 state= 254 x= 1 y= 2
Id= T204 state= 254 x= 2 y= 2
Id= T205 state= 255 x= 3 y= 2
Id= T210 state= 254 x= 4 y= 2
xs= [4, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4]
ys= [2, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]
colors= [’#ffff33’, ‘#e41a1c’, ‘#e41a1c’, ‘#ffff33’, ‘#4daf4a’, ‘#e41a1c’, ‘#a65628’, ‘#e41a1c’, ‘#a65628’, ‘#4daf4a’, ‘#a65628’, ‘#ffff33’, ‘#ffff33’, ‘#4daf4a’, ‘#ffff33’]
labels= [Label(id=‘1530’, …), Label(id=‘1003’, …), Label(id=‘1004’, …), Label(id=‘1005’, …), Label(id=‘1006’, …), Label(id=‘1007’, …), Label(id=‘1008’, …), Label(id=‘1009’, …), Label(id=‘1010’, …), Label(id=‘1011’, …), Label(id=‘1012’, …), Label(id=‘1013’, …), Label(id=‘1014’, …), Label(id=‘1015’, …), Label(id=‘1016’, …)]

‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’
Id= T000 state= 255 x= 0 y= 0
Id= T019 state= 119 x= 1 y= 0
Id= T020 state= 119 x= 2 y= 0
Id= T021 state= 254 x= 3 y= 0
Id= T022 state= 255 x= 4 y= 0
Id= T023 state= 0 x= 0 y= 1
Id= T024 state= 100 x= 1 y= 1
Id= T025 state= 119 x= 2 y= 1
Id= T026 state= 120 x= 3 y= 1
Id= T030 state= 255 x= 4 y= 1
Id= T031 state= 120 x= 0 y= 2
Id= T203 state= 254 x= 1 y= 2
Id= T204 state= 254 x= 2 y= 2
Id= T205 state= 255 x= 3 y= 2
Id= T210 state= 254 x= 4 y= 2
xs= [4, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4]
ys= [2, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]
colors= [’#ffff33’, ‘#e41a1c’, ‘#e41a1c’, ‘#ffff33’, ‘#4daf4a’, ‘#e41a1c’, ‘#a65628’, ‘#e41a1c’, ‘#a65628’, ‘#4daf4a’, ‘#a65628’, ‘#ffff33’, ‘#ffff33’, ‘#4daf4a’, ‘#ffff33’]
labels= [Label(id=‘1546’, …), Label(id=‘1003’, …), Label(id=‘1004’, …), Label(id=‘1005’, …), Label(id=‘1006’, …), Label(id=‘1007’, …), Label(id=‘1008’, …), Label(id=‘1009’, …), Label(id=‘1010’, …), Label(id=‘1011’, …), Label(id=‘1012’, …), Label(id=‘1013’, …), Label(id=‘1014’, …), Label(id=‘1015’, …), Label(id=‘1016’, …)]

⌁   Link to post
yvechang
yvechang

I am sorry for miss adding the statement “i = i + 1” in the end of the for loop. The following output is really the expected. We can see that the 6th state value and the 6th color were changed! But why did the plot still not changed?


Id= T000 state= 255 x= 0 y= 0
Id= T019 state= 119 x= 1 y= 0
Id= T020 state= 119 x= 2 y= 0
Id= T021 state= 254 x= 3 y= 0
Id= T022 state= 255 x= 4 y= 0
Id= T023 state= 0 x= 0 y= 1
Id= T024 state= 100 x= 1 y= 1
Id= T025 state= 0 x= 2 y= 1
Id= T026 state= 120 x= 3 y= 1
Id= T030 state= 255 x= 4 y= 1
Id= T031 state= 120 x= 0 y= 2
Id= T203 state= 254 x= 1 y= 2
Id= T204 state= 254 x= 2 y= 2
Id= T205 state= 255 x= 3 y= 2
Id= T210 state= 254 x= 4 y= 2
xs= [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4]
ys= [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]
colors= [’#4daf4a’, ‘#e41a1c’, ‘#e41a1c’, ‘#ffff33’, ‘#4daf4a’, ‘#a65628’, ‘#a65628’, ‘#a65628’, ‘#a65628’, ‘#4daf4a’, ‘#a65628’, ‘#ffff33’, ‘#ffff33’, ‘#4daf4a’, ‘#ffff33’]
labels= [Label(id=‘1404’, …), Label(id=‘1405’, …), Label(id=‘1406’, …), Label(id=‘1407’, …), Label(id=‘1408’, …), Label(id=‘1409’, …), Label(id=‘1410’, …), Label(id=‘1411’, …), Label(id=‘1412’, …), Label(id=‘1413’, …), Label(id=‘1414’, …), Label(id=‘1415’, …), Label(id=‘1416’, …), Label(id=‘1417’, …), Label(id=‘1418’, …)]
Id= T000 state= 255 x= 0 y= 0
Id= T019 state= 119 x= 1 y= 0
Id= T020 state= 119 x= 2 y= 0
Id= T021 state= 254 x= 3 y= 0
Id= T022 state= 255 x= 4 y= 0
Id= T023 state= 119 x= 0 y= 1
Id= T024 state= 100 x= 1 y= 1
Id= T025 state= 0 x= 2 y= 1
Id= T026 state= 120 x= 3 y= 1
Id= T030 state= 255 x= 4 y= 1
Id= T031 state= 120 x= 0 y= 2
Id= T203 state= 254 x= 1 y= 2
Id= T204 state= 254 x= 2 y= 2
Id= T205 state= 255 x= 3 y= 2
Id= T210 state= 254 x= 4 y= 2
xs= [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4]
ys= [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]
colors= [’#4daf4a’, ‘#e41a1c’, ‘#e41a1c’, ‘#ffff33’, ‘#4daf4a’, ‘#e41a1c’, ‘#a65628’, ‘#a65628’, ‘#a65628’, ‘#4daf4a’, ‘#a65628’, ‘#ffff33’, ‘#ffff33’, ‘#4daf4a’, ‘#ffff33’]
labels= [Label(id=‘1420’, …), Label(id=‘1421’, …), Label(id=‘1422’, …), Label(id=‘1423’, …), Label(id=‘1424’, …), Label(id=‘1425’, …), Label(id=‘1426’, …), Label(id=‘1427’, …), Label(id=‘1428’, …), Label(id=‘1429’, …), Label(id=‘1430’, …), Label(id=‘1431’, …), Label(id=‘1432’, …), Label(id=‘1433’, …), Label(id=‘1434’, …)]


⌁   Link to post
Bryan
Bryan

That error indicates that BokehJS has been asked to do something with a Bokeh object that it doesn’t know anything about. My suspicion is that it might be to do with the Label that you create every callback, but then don’t actually do anything with. I can’t ever think of a reason to create “dangling” objects like this that don’t get added to the document. My first suggestion is to comment that line out in the callback. Then, as I mentioned, the the proper way to do things is to create one Label, up front, then later only modify the data source for that existing label, to update it.

⌁   Link to post
yvechang
yvechang

Hi Bryan,
Thank you very much for your suggestions!
From the reminder of your suspicion, Finally, I found the successful way to periodically update the circles and labels in a figure object. And the following things were the changes in my codes.

  1. Remove the label object from the ColumnDataSource of circles in the figure.
  2. Constructing another new ColumnDataSource() named “labelSource” for a “labels” object.
  3. Constructing “labels” object by LabelSet(…), and assigning source = labelSource.
  4. plot.add_layout(labels).
  5. Update the attributes of both circels and “labels” in the callback function periodically.
⌁   Link to post

End of archived discussion · Replies are disabled