src/pages/dashboard.py
def plot_timeline(df, feature, country=None):
    """
    Function plots  time series charts for worldwide as well as countries
    :param df: DataFrame
    :param feature: str
    :param country: str
    :return: plotly.figure, DataFrame
    """
    color = px.colors.qualitative.Prism
    if country:
        df = df[df["Country/Region"] == country]
    temp = df.groupby(["Date"]).agg({feature: "sum"}).reset_index()
    temp["Delta_{}".format(feature)] = temp[feature].diff()
    temp["Delta_{}".format(feature)].clip(0, inplace=True)

    fig = make_subplots(2, 1, subplot_titles=["Cumulative {}".format(feature),
                                              "Daily Delta {}".format(feature)])
    fig.add_trace(go.Scatter(
        x=temp["Date"],
        y=temp[feature],
        marker=dict(color=color[2]),
        line=dict(dash="dashdot", width=4),
        hovertemplate='Date: %{x} <br>Count: %{y:,.2f}',
    ),
        row=1, col=1)
    fig.add_trace(go.Bar(
        x=temp["Date"],
        y=temp["Delta_{}".format(feature)],
        marker=dict(color=color[6]),
        opacity=0.7,
        hovertemplate='Date: %{x} <br>Count: %{y:,.2f}'),
        row=2, col=1)
    fig.update_yaxes(showgrid=False, title="Number of cases")
    fig.update_xaxes(showgrid=False)
    fig.update_xaxes(showspikes=True, row=1, col=1)
    fig.update_yaxes(showspikes=True, row=1, col=1)
    fig.update_layout(height=800,
                      showlegend=False)

    return fig, temp

    Function plots  time series charts for worldwide as well as countries
    :param df: DataFrame
    :param feature: str
    :param country: str
    :return: plotly.figure, DataFrame
    
Function plots  time series charts for worldwide as well as countries
Function plots time series charts for worldwide as well as countries
def plot_timeline(df, feature, country=None):
    color = px.colors.qualitative.Prism
    if country:
        df = df[df["Country/Region"] == country]
    temp = df.groupby(["Date"]).agg({feature: "sum"}).reset_index()
    temp["Delta_{}".format(feature)] = temp[feature].diff()
    temp["Delta_{}".format(feature)].clip(0, inplace=True)
    fig = make_subplots(2, 1, subplot_titles=["Cumulative {}".format(feature),
                                              "Daily Delta {}".format(feature)])
    fig.add_trace(go.Scatter(
        x=temp["Date"],
        y=temp[feature],
        marker=dict(color=color[2]),
        line=dict(dash="dashdot", width=4),
        hovertemplate='Date: %{x} <br>Count: %{y:,.2f}',
    ),
        row=1, col=1)
    fig.add_trace(go.Bar(
        x=temp["Date"],
        y=temp["Delta_{}".format(feature)],
        marker=dict(color=color[6]),
        opacity=0.7,
        hovertemplate='Date: %{x} <br>Count: %{y:,.2f}'),
        row=2, col=1)
    fig.update_yaxes(showgrid=False, title="Number of cases")
    fig.update_xaxes(showgrid=False)
    fig.update_xaxes(showspikes=True, row=1, col=1)
    fig.update_yaxes(showspikes=True, row=1, col=1)
    fig.update_layout(height=800,
                      showlegend=False)
    return fig, temp
def plot_timeline ( df , feature , country = None ) : color = px . colors . qualitative . Prism if country : df = df [ df [ "Country/Region" ] == country ] temp = df . groupby ( [ "Date" ] ) . agg ( { feature : "sum" } ) . reset_index ( ) temp [ "Delta_{}" . format ( feature ) ] = temp [ feature ] . diff ( ) temp [ "Delta_{}" . format ( feature ) ] . clip ( 0 , inplace = True ) fig = make_subplots ( 2 , 1 , subplot_titles = [ "Cumulative {}" . format ( feature ) , "Daily Delta {}" . format ( feature ) ] ) fig . add_trace ( go . Scatter ( x = temp [ "Date" ] , y = temp [ feature ] , marker = dict ( color = color [ 2 ] ) , line = dict ( dash = "dashdot" , width = 4 ) , hovertemplate = 'Date: %{x} <br>Count: %{y:,.2f}' , ) , row = 1 , col = 1 ) fig . add_trace ( go . Bar ( x = temp [ "Date" ] , y = temp [ "Delta_{}" . format ( feature ) ] , marker = dict ( color = color [ 6 ] ) , opacity = 0.7 , hovertemplate = 'Date: %{x} <br>Count: %{y:,.2f}' ) , row = 2 , col = 1 ) fig . update_yaxes ( showgrid = False , title = "Number of cases" ) fig . update_xaxes ( showgrid = False ) fig . update_xaxes ( showspikes = True , row = 1 , col = 1 ) fig . update_yaxes ( showspikes = True , row = 1 , col = 1 ) fig . update_layout ( height = 800 , showlegend = False ) return fig , temp
Function plots  time series charts for worldwide as well as countries
Function plots time series charts for worldwide as well as countries
"""
    Function plots  time series charts for worldwide as well as countries
    :param df: DataFrame
    :param feature: str
    :param country: str
    :return: plotly.figure, DataFrame
    """
None
df
None
feature
None
country
None