I would like to make streaming line graph but I could not understand how to implement bokeh periodic callback. I checked the given examples (1 and 2) for ColumnDataSource
update using update function but I could not understand.
I would like to get data from database and plot (each time new data periodically). Could you please give me a very simple example?
import sqlite3
import time
import datetime
import time, threading
from dateutil import parser
from bokeh.io import curdoc
from bokeh.plotting import figure
from bokeh.layouts import column
p = figure(plot_width=800, plot_height=200)
p2 = figure(plot_width=800, plot_height=200)
conn = sqlite3.connect('data.db')
c = conn.cursor()
p_time = datetime.datetime.now() - datetime.timedelta(minutes=15)
c.execute('SELECT Date_Time, Inactive_Time, signal FROM PlotData WHERE Interface=(?) AND Date_Time>(?)',('wlan0',p_time,))
data = c.fetchall()
xs = []
ys = []
zs = []
for row in data:
xs.append(parser.parse(row[0]))
ys.append(row[1])
zs.append(row[2])
p.line(xs, ys, line_width=2)
p2.line(xs, zs, line_width=2)
curdoc().add_root(column(p,p2))