Update on_change behavior for Bokeh 1.0
@@ -5,6 +5,7 @@ from operator import add
from time import time
import weakref
+import bokeh
from bokeh.layouts import row, column
from bokeh.models import ( ColumnDataSource, Plot, DataRange1d, LinearAxis,
HoverTool, BoxZoomTool, ResetTool, PanTool, WheelZoomTool, Range1d,
@@ -325,6 +326,9 @@ class ProfilePlot(DashboardComponent):
self.source.data.update(data)
self.source.selected = old
+ if bokeh.__version__ >= '1.0':
+ self.source.selected.on_change('indices', cb)
+ else:
self.source.on_change('selected', cb)
self.root = figure(tools='tap', **kwargs)
@@ -411,9 +415,9 @@ class ProfileTimePlot(DashboardComponent):
if changing[0]:
return
with log_errors():
- try:
- selected = new.indices
- except AttributeError:
+ if isinstance(new, list): # bokeh >= 1.0
+ selected = new
+ else:
selected = new['1d']['indices']
try:
ind = selected[0]
@@ -424,9 +428,15 @@ class ProfileTimePlot(DashboardComponent):
self.states.extend(data.pop('states'))
changing[0] = True # don't recursively trigger callback
self.source.data.update(data)
+ if isinstance(new, list): # bokeh >= 1.0
+ self.source.selected.indices = old
+ else:
self.source.selected = old
changing[0] = False
+ if bokeh.__version__ >= '1.0':
+ self.source.selected.on_change('indices', cb)
+ else:
self.source.on_change('selected', cb)
self.profile_plot = figure(tools='tap', height=400, **kwargs)
@@ -496,6 +506,9 @@ class ProfileTimePlot(DashboardComponent):
self.start = self.stop = None
self.trigger_update(update_metadata=False)
+ if bokeh.__version__ >= '1.0':
+ self.ts_source.selected.on_change('indices', ts_change)
+ else:
self.ts_source.on_change('selected', ts_change)
self.reset_button = Button(label="Reset", button_type="success")
@@ -578,9 +591,9 @@ class ProfileServer(DashboardComponent):
if changing[0]:
return
with log_errors():
- try:
- selected = new.indices
- except AttributeError:
+ if isinstance(new, list): # bokeh >= 1.0
+ selected = new
+ else:
selected = new['1d']['indices']
try:
ind = selected[0]
@@ -591,9 +604,15 @@ class ProfileServer(DashboardComponent):
self.states.extend(data.pop('states'))
changing[0] = True # don't recursively trigger callback
self.source.data.update(data)
+ if isinstance(new, list): # bokeh >= 1.0
+ self.source.selected.indices = old
+ else:
self.source.selected = old
changing[0] = False
+ if bokeh.__version__ >= '1.0':
+ self.source.selected.on_change('indices', cb)
+ else:
self.source.on_change('selected', cb)
self.profile_plot = figure(tools='tap', height=400, **kwargs)
@@ -663,6 +682,9 @@ class ProfileServer(DashboardComponent):
self.start = self.stop = None
self.trigger_update()
+ if bokeh.__version__ >= '1.0':
+ self.ts_source.selected.on_change('indices', ts_change)
+ else:
self.ts_source.on_change('selected', ts_change)
self.reset_button = Button(label="Reset", button_type="success")
