From 235d51a5244c25736dfa68ba99db700ae28f0599 Mon Sep 17 00:00:00 2001 From: maxl Date: Wed, 18 Mar 2020 22:30:02 +0100 Subject: [PATCH 1/3] - improved bar plots - improved section titles --- app.py | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/app.py b/app.py index 2780ef1..d8fa056 100644 --- a/app.py +++ b/app.py @@ -213,7 +213,7 @@ ], ), html.Br(), - html.H4(children="Data per Canton", style={"color": theme["accent"]}), + html.H4(children="Data per Canton (Interpolated)", style={"color": theme["accent"]}), html.Div( className="row", children=[ @@ -227,7 +227,7 @@ ), html.Br(), html.H4( - children="Interpolated and Predicted Data", style={"color": theme["accent"]} + children="Data per Canton (Interpolated and Predicted)", style={"color": theme["accent"]} ), html.Div( className="row", @@ -321,7 +321,7 @@ def update_case_graph(selected_cantons, selected_scale): if canton in selected_cantons ], "layout": { - "title": "Cases per Canton", + "title": "Cases per Canton (Real)", "height": 750, "xaxis": {"showgrid": True, "color": "#ffffff"}, "yaxis": {"type": selected_scale, "showgrid": True, "color": "#ffffff"}, @@ -349,7 +349,7 @@ def update_case_pc_graph(selected_cantons, selected_scale): if canton in selected_cantons ], "layout": { - "title": "Cases per Canton (per 10,000 Inhabitants)", + "title": "Cases per Canton per 10,000 Inhabitants (Real)", "height": 750, "xaxis": {"showgrid": True, "color": "#ffffff"}, "yaxis": {"type": selected_scale, "showgrid": True, "color": "#ffffff"}, @@ -361,13 +361,13 @@ def update_case_pc_graph(selected_cantons, selected_scale): # -# Total cases Switzerland +# Total cases Switzerland (real) # @app.callback( Output("case-ch-graph", "figure"), [Input("radio-scale", "value")], ) def update_case_ch_graph(selected_scale): - return { + trace = { "data": [ { "x": data["Date"], @@ -375,12 +375,14 @@ def update_case_ch_graph(selected_scale): "name": canton, "marker": {"color": theme["foreground"]}, "type": "bar", + "text": data[canton], + "textposition": "auto", } for i, canton in enumerate(data) if canton != "Date" and canton == "CH" ], "layout": { - "title": "Total Cases Switzerland", + "title": "Total Cases Switzerland (Real)", "height": 400, "xaxis": {"showgrid": True, "color": "#ffffff"}, "yaxis": {"type": selected_scale, "showgrid": True, "color": "#ffffff"}, @@ -388,7 +390,8 @@ def update_case_ch_graph(selected_scale): "paper_bgcolor": theme["background"], "font": {"color": theme["foreground"]}, }, - } + } + return trace # @@ -398,7 +401,7 @@ def update_case_ch_graph(selected_scale): Output("case-ch-graph-pred", "figure"), [Input("radio-scale", "value")], ) def update_case_ch_graph_pred(selected_scale): - return { + trace = { "data": [ { "x": data_pred["Date"], @@ -406,12 +409,14 @@ def update_case_ch_graph_pred(selected_scale): "name": canton, "marker": {"color": theme["foreground"]}, "type": "bar", + "text": data_pred[canton], + "textposition": "auto", } for i, canton in enumerate(data) if canton != "Date" and canton == "CH" ], "layout": { - "title": "Predicted Total Cases Switzerland", + "title": "Total Cases Switzerland (Predicted)", "height": 400, "xaxis": {"showgrid": True, "color": "#ffffff"}, "yaxis": {"type": selected_scale, "showgrid": True, "color": "#ffffff"}, @@ -420,6 +425,7 @@ def update_case_ch_graph_pred(selected_scale): "font": {"color": theme["foreground"]}, }, } + return trace # @@ -442,7 +448,7 @@ def update_case_graph_pred(selected_cantons, selected_scale): if canton in selected_cantons ], "layout": { - "title": "Cases per Canton", + "title": "Cases per Canton (Predicted)", "height": 750, "xaxis": {"showgrid": True, "color": "#ffffff"}, "yaxis": {"type": selected_scale, "showgrid": True, "color": "#ffffff"}, @@ -473,7 +479,7 @@ def update_case_pc_graph_pred(selected_cantons, selected_scale): if canton in selected_cantons ], "layout": { - "title": "Cases per Canton (per 10,000 Inhabitants)", + "title": "Cases per Canton per 10,000 Inhabitants (Predicted)", "height": 750, "xaxis": {"showgrid": True, "color": "#ffffff"}, "yaxis": {"type": selected_scale, "showgrid": True, "color": "#ffffff"}, @@ -486,9 +492,9 @@ def update_case_pc_graph_pred(selected_cantons, selected_scale): if __name__ == "__main__": app.run_server( - # debug=True, - # dev_tools_hot_reload=True, - # dev_tools_hot_reload_interval=5000, - # dev_tools_hot_reload_max_retry=30, + debug=True, + dev_tools_hot_reload=True, + dev_tools_hot_reload_interval=5000, + dev_tools_hot_reload_max_retry=30, ) From b726f692086a983e1dfbfa503a665c651025d30d Mon Sep 17 00:00:00 2001 From: maxl Date: Wed, 18 Mar 2020 23:15:59 +0100 Subject: [PATCH 2/3] - commented debug mode --- app.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app.py b/app.py index d8fa056..0b5cf99 100644 --- a/app.py +++ b/app.py @@ -384,7 +384,7 @@ def update_case_ch_graph(selected_scale): "layout": { "title": "Total Cases Switzerland (Real)", "height": 400, - "xaxis": {"showgrid": True, "color": "#ffffff"}, + "xaxis": {"showgrid": True, "color": "#ffffff", "tickangle": "-45"}, "yaxis": {"type": selected_scale, "showgrid": True, "color": "#ffffff"}, "plot_bgcolor": theme["background"], "paper_bgcolor": theme["background"], @@ -400,14 +400,14 @@ def update_case_ch_graph(selected_scale): @app.callback( Output("case-ch-graph-pred", "figure"), [Input("radio-scale", "value")], ) -def update_case_ch_graph_pred(selected_scale): +def update_case_ch_graph_pred(selected_scale): trace = { "data": [ { "x": data_pred["Date"], "y": data_pred[canton], "name": canton, - "marker": {"color": theme["foreground"]}, + "marker": {"color": "#ffffff"}, "type": "bar", "text": data_pred[canton], "textposition": "auto", @@ -418,7 +418,7 @@ def update_case_ch_graph_pred(selected_scale): "layout": { "title": "Total Cases Switzerland (Predicted)", "height": 400, - "xaxis": {"showgrid": True, "color": "#ffffff"}, + "xaxis": {"showgrid": True, "color": "#ffffff", "tickangle": "-45"}, "yaxis": {"type": selected_scale, "showgrid": True, "color": "#ffffff"}, "plot_bgcolor": theme["background"], "paper_bgcolor": theme["background"], @@ -492,9 +492,9 @@ def update_case_pc_graph_pred(selected_cantons, selected_scale): if __name__ == "__main__": app.run_server( - debug=True, - dev_tools_hot_reload=True, - dev_tools_hot_reload_interval=5000, - dev_tools_hot_reload_max_retry=30, + #debug=True, + #dev_tools_hot_reload=True, + #dev_tools_hot_reload_interval=5000, + #dev_tools_hot_reload_max_retry=30, ) From da0e2e76c796f140e124a07897c370751e6fe0e1 Mon Sep 17 00:00:00 2001 From: maxl Date: Wed, 18 Mar 2020 23:20:03 +0100 Subject: [PATCH 3/3] - changed weird color --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index 0b5cf99..5b13c4b 100644 --- a/app.py +++ b/app.py @@ -407,7 +407,7 @@ def update_case_ch_graph_pred(selected_scale): "x": data_pred["Date"], "y": data_pred[canton], "name": canton, - "marker": {"color": "#ffffff"}, + "marker": {"color": theme["foreground"]}, "type": "bar", "text": data_pred[canton], "textposition": "auto",