Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from bokeh.io import show
- from bokeh.models import DataTable, TableColumn, ColumnDataSource, CustomJS
- cds = ColumnDataSource(data=dict(x=["a", "b", "c"], y=[10,20,30]))
- dt = DataTable(columns=[TableColumn(title='X', field='x'),
- TableColumn(title='Y', field='y')],
- width=200, source=cds, editable=True)
- fig1 = figure(x_range=["a", "b", "c"], width=300, height=250)
- vbar = fig1.vbar(x='x', top='y', source=cds)
- cds.js_on_change('patching', CustomJS(args=dict(cds=cds, fig=fig), code="""
- const firstKey = Object.keys(cds.data)[0];
- const newFactors = cds.data[firstKey];
- fig.x_range.factors = newFactors;
- cds.change.emit();
- """))
- show(row(dt, fig))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement