Arbitraty JS at the beginning of each session
See original GitHub issueI am trying to run JS code at the beginning of a bokeh serve session and return some values to the python side which I will use later to update the plot data. Currently I am not able to see any documentation to achieve this.
I tried the following to no avail. Is there a way to do this?
from random import random
import numpy as np
from bokeh.layouts import column, row, widgetbox, layout
from bokeh.models import Button
from bokeh.palettes import RdYlBu3
from bokeh.plotting import figure, curdoc
from bokeh.models.widgets import MultiSelect, Dropdown, Select, TextInput, PreText
from bokeh.models import ColumnDataSource, CustomJS, Slider
from bokeh.models.widgets import DataTable, DateFormatter, TableColumn
source = ColumnDataSource(data=dict(x=[0,1,2]))
jscallback = CustomJS(args=dict(source=source), code="""
var data = source.get('data');
x = data['x']
x = x+x;
console.log(x)
source.trigger('change');
""")
slider = Slider(start=0.1, end=4, value=1, step=.1, title="power", callback=jscallback)
def printcallback():
print(source.data['x'])
button1 = Button(label="Foo", button_type="success")
button1.on_click(printcallback)
l = row(slider, button1)
curdoc().add_root(l)
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Getter for arbitrary property of object - javascript - Stack Overflow
I know I can use Object.defineProperty to define a custom getter, I just can't wrap my head around how to access an arbitrary,...
Read more >Queries will hang arbitrarily · Issue #148 · neo4j ... - GitHub
Occasionally, this will hang on session.run for a long period of time (~60 seconds?). After that, we get a ETIMEDOUT error.
Read more >Tools — Acrobat-PDFL SDK: JS Developer Guide
Learn how to integrate PDF products and features in your apps with the Acrobat and PDFL APIs. Create apps that integrate with Adobe's ......
Read more >Node.js Vulnerability Cheatsheet | ShiftLeft Blog
25 vulnerabilities to look out for in Node JS applications: Directory traversal, prototype pollution, XSSI, and more…
Read more >Communicating with Shiny via JavaScript
Communication from JavaScript to R works by setting a reactive input. ... to run arbitrary R code in response to the value.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This capability does not yet exist.
Ah I see yes that works however the on_change event on the source does not trigger when doing this.
In the code below moving the slider changes the source. Clicking the button shows that the source has been changed and prints out the new value. However the on change event on source is not triggered.