Is there a way to make multiple selections within a “DataTable” for plotting. In the example below it seems that only one row of data at a time can be selected and plotted. I’d like to make multiple selections and have them all plotted on the same graph.
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.charts import Line
import numpy as np
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):
selected_row = new[‘1d’][‘indices’][0]
download_count = data[‘downloads’][selected_row]
chart_data = np.random.uniform(0, 100, size=download_count)
fig = Line(chart_data, height=250, width=600)
fig.title.text = “Download times - {}”.format(data[‘dates’][selected_row])
root_layout.children[1] = fig
d_source.on_change(‘selected’, table_select_callback)
root_layout = layouts.Column(data_table, widgets.Div(text=‘Select Date’))
curdoc().add_root(root_layout)