Created
September 9, 2019 20:41
-
-
Save david-macleod/312404f28ef928df8e42312cdc9bbb00 to your computer and use it in GitHub Desktop.
bokeh callbacks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bokeh.models import CustomJS, ColumnDataSource | |
source = ColumnDataSource(data=dict(x=[0,0], y=[0, 80])) | |
# Javascript | |
callback = CustomJS(args=dict(source=source), code=""" | |
var data = source.data; | |
var f = cb_obj.value | |
data['x'] = [f, f] | |
source.change.emit(); | |
""") | |
model_obj.js_on_change('value', callback) | |
# Python | |
def callback(attrname, old, new): | |
source.data['x'] = [new, new] | |
model_obj.on_change('value', callback) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment