question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ColumnDataSource callback on_change issue in 0.13

See original GitHub issue

I have connected a widgets.DataTable with a figure by using the on_change method on the ColumnDataSource.

source = ColumnDataSource(sub)
source.on_change('selected', table_select_callback)

This has stopped working in the latest release (0.13). Selecting rows in the table does not seem to trigger an event anymore.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
bjonencommented, Jun 20, 2018

Many thanks. With the above adjustment, the example is fixed. Thanks for the quick response!

from datetime import date
from random import randint
from bokeh.models import ColumnDataSource
from bokeh.models.widgets import DataTable, DateFormatter, TableColumn

import bokeh.layouts as layouts
import bokeh.models.widgets as widgets
from bokeh.io import curdoc

# from bokeh.models.glyphs import Line
# from bkcharts import Line
import numpy as np
from bokeh.plotting import figure

data = dict(
    dates=[date(2014, 3, i + 1) for i in range(10)],
    downloads=[randint(0, 100) for i in range(10)],
)
d_source = ColumnDataSource(data)

columns = [
    TableColumn(field="dates", title="Date", formatter=DateFormatter()),
    TableColumn(field="downloads", title="Downloads"),
]

data_table = DataTable(source=d_source, columns=columns, width=400, height=280)
#data_table.row_headers = False


def table_select_callback(attr, old, new):
    # print 'here'
    # print new
    # selected_row = new['1d']['indices'][0]
    selected_row = new[0]
    download_count = data['downloads'][selected_row]
    chart_data = np.random.uniform(0, 100, size=download_count)
    p = figure(title='bla')
    r = p.line(x=range(len(chart_data)), y=chart_data)
    root_layout.children[1] = p

# d_source.on_change('selected', table_select_callback)
d_source.selected.on_change('indices', table_select_callback)

root_layout = layouts.Column(data_table, widgets.Div(text='Select Date'))
curdoc().add_root(root_layout)

2reactions
bryevdvcommented, Jun 20, 2018

In any case, arguably, since the work to make Selection a proper Bokeh models earlier this year, the proper/better way to do this is

source.selected.on_change('indices', table_select_callback)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Columndatasource not in document puzzle when using a JS ...
Hello, Recently updated to 0.13.0 and seem to be running into an issue when trying to use a JS / Python Callback combination...
Read more >
Bokeh 1.3.2 documentation
Bokeh Version 1.0.4 (January 2019) primarily addresses a security issue regarding yaml.load ... source.on_change('selected', callback) # BAD, DON'T DO THIS.
Read more >
Running a Bokeh Server — Bokeh 0.13.0 documentation
Normally Bokeh session callbacks recursively lock the document until all future work they initiate is completed. However, you may want to drive blocking ......
Read more >
Releases — Bokeh 3.0.3 Documentation
Ensure change callback manipulation is threadsafe (#12623) ... Bokeh Version 3.0.2 (Nov 2022) is a point release that addresses issues that could result...
Read more >
bokeh.models.markers.Circle — Bokeh 0.13.0 documentation
A mapping of event names to lists of CustomJS callbacks. ... On the BokehJS side, change events for model properties have the form...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found