Bokeh: Displaying only selected entries in DataTable

Created on 20 May 2015  路  4Comments  路  Source: bokeh/bokeh

Based on the DataTable example, is it possible to display only those entries in the table that were selected in the plot?

Currently, the data entries for selected glyphs are only highlighted.

[Bokeh version 0.9.0rc.62565432]

discussion

Most helpful comment

CDSViews now work with data tables, e.g.

view1 = CDSView(source=source, filters=[GroupFilter(column_name='manufacturer', group='Audi')])
data_table = DataTable(source=source, columns=columns, editable=True, width=1000,
                       index_position=-1, index_header="row index", index_width=60, view=view1)

restricts the table to only "Audi" rows in the data_tables.py example.

@esvhd you are seeing a something different, I am going to copy your code and comment to a new issue.

All 4 comments

I had a similar issue where I wanted to display only certain rows based on some filters. The hack I used was to use two datasources, one "read only" and the other modified based on the current filters.

Here's a gist: https://gist.github.com/dennisobrien/450d7da20daaba6d39d0

This seems like it might fall out of filterable CDS work fairly straightforwardly.

Edit: filed a new issue #7966 here.

I noticed that in 0.12.16 (and at least 1 version ago as well), selected rows (i.e. associated glyph) in DataTable are no longer highlighted in figure. Has the default behaviour changed and if so is there a way to turn it back on?

Running the same code as previous versions in notebook, code example below:

import bokeh.plotting as bkp
from bokeh.resources import INLINE
bkp.output_notebook(resources=INLINE)

from datetime import date
from random import randint

# from bokeh.layouts import widgetbox
from bokeh.models import ColumnDataSource
from bokeh.models.widgets import DataTable, DateFormatter, TableColumn

import bokeh.models as bkm
import bokeh

data = dict(
        dates=[i for i in range(10)],
        downloads=[randint(0, 100) for i in range(10)],
    )
source = ColumnDataSource(data)

p = bkp.figure(plot_width=300, plot_height=200)
downs = bkm.Cross(x='dates', y='downloads', size=12, line_color='blue')
g = p.add_glyph(source_or_glyph=source, glyph=downs)

columns = [
        TableColumn(field="dates", title="Date", formatter=DateFormatter()),
        TableColumn(field="downloads", title="Downloads"),
    ]
data_table = DataTable(source=source, columns=columns, width=400, height=280)

layout = bkm.layouts.Column(p, bokeh.layouts.WidgetBox(data_table))

bkp.show(layout)

CDSViews now work with data tables, e.g.

view1 = CDSView(source=source, filters=[GroupFilter(column_name='manufacturer', group='Audi')])
data_table = DataTable(source=source, columns=columns, editable=True, width=1000,
                       index_position=-1, index_header="row index", index_width=60, view=view1)

restricts the table to only "Audi" rows in the data_tables.py example.

@esvhd you are seeing a something different, I am going to copy your code and comment to a new issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thoth291 picture thoth291  路  4Comments

taiwotman picture taiwotman  路  3Comments

agoodm picture agoodm  路  4Comments

rornor picture rornor  路  3Comments

cyrusmaher picture cyrusmaher  路  3Comments