I already posted (a better readable post) on stackoverflow but had no answer: python - Bokeh+Flask: Multiple AjaxDataSource calls - Stack Overflow
A simple 3-glyphs plot is giving me headache.
This is the stripped down 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):
# load data from db and return JSON
...
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()
)
Why is AjaxDataSource
called 3 times, once for each glyph (they are a few milliseconds apart, then the triple reading is done again after 5 seconds) instead of only once every 5 seconds, one reading for the 3 glyphs?
I believed that AjaxDataSource fills dynamically data_source.data
every 5 seconds and then, after they have been read, the 3 lines read these “now static” data.