import dash_table import dash_html_components as html import dash_core_components as dcc from make_figures import make_map, make_timeplot, FIRST_LINE_HEIGHT from data_input import tidy_most_recent, get_all_data if 'DEBUG' in os.environ: debug = os.environ['DEBUG'] == 'True' print(f"DEBUG environment variable present, DEBUG set to {debug}") else: print("No DEBUG environment variable: defaulting to debug mode") debug = True # -------- Data -------------------------- df, df_prediction = get_all_data() df_tidy = tidy_most_recent( df) # most recent date, tidy format (one column for countries) df_tidy_table = df_tidy[['country_region', 'value']] # keep only two columns for Dash DataTable # ----------- Figures --------------------- fig1 = make_map(df_tidy) fig2 = make_timeplot(df, df_prediction) # ------------ Markdown text --------------- # maybe later we can break the text in several parts with open("text_block.md", "r") as f: intro_md = f.read() # -----------App definition----------------------- app = dash.Dash( __name__,
fig.update_layout( showlegend=True, annotations=[fatalities_annotation, confirmed_annotation, drag_handle_annotation], xaxis_tickfont_size=LABEL_FONT_SIZE - 4, yaxis_tickfont_size=LABEL_FONT_SIZE - 4, yaxis_type='linear', height=FIRST_LINE_HEIGHT, margin=dict(t=0, b=0.02), # The legend position + font size # See https://plot.ly/python/legend/#style-legend legend=dict(x=.05, y=.8, font_size=LABEL_FONT_SIZE) ) return fig if __name__ == '__main__': from data_input import get_all_data, tidy_most_recent df, df_prediction = get_all_data() # most recent date, tidy format (one column for countries) df_tidy = tidy_most_recent(df) df_tidy_fatalities = tidy_most_recent(df, 'death') fig1 = make_map(df_tidy, df_tidy_fatalities) fig2 = make_timeplot(df, df_prediction)
y=1.05, yanchor="top", font_color='black', ), ], xaxis_tickfont_size=LABEL_FONT_SIZE - 4, yaxis_tickfont_size=LABEL_FONT_SIZE - 4, height=FIRST_LINE_HEIGHT, margin=dict(t=0, b=0.02), # The legend position + font size # See https://plot.ly/python/legend/#style-legend legend=dict(x=.05, y=.8, font_size=LABEL_FONT_SIZE, title="Active cases in"), ) return fig if __name__ == '__main__': from data_input import get_all_data, tidy_most_recent df, df_prediction = get_all_data() # most recent date, tidy format (one column for countries) df_tidy = tidy_most_recent(df) df_tidy_fatalities = tidy_most_recent(df, 'death') df_tidy_recovered = tidy_most_recent(df, 'recovered') fig1 = make_map(df_tidy, df_tidy_fatalities, df_tidy_recovered) fig2 = make_timeplot(df, df_prediction)
), dict( args=["yaxis", {'type':'linear'}], label="lin", method="relayout", ), ]), pad={"r": 10, "t": 10, "b":5}, showactive=True, x=0.05, xanchor="left", y=1.35, yanchor="top", font_color='black', ), ], height=.9*FIRST_LINE_HEIGHT, ) return fig if __name__ == '__main__': from data_input import get_all_data, tidy_most_recent df, df_prediction = get_all_data() df_tidy = tidy_most_recent(df) fig1 = make_map(df_tidy) fig2 = make_timeplot(df, df_prediction)