def dataframe_to_date(usa_only=False, scale=1000): # We should connect the last expensive data querying steps needed to render the graphs with this data # Get Today's Date today = datetime.date.today() # Get the date 7 days ago week_ago = today - datetime.timedelta(days=60) # Create Variable = Async Data Fetch requesting date df_list = fetch_to_date.main(date=str(week_ago), value=scale, usa_only=usa_only) # returns a list [df1, df2, ... df7] # loop through the list for df in df_list: print(f'Building Redis Storage on: {df["lastUpdate"][0]}-dataframe') # Creates a redis instence to store data, turns df to dictionary & encodes in json redis_instance.set( f'{df["lastUpdate"][0]}-dataframe', json.dumps( df.to_dict(), # This JSON Encoder will handle things like numpy arrays # and datetimes cls=plotly.utils.PlotlyJSONEncoder, ), )
] } ], paper_bgcolor='rgba(0,0,0,0)', plot_bgcolor='rgba(0,0,0,0)', font=dict( family="Courier New, monospace", size=18, color="#7f7f7f" ) ) frames = [] for l in maps: frames.append(go.Frame(data=l)) fig = go.Figure(data=[maps[0][0], maps[0][1], maps[0][2]], layout=layout, frames=frames[::-1]) return fig if __name__ == '__main__': map = request_map(fetch_to_date.main(date='2020-03-24', usa_only=False, value=500)) map.show() print(map)
def query_to_date(date='2020-03-24', usa_only=False, scale=500): data = fetch_to_date.main(date=date, value=scale, usa_only=usa_only) return conn.setex('TO_Date', TIMEOUT, zlib.compress(pickle.dumps(data)))
def display_worldmap(date): fetch_data = fetch_to_date.main(date, usa_only=False) date_data = three_d(fetch_data) return dcc.Graph(figure=date_data, style={'height': '85vh'})
dbc.Label("Cases / Scale", html_for="slider"), dcc.Slider(id="slider", min=1, max=1000, step=10, value=400), ]) ])), width=3), dbc.Col(html.H1(id='rate-slider', ), width=3), ]), dbc.Row([ dbc.Col(html.Div(id='rate-scale'), md=12, lg=6), dbc.Col(html.Div( dcc.Graph(figure=usa_barchart( data=fetch_to_date.main('2020-03-28', usa_only=True)), style={'height': '75vh'})), md=12, lg=6) ]), ]))) tab_snapshot = dbc.Card( dbc.CardBody([ dbc.Row([ # Header dbc.Row([ dbc.Col(html.Div(), width=3), dbc.Col(dcc.DatePickerSingle( id='date-picker-single', min_date_allowed=dt(2020, 3, 23),
text=x['countryRegion'], name=str(x['lastUpdate'][0]), customdata=x.loc[:, ['confirmed']], hovertemplate="<b>%{text}</b><br><br>" + "Confirmed: %{customdata[0]}<br>" + "<extra></extra>", )) layout = go.Layout( paper_bgcolor='#060606', plot_bgcolor='rgba(0,0,0,0)', barmode='stack', title='Daily Growth By Country', font=dict(family="Courier New, monospace", size=18, color="#7f7f7f"), xaxis={ 'rangeslider_visible': True, 'range': [ data[-1]['lastUpdate'][0], str(datetime.date.today() - datetime.timedelta(days=1)) ] }, ) fig = go.Figure(data=graphs, layout=layout) return fig if __name__ == '__main__': fetch_data = fetch_to_date.main('2020-03-28', usa_only=False) date_data = three_d(fetch_data).show()
"below": 'traces', "sourcetype": "raster", "source": [ "https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}" ] }], paper_bgcolor='rgba(0,0,0,0)', plot_bgcolor='rgba(0,0,0,0)', font=dict(family="Courier New, monospace", size=18, color="#7f7f7f")) frames = [] for m in maps: frames.append(go.Frame(data=m)) fig = go.Figure(data=[maps[0][0], maps[0][1], maps[0][2]], frames=frames, layout=layout) return fig if __name__ == '__main__': map = request_home_map( fetch_to_date.main(date='2020-03-24', usa_only=False, value=10000)) map.show() print(map)