Remove auto-refresh

master
0xee 2021-01-08 14:47:54 +00:00
parent 324afe2de2
commit 17f0a5eccd
1 changed files with 7 additions and 5 deletions

12
tsplot
View File

@ -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,