some prototypes
This commit is contained in:
39
prototypes/stream-bokeh.py
Normal file
39
prototypes/stream-bokeh.py
Normal file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from time import sleep
|
||||
from random import random
|
||||
from bokeh.plotting import curdoc, figure
|
||||
from bokeh.models import ColumnDataSource
|
||||
|
||||
data = {
|
||||
"x": [0, 1, 2, 3, 4],
|
||||
"y": [6, 7, 2, 3, 5]
|
||||
}
|
||||
|
||||
i = len(data["x"])
|
||||
|
||||
source = ColumnDataSource(data=data)
|
||||
|
||||
p = figure()
|
||||
p.line(x="x", y="y", source=source)
|
||||
|
||||
|
||||
def update():
|
||||
global i
|
||||
i += 1
|
||||
|
||||
new = {
|
||||
"x": [i],
|
||||
"y": [random()*10]
|
||||
}
|
||||
|
||||
source.stream(new, rollover=50)
|
||||
|
||||
|
||||
|
||||
doc = curdoc()
|
||||
doc.add_periodic_callback(update, 500)
|
||||
doc.add_root(p)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user