A Bokeh object is a number that shows 3 independent lines.
Data is streamed. The AjaxDataSource call updates data every 5 seconds, reading the latest from the database.
This is a split class:
class Graph:
def __init__(self):
data_source = AjaxDataSource(data=dict(date_time=[],
value_1=[],
value_2=[],
value_3=[]),
data_url="/data",
polling_interval=5000)
line1 = self.figure.line(x="date_time", y="value_1", source=data_source)
line2 = self.figure.line(x="date_time", y="value_2", source=data_source)
line3 = self.figure.line(x="date_time", y="value_3", source=data_source)
app.add_url_rule("/data", "/data", self.serve, methods=['GET', 'OPTIONS', 'POST'])
def serve(self):
...
return jsonify(
date_time= da.df["Date_Time"].tolist(),
value_1=da.df["Value1"].tolist(),
value_2=da.df["Value2"].tolist(),
value_3=da.df["Value3"].tolist()
)
date_timeis the common x axis, value_1for row 1, value_2for row 2, value_3for row 3.
Problem
Why AjaxDataSourceis it called 3 times (they are a few milliseconds from each other, then triple reading is performed after 5 seconds), and not only once every 5 seconds?
I believed that the AjaxDataSource is dynamically populated data_source.dataevery 5 seconds, and then, after they have been read, 3 lines read this "static" data.
Workaround
AjaxDataSource, ColumnDataSource "" ?
- ?