Esempio n. 1
0
def map_today_data(usa_only, scale):
    # We should connect the last expensive data querying steps needed to render the graphs with this data

    # Get Today's Date
    date = str(datetime.date.today() - datetime.timedelta(days=1))

    # Create Variable = Async Data Fetch requesting only today's dataframe
    data = fetch_today.main(date=date, value=scale, usa_only=usa_only)

    # Does this graph only want to be focused on the US?
    if usa_only == True:
        usa_only = data['countryRegion'].str.contains('US')
        data = data[usa_only]

    df = data

    print('check df')
    print(df)

    redis_instance.set(
        f'today-dataframe',
        json.dumps(
            df.to_dict(),
            # This JSON Encoder will handle things like numpy arrays
            # and datetimes
            cls=plotly.utils.PlotlyJSONEncoder,
        ),
    )
Esempio n. 2
0
def query_today(usa_only, scale):
    date = str(datetime.date.today() - datetime.timedelta(days=1))

    data = fetch_today.main(date=date, value=scale, usa_only=usa_only)

    if usa_only == True:
        usa_only = data['countryRegion'].str.contains('US')

        data = data[usa_only]

    data['confirmed_size'] = data.loc[:, 'confirmed'].apply(
        lambda x: int(x) / scale)
    data['death_size'] = data.loc[:, 'deaths'].apply(lambda x: int(x) / scale)
    data['recovered_size'] = data.loc[:, 'recovered'].apply(
        lambda x: int(x) / scale)
    print('why you acting up data?')
    print(data)
    print(type(data))
    print(conn.setex('USA_Today', TIMEOUT, zlib.compress(pickle.dumps(data))))
    return conn.setex('USA_Today', TIMEOUT, zlib.compress(pickle.dumps(data)))
Esempio n. 3
0
    layout = go.Layout(height=800,
                       autosize=True,
                       mapbox_accesstoken=token,
                       mapbox_style="stamen-watercolor",
                       mapbox_center={
                           "lat": float(location['geoplugin_latitude'][0]),
                           "lon": float(location['geoplugin_longitude'][0])
                       },
                       paper_bgcolor='rgba(0,0,0,0)',
                       plot_bgcolor='rgba(0,0,0,0)',
                       font=dict(family="Courier New, monospace",
                                 size=18,
                                 color="#7f7f7f"),
                       mapbox=dict(
                           center=dict(
                               lat=float(location['geoplugin_latitude'][0]),
                               lon=float(location['geoplugin_longitude'][0])),
                           pitch=0,
                           zoom=3,
                       ))

    data = [map_confirmed, map_recovered, map_deaths]

    fig = go.Figure(data=data, layout=layout)
    return fig


if __name__ == '__main__':
    data = fetch_today.main(value=1000)
    request_usa_map(data, location=grab_users_geo()).show()
Esempio n. 4
0
def slider_scale_rate(value):

    data = fetch_today.main(value=value, usa_only=True)

    return dcc.Graph(figure=request_usa_map(data), style={'height': '85vh'})