From 17f0a5eccd53170d1047eb150947fc7d2e2b417e Mon Sep 17 00:00:00 2001 From: 0xee Date: Fri, 8 Jan 2021 14:47:54 +0000 Subject: [PATCH] Remove auto-refresh --- tsplot | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tsplot b/tsplot index 59c2f5f..fabc2f5 100755 --- a/tsplot +++ b/tsplot @@ -25,8 +25,6 @@ def get_topics(db): return topics -update_interval_s = 4 - # Since we're adding callbacks to elements that don't exist in the app.layout, # Dash will raise an exception to warn us that we might be # doing something wrong. @@ -42,6 +40,7 @@ app.layout = html.Div([ @lru_cache(maxsize=10) def get_data(topic, timerange, ts): + start = time.time() conn = sqlite3.connect(db) table = topic @@ -50,9 +49,12 @@ def get_data(topic, timerange, ts): df = pd.read_sql(query, conn, parse_dates=[ 'timestamp'], index_col='timestamp') + print(f"Obtained data in {time.time()-start}") return df + + plot_page = html.Div([ dcc.Interval( id='interval-component', @@ -106,16 +108,16 @@ def update_topic_checklist(pathname): return [{"label":topic, "value":topic, "disabled":False} for topic in sorted(topics)], selected @app.callback(Output('graph', 'figure'), - [Input('interval-component', 'n_intervals'), + [ Input('timerange', 'value'), Input('range_count', 'value'), Input('topic-checklist', 'value')]) -def update_graph(interval, timerange, range_count, topics): +def update_graph(timerange, range_count, topics): if topics: print(f"topics: {topics}") delta = get_timedelta(timerange, range_count) - now = int(time.time()) // update_interval_s + now = int(time.time()) def make_data(df, name): return { 'x': df.index,