Skip to content

Commit 4a30e05

Browse files
committed
include all time graphs
1 parent d204c2c commit 4a30e05

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

app.py

+43-3
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,12 @@ def wind_direction_graph(df_wind, history_rgb, forecast_rgb):
437437
)
438438
return fig
439439

440+
440441
@app.callback(
441442
Output(component_id='all_info', component_property="children"),
442443
Input(component_id="interval", component_property="n_intervals")
443444
)
444445
def generate_page(n_intervals):
445-
446446
try:
447447
logging.info(f"Regenerating info div: times regenerated = {n_intervals}")
448448
df = create_df()
@@ -461,6 +461,17 @@ def generate_page(n_intervals):
461461
forecast_rgb=FORECAST_RGB
462462
)
463463

464+
fig_temp_historical = create_time_figure(
465+
df,
466+
"temperature.temp",
467+
"Temperature (F) - All time",
468+
show_forecast=False,
469+
show_history=True,
470+
history_rgb="rgb(255,0,0)",
471+
limit_date_range=False,
472+
)
473+
474+
464475
fig_precipitation_prob = create_time_figure(
465476
df,
466477
"precipitation_probability",
@@ -480,6 +491,16 @@ def generate_page(n_intervals):
480491
history_rgb="rgb(0,255,0)",
481492
forecast_rgb=FORECAST_RGB
482493
)
494+
fig_windspeed_historical = create_time_figure(
495+
df,
496+
"wind.speed",
497+
"Wind speed (mph) - All time",
498+
show_forecast=False,
499+
show_history=True,
500+
history_rgb="rgb(0,255,0)",
501+
limit_date_range=False
502+
)
503+
483504

484505
fig_pressure = create_time_figure(
485506
df,
@@ -588,7 +609,18 @@ def generate_page(n_intervals):
588609
history_rgb="rgb(7,130,255)",
589610
forecast_rgb=FORECAST_RGB
590611
)
591-
fig_aqi.update_yaxes(type="category", categoryorder="array", categoryarray=["great", "fair", "moderate", "poor", "hazardous"])
612+
fig_aqi_historical = create_time_figure(
613+
adf,
614+
"aqi",
615+
"Adjusted AQI - All time",
616+
show_history=True,
617+
show_forecast=False,
618+
history_rgb="rgb(7,130,255)",
619+
limit_date_range=False
620+
)
621+
622+
for fig in (fig_aqi, fig_aqi_historical):
623+
fig.update_yaxes(type="category", categoryorder="array", categoryarray=["great", "fair", "moderate", "poor", "hazardous"])
592624

593625
trace_pollutants_forecasts = False
594626
trace_pollutants_markers = "lines"
@@ -726,6 +758,14 @@ def generate_page(n_intervals):
726758
if len(graphs) % 2 != 0:
727759
divs.append(html.Div(graphs[-1], className="row"))
728760

761+
762+
graphs_historical = [
763+
dcc.Graph(id="graph_temp_historical", figure=fig_temp_historical),
764+
dcc.Graph(id="graph_windspeed_historical", figure=fig_windspeed_historical),
765+
dcc.Graph(id="graph_aqi_historical", figure=fig_aqi_historical),
766+
]
767+
divs_historical = [html.Div(g) for g in graphs_historical]
768+
729769

730770
# top rows
731771
common_style = {"width": "95%", "height": "700px", "margin": "auto", "border": "30px"}
@@ -848,7 +888,7 @@ def generate_page(n_intervals):
848888
col1 = html.Div([right_now, g], className="six columns")
849889
col2 = html.Div(widget, className="six columns")
850890
toprow = html.Div([col1, col2], className="row")
851-
return html.Div([toprow] + divs)
891+
return html.Div([toprow] + [html.H3("Recent Weather Metrics", style=white_text)] + divs + [html.H3("Full History", style=white_text)] + divs_historical)
852892
except BaseException:
853893
exc_type, exc_value, exc_traceback = sys.exc_info()
854894
tbf = traceback.format_exception(exc_type, exc_value, exc_traceback)

0 commit comments

Comments
 (0)