def update_range(ds, fig, window): #if len(ds.data['x']) > window: # fig.x_range.start = time.mktime(ds.data['x'][-window].timetuple()) * 1000 - 20000000 # fig.x_range.end = time.mktime(ds.data['x'][-1].timetuple()) * 1000 - 20000000 now = datetime.now() start = now - timedelta(hours=window) #fig.x_range.start = time.mktime(start.timetuple()) * 1000 - 20000000 #fig.x_range.end = time.mktime(now.timetuple()) * 1000 - 20000000 #cursession().store_objects(fig.x_range) cursession().store_objects()
import time import numpy as np from bokeh.charts import Line, curdoc, cursession, output_server, show from bokeh.models import GlyphRenderer N = 80 x = np.linspace(0, 4*np.pi, N) xyvalues = OrderedDict(sin=np.sin(x), cos=np.cos(x)) output_server("line_animate") chart = Line(xyvalues, title="Lines", ylabel='measures') curdoc().add(chart) show(chart) renderer = chart.select(dict(type=GlyphRenderer)) ds = renderer[0].data_source while True: for i in np.hstack((np.linspace(1, -1, 100), np.linspace(-1, 1, 100))): for k, values in xyvalues.items(): if k != 'x': ds.data['y_%s'%k] = values * i cursession().store_objects(ds) time.sleep(0.05)
def update_series(ds, xvalue, yvalue): ds.data['x'].append(xvalue) ds.data['y'].append(yvalue) cursession().store_objects(ds)
import time import numpy as np from bokeh.charts import Line, curdoc, cursession, output_server, show from bokeh.models import GlyphRenderer N = 80 x = np.linspace(0, 4 * np.pi, N) xyvalues = OrderedDict(sin=np.sin(x), cos=np.cos(x)) output_server("line_animate") chart = Line(xyvalues, title="Lines", ylabel='measures') curdoc().add(chart) show(chart) renderer = chart.select(dict(type=GlyphRenderer)) ds = renderer[0].data_source while True: for i in np.hstack((np.linspace(1, -1, 100), np.linspace(-1, 1, 100))): for k, values in xyvalues.items(): if k != 'x': ds.data['y_%s' % k] = values * i cursession().store_objects(ds) time.sleep(0.05)