Advertisement
Higem

Untitled

Apr 7th, 2020
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. from bokeh.io import show
  2. from bokeh.models import DataTable, TableColumn, ColumnDataSource, CustomJS
  3.  
  4. cds = ColumnDataSource(data=dict(x=["a", "b", "c"], y=[10,20,30]))
  5. dt = DataTable(columns=[TableColumn(title='X', field='x'),
  6. TableColumn(title='Y', field='y')],
  7. width=200, source=cds, editable=True)
  8.  
  9.  
  10.  
  11. fig1 = figure(x_range=["a", "b", "c"], width=300, height=250)
  12.  
  13. vbar = fig1.vbar(x='x', top='y', source=cds)
  14.  
  15. cds.js_on_change('patching', CustomJS(args=dict(cds=cds, fig=fig), code="""
  16. const firstKey = Object.keys(cds.data)[0];
  17. const newFactors = cds.data[firstKey];
  18. fig.x_range.factors = newFactors;
  19. cds.change.emit();
  20. """))
  21.  
  22. show(row(dt, fig))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement