def update_ratio_bar(min_seq):
    data = call_full_data()
    data = data.loc[data['Date'] == data['Date'].max()]
    data = data.loc[data['total_sequence'] > min_seq].sort_values(
        by=['case_sequence_ratio'])
    case_sequence_ratio_bar = create_case_sequence_ratio_bar_fig(data)
    return case_sequence_ratio_bar
def update_bar(log_radio, min_seq, sort_radio_selection):
    data = call_full_data()
    data = data.loc[data['Date'] == data['Date'].max()]
    data = data.loc[data['total_sequence'] > min_seq].sort_values(
        by=sort_radio_selection)
    bar_fig = create_double_bar_fig(data)
    bar_fig.update_xaxes(type=log_radio)
    return bar_fig
def update_map_line(ClickData, log_radio_line, checklist,
                    case_sequence_checklist):
    data = call_full_data()
    try:
        data = data.loc[data['iso3'] == ClickData['points'][0]['location']]
        fig = create_time_series_country(data)
    except:
        mask = data.continent.isin(checklist)
        fig = create_time_series_continent(data[mask], case_sequence_checklist)
    fig.update_yaxes(type=log_radio_line)
    fig.update_layout(transition_duration=500)
    #try:print(ClickData['points'][0]['location'])
    #except: print('unable to print')
    return fig
from dash.dependencies import Input, Output, State
import plotly.express as px
#My functions
from figures.map_figs import create_case_sequence_scatter_mapbox_fig
from figures.line_figs import create_time_series_country, create_time_series_continent
from figures.bar_figs import create_double_bar_fig, create_case_sequence_ratio_bar_fig
from pipeline.call_data import call_full_data
#############

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.title = 'Covid-19 Dashboard'

px.set_mapbox_access_token(open('mapbox_key.txt').read())
all_continents = call_full_data()['continent'].unique()
data = call_full_data()

app.layout = html.Div([

    #BANNER
    html.Div([
        html.H2("COVID SEQUENCING DASHBOARD"),
        html.Img(src="/assets/covid_image.png")
    ],
             className="banner"),
    html.
    P("This interactive Dashboard aims to provide visualization for global COVID-19 sequencing coverage. This dashboard is fully interactive and easily customizable. A full writeup can be found at the following link: "
      ),
    dcc.Link('github.com/choldener/Vector-Engineering-Project',
             href='https://github.com/choldener/Vector-Engineering-Project'),
Beispiel #5
0
    #     )
    # fig.update_layout(mapbox_style="carto-positron",
    #                   mapbox_zoom=1, mapbox_center={"lat": 37.0902, "lon": -95.7129}, 
    #                   width = 1800, height=1000
    #     )
    # fig2 = px.scatter_mapbox(data, lat = 'Lat', lon = 'Long_', size = 'total_sequence_scale',)
    # fig2.update_traces(hovertemplate=None, hoverinfo='skip')
    # fig.add_trace(
    #     fig2.data[0]
    #       )
    
    return fig



df = call_full_data()
df = df.loc[df['Date'] == df['Date'].max()]









app.layout = html.Div(children=[

    dcc.Graph(
        id='debug-plot',
        figure=create_cases_map_fig(df)
def create_case_sequence_scatter_mapbox_fig(relayout_data=None):
    """Creates bar graph with cases represented as color and a bubble representing sequences"""
    #DATA GATHERING
    data = call_full_data()
    data = data.loc[data['Date'] == data['Date'].max()]
    data = data.loc[data['total_sequence'] > 0].sort_values(
        by=['total_sequence'])
    #geojson
    with urlopen(
            'https://raw.githubusercontent.com/johan/world.geo.json/master/countries.geo.json'
    ) as response:
        countries = json.load(response)

    #RELAY DATA
    if relayout_data == None:
        center_lat = 27
        center_lon = 0
        map_zoom = .75
    else:
        center_lat = float(relayout_data['mapbox.center']['lat'])
        center_lon = float(relayout_data['mapbox.center']['lon'])
        map_zoom = float(relayout_data['mapbox.zoom'])

    #Colored mapbox creation
    fig = px.choropleth_mapbox(data,
                               geojson=countries,
                               locations='iso3',
                               color=np.log10(data['Cases']),
                               color_continuous_scale=px.colors.sequential.Jet,
                               opacity=0.75,
                               mapbox_style='light',
                               width=900,
                               height=600,
                               hover_name="Country",
                               hover_data={
                                   'Lat': False,
                                   'Long_': False,
                                   'total_sequence': True,
                                   'Cases': True,
                                   'iso3': False
                               },
                               zoom=map_zoom,
                               center=dict(
                                   lat=center_lat,
                                   lon=center_lon,
                               ))
    fig.update_layout(coloraxis_colorbar=dict(title='Cases',
                                              tickvals=[
                                                  -1,
                                                  np.log10(1000),
                                                  np.log10(10000),
                                                  np.log10(100000),
                                                  np.log10(1000000),
                                                  np.log10(10000000)
                                              ],
                                              ticktext=[
                                                  '0', '1,000', '10,000',
                                                  '100,000', '1,000,000',
                                                  '10,000,000'
                                              ]),
                      clickmode='event+select')

    #Bubble mapbox creation
    fig2 = px.scatter_mapbox(data,
                             lat='Lat',
                             lon='Long_',
                             size='total_sequence_scale',
                             size_max=70,
                             zoom=map_zoom,
                             center=dict(lat=center_lat, lon=center_lon),
                             mapbox_style='light',
                             width=1800,
                             height=1000,
                             opacity=0.5)
    fig2.update_traces(hovertemplate=None, hoverinfo='skip')

    #adding bubble mapbox data to color mapbox
    fig.add_trace(fig2.data[0])
    return fig