def update_pm25(): # re-scan the table and get last update dt lastpm = generate_graph(table)['lastpm'] lastpm25 = 'PM2.5: ' + str(lastpm['pm25']) + ' (' + str( generate_graph(table)['lastpm']['pm25'] * 4) + '%)' return lastpm25
def serve_layout(): # dash app layout definition serve = html.Div( style={'backgroundColor': colors['background']}, children=[ # title html.H1(children='Zanieczyszczenie powietrza', style={ 'textAlign': 'center', 'color': colors['text'] }), # graph dcc.Graph(id='live-graph', animate=False, figure=go.Figure( data=generate_graph(table)['data'], layout=go.Layout(yaxis=dict(title="µg/m3")))), # last updated date html.Div(id='update-date', children=generate_graph(table)['lastdt'], style={ 'textAlign': 'right', 'color': colors['text'], 'fontSize': 12 }), # event update handler dcc.Interval(id='event-update', interval=4 * 1000) ]) return serve
def update_header(): # re-scan the table and get last update dt lastdt = 'Data as of: ' + generate_graph( table, dt_limit)['lastdt'][11:13] + '.' + generate_graph( table, dt_limit)['lastdt'][14:15] + '0:' return lastdt
def update_pm10(): # re-scan the table and get last update dt lastpm = generate_graph(table)['lastpm'] lastpm10 = 'PM10: ' + str(lastpm['pm10']) + ' (' + str( generate_graph(table)['lastpm']['pm10'] * 2) + '%)' return lastpm10
def update_date(): # re-scan the table and get last update dt lastdt = generate_graph(table)['lastdt'] return lastdt
def update_graph(): # re-scan the table return generate_graph(table)
def serve_layout(): # dash app layout definition serve = html.Div( style={'backgroundColor': colors['background']}, children=[ # title html.H1(children='Zanieczyszczenie powietrza', style={ 'textAlign': 'center', 'color': colors['text'] }), # graph dcc.Graph(id='live-graph', animate=False, figure=go.Figure( data=generate_graph(table)['data'], layout=go.Layout( yaxis=dict(title="µg/m3"), xaxis=dict(rangeselector=dict(buttons=list([ dict(count=6, label='6h', step='hour', stepmode='backward'), dict(count=1, label='1d', step='day', stepmode='backward'), dict(count=7, label='1w', step='day', stepmode='backward'), dict(count=14, label='2w', step='day', stepmode='backward'), dict(step='all') ])), rangeslider=dict(visible=True), type='date')))), # header pm html.Div(id='update-header', children='Stan na godz. ' + generate_graph(table)['lastdt'][11:13] + '.' + generate_graph(table)['lastdt'][14:15] + '0:', style={ 'textAlign': 'left', 'color': colors['text'], 'fontSize': 27, 'marginTop': 2, 'marginLeft': 24 }), # latest results pm10 html.Div(id='update-pm10', children='PM10: ' + str(generate_graph(table)['lastpm']['pm10']) + ' (' + str(generate_graph(table)['lastpm']['pm10'] * 2) + '%)', style={ 'textAlign': 'left', 'color': colors['text'], 'fontSize': 27, 'marginTop': 5, 'marginLeft': 24 }), # latest results pm25 html.Div(id='update-pm25', children='PM2.5: ' + str(generate_graph(table)['lastpm']['pm25']) + ' (' + str(generate_graph(table)['lastpm']['pm25'] * 4) + '%)', style={ 'textAlign': 'left', 'color': colors['text'], 'fontSize': 27, 'marginTop': 5, 'marginLeft': 24 }), # last updated date html.Div(id='update-date', children='Ostatnia aktualizacja: ' + generate_graph(table)['lastdt'], style={ 'textAlign': 'right', 'color': colors['text'], 'fontSize': 9 }), # event update handler dcc.Interval( id='event-update', interval=60 * 4 * 1000 # update every 4 minutes ) ]) return serve
def update_date(): # re-scan the table and get last update dt lastdt = 'Ostatnia aktualizacja: ' + generate_graph(table)['lastdt'] return lastdt
def update_header(): # re-scan the table and get last update dt lastdt = 'Stan na godz. ' + generate_graph(table)['lastdt'][ 11:13] + '.' + generate_graph(table)['lastdt'][14:15] + '0:' return lastdt
def update_date(): # re-scan the table and get last update dt lastdt = 'Last update: ' + generate_graph(table, dt_limit)['lastdt'] return lastdt
def update_temp(): # re-scan the table and get last update dt lastpm = generate_graph(table, dt_limit)['lastpm'] lasttemp = 'Temperature: ' + str(lastpm['temp']) + '°C' return lasttemp
def update_hum(): # re-scan the table and get last update dt lastpm = generate_graph(table, dt_limit)['lastpm'] lasthum = 'Humidity: ' + str(lastpm['hum']) + '%' return lasthum
def update_pm1(): # re-scan the table and get last update dt lastpm = generate_graph(table, dt_limit)['lastpm'] lastpm1 = 'PM1: ' + str(lastpm['pm1']) return lastpm1