def update_graph1(selected_state):
    """Return a graph

    Update state graph with selected state
    """
    states.set_state(selected_state)

    # Preparing Data
    cases = helper.Confirmed(selected_state)

    trace1 = go.Scatter(x=cases.get_dates_since_start(),
                        y=cases.get_total_state_cases_over_time(),
                        mode='lines',
                        name='Cases')
    data = [trace1]
    state_graph = {
        'data':
        data,
        'layout':
        go.Layout(title='Total number of Confirmed Cases in ' +
                  cases.get_state_name(),
                  xaxis={'title': 'Date'},
                  yaxis={'title': 'Number of confirmed cases'})
    }
    return state_graph
def update_graph2(selected_state, selected_county):
    """Return a graph

    Update county graph with selected state and county
    """
    cases = helper.Confirmed(selected_state)
    states.set_state(selected_state)

    cases.set_county(selected_county)
    trace1 = go.Scatter(x=cases.get_dates_since_start(),
                        y=cases.get_county_cases_over_time(),
                        mode='lines',
                        name='Cases')
    data = [trace1]
    county_graph = {
        'data':
        data,
        'layout':
        go.Layout(title='Total number of Confirmed Cases in ' +
                  cases.get_county_name() + ' County, ' +
                  cases.get_state_name(),
                  xaxis={'title': 'Date'},
                  yaxis={'title': 'Number of confirmed cases'})
    }

    return county_graph
def update_figure(selected_state):

    states.set_state(selected_state)

    cases = helper.Confirmed(selected_state)

    trace1 = go.Scatter(x=cases.get_all_counties_unsorted(),
                        y=cases.get_all_counties_total_cases_unsorted(),
                        text=cases.get_county_name(),
                        mode='markers')

    data = [trace1]

    scatter_plot = {
        'data':
        data,
        'layout':
        go.Layout(title='Cases by County in ' + cases.get_state_name(),
                  xaxis={'title': 'County Name'},
                  yaxis={'title': 'Number of confirmed cases'})
    }

    return scatter_plot
def update_graph1(selected_state):
    """Return a graph

    Update state graph with selected state
    """
    states.set_state(selected_state)

    # Preparing Data
    cases = helper.Confirmed(selected_state)

    trace1 = go.Bar(x=cases.get_dates_since_start(),
                    y=cases.get_daily_state_cases(),
                    name='Cases')
    data = [trace1]
    state_graph = {
        'data':
        data,
        'layout':
        go.Layout(title='New Daily Confirmed Cases in ' +
                  cases.get_state_name(),
                  xaxis={'title': 'Date'},
                  yaxis={'title': 'Number of confirmed cases'})
    }
    return state_graph
from navbar import Navbar
from Plots import helper

with urlopen(
        'https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json'
) as response:
    counties = json.load(response)

cases = pd.read_csv("Datasets/time_series_covid19_confirmed_US.csv",
                    dtype={"FIPS": str})
deaths = pd.read_csv("Datasets/time_series_covid19_deaths_US.csv",
                     dtype={"FIPS": str})

nav = Navbar()

LATEST_DATE = helper.Confirmed(
    "North Carolina").get_latest_data_date()  # state doesn't matter

FIPS = []
# Remove extra zeroes from FIPS
for code in deaths['FIPS']:
    code = str(code)
    split_num = code.split(".", 1)
    FIPS.append(split_num[0].zfill(5))


def calculate_cases_ratio():
    ratios = []
    for i in range(deaths[LATEST_DATE].__len__()):
        if deaths['Population'][i] != 0:
            ratio = cases[LATEST_DATE][i] / (deaths['Population'][i] / 10000)
            rounded_ratio = math.ceil(ratio * 100) / 100
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import pandas as pd
import plotly.graph_objs as go
from Plots import helper
from navbar import Navbar
from app import app

nav = Navbar()

states = helper.States()
states.set_state("North Carolina")

date_for_graph = helper.Confirmed("North Carolina").get_latest_data_date()

# Line Chart Layout
line_chart_layout = html.Div(
    className='graph-layout',
    children=[
        # Layout for Line Graph
        html.A(id='total-deaths-state-county'),
        html.H1(children='Deaths from COVID-19 in Each State and County',
                style={
                    'textAlign': 'center',
                    'color': 'white'
                }),
        html.H3('Interactive Line chart', style={'color': 'white'}),
        html.Div(
            'This chart represents the total number of confirmed deaths in a state'