| 72 | return df.sort_values(df.index[-1], axis=1) # Sorts columns by last day's value. |
| 73 | |
| 74 | def get_figure(df): |
| 75 | figure = go.Figure() |
| 76 | for col_name in reversed(df.columns): |
| 77 | yaxis = 'y1' if col_name == 'Total Cases' else 'y2' |
| 78 | colors = {'Total Cases': '#EF553B', 'Bitcoin': '#636efa', 'Gold': '#FFA15A', |
| 79 | 'Dow Jones': '#00cc96'} |
| 80 | trace = go.Scatter(x=df.index, y=df[col_name], name=col_name, yaxis=yaxis, |
| 81 | line=dict(color=colors[col_name])) |
| 82 | figure.add_trace(trace) |
| 83 | figure.update_layout( |
| 84 | yaxis1=dict(title='Total Cases', rangemode='tozero'), |
| 85 | yaxis2=dict(title='%', rangemode='tozero', overlaying='y', side='right'), |
| 86 | legend=dict(x=1.1), |
| 87 | margin=dict(t=24, b=0), |
| 88 | paper_bgcolor='rgba(0, 0, 0, 0)' |
| 89 | ) |
| 90 | return figure |
| 91 | |
| 92 | main() |
| 93 | |