src/pages/dashboard.py
def plot_top_countries(df, colors, date):
    """
    Function plots top countries by confirmed, deaths, recovered, active cases.

    :param df: DataFrame
    :param colors: list
    :param date: datetime object
    :return: plotly.figure
    """
    with st.spinner("Rendering chart..."):
        temp = df.groupby("Country_Region").agg({"Confirmed": "sum",
                                                 "Deaths": "sum",
                                                 "Recovered": "sum",
                                                 "Active": "sum"})
        colors = px.colors.qualitative.Prism
        fig = make_subplots(2, 2, subplot_titles=["Top 10 Countries by cases",
                                                  "Top 10 Countries by deaths",
                                                  "Top 10 Countries by recoveries",
                                                  "Top 10 Countries by active cases"])
        fig.append_trace(go.Bar(x=temp["Confirmed"].nlargest(n=10),
                                y=temp["Confirmed"].nlargest(n=10).index,
                                orientation='h',
                                marker=dict(color=colors),
                                hovertemplate='<br>Count: %{x:,.2f}',
                                ),
                         row=1, col=1)

        fig.append_trace(go.Bar(x=temp["Deaths"].nlargest(n=10),
                                y=temp["Deaths"].nlargest(n=10).index,
                                orientation='h',
                                marker=dict(color=colors),
                                hovertemplate='<br>Count: %{x:,.2f}',
                                ),
                         row=2, col=1)

        fig.append_trace(go.Bar(x=temp["Recovered"].nlargest(n=10),
                                y=temp["Recovered"].nlargest(n=10).index,
                                orientation='h',
                                marker=dict(color=colors),
                                hovertemplate='<br>Count: %{x:,.2f}',
                                ),
                         row=1, col=2)

        fig.append_trace(go.Bar(x=temp["Active"].nlargest(n=10),
                                y=temp["Active"].nlargest(n=10).index,
                                orientation='h',
                                marker=dict(color=colors),
                                hovertemplate='<br>Count: %{x:,.2f}'),
                         row=2, col=2)
        fig.update_yaxes(autorange="reversed")
        fig.update_traces(
            opacity=0.7,
            marker_line_color='rgb(255, 255, 255)',
            marker_line_width=2.5
        )
        fig.update_layout(height=800,
                          width=1100,
                          showlegend=False)

    return fig

    Function plots top countries by confirmed, deaths, recovered, active cases.

    :param df: DataFrame
    :param colors: list
    :param date: datetime object
    :return: plotly.figure
    
Function plots top countries by confirmed, deaths, recovered, active cases.
Function plots top countries by confirmed deaths recovered active cases .
def plot_top_countries(df, colors, date):
    with st.spinner("Rendering chart..."):
        temp = df.groupby("Country_Region").agg({"Confirmed": "sum",
                                                 "Deaths": "sum",
                                                 "Recovered": "sum",
                                                 "Active": "sum"})
        colors = px.colors.qualitative.Prism
        fig = make_subplots(2, 2, subplot_titles=["Top 10 Countries by cases",
                                                  "Top 10 Countries by deaths",
                                                  "Top 10 Countries by recoveries",
                                                  "Top 10 Countries by active cases"])
        fig.append_trace(go.Bar(x=temp["Confirmed"].nlargest(n=10),
                                y=temp["Confirmed"].nlargest(n=10).index,
                                orientation='h',
                                marker=dict(color=colors),
                                hovertemplate='<br>Count: %{x:,.2f}',
                                ),
                         row=1, col=1)
        fig.append_trace(go.Bar(x=temp["Deaths"].nlargest(n=10),
                                y=temp["Deaths"].nlargest(n=10).index,
                                orientation='h',
                                marker=dict(color=colors),
                                hovertemplate='<br>Count: %{x:,.2f}',
                                ),
                         row=2, col=1)
        fig.append_trace(go.Bar(x=temp["Recovered"].nlargest(n=10),
                                y=temp["Recovered"].nlargest(n=10).index,
                                orientation='h',
                                marker=dict(color=colors),
                                hovertemplate='<br>Count: %{x:,.2f}',
                                ),
                         row=1, col=2)
        fig.append_trace(go.Bar(x=temp["Active"].nlargest(n=10),
                                y=temp["Active"].nlargest(n=10).index,
                                orientation='h',
                                marker=dict(color=colors),
                                hovertemplate='<br>Count: %{x:,.2f}'),
                         row=2, col=2)
        fig.update_yaxes(autorange="reversed")
        fig.update_traces(
            opacity=0.7,
            marker_line_color='rgb(255, 255, 255)',
            marker_line_width=2.5
        )
        fig.update_layout(height=800,
                          width=1100,
                          showlegend=False)
    return fig
def plot_top_countries ( df , colors , date ) : with st . spinner ( "Rendering chart..." ) : temp = df . groupby ( "Country_Region" ) . agg ( { "Confirmed" : "sum" , "Deaths" : "sum" , "Recovered" : "sum" , "Active" : "sum" } ) colors = px . colors . qualitative . Prism fig = make_subplots ( 2 , 2 , subplot_titles = [ "Top 10 Countries by cases" , "Top 10 Countries by deaths" , "Top 10 Countries by recoveries" , "Top 10 Countries by active cases" ] ) fig . append_trace ( go . Bar ( x = temp [ "Confirmed" ] . nlargest ( n = 10 ) , y = temp [ "Confirmed" ] . nlargest ( n = 10 ) . index , orientation = 'h' , marker = dict ( color = colors ) , hovertemplate = '<br>Count: %{x:,.2f}' , ) , row = 1 , col = 1 ) fig . append_trace ( go . Bar ( x = temp [ "Deaths" ] . nlargest ( n = 10 ) , y = temp [ "Deaths" ] . nlargest ( n = 10 ) . index , orientation = 'h' , marker = dict ( color = colors ) , hovertemplate = '<br>Count: %{x:,.2f}' , ) , row = 2 , col = 1 ) fig . append_trace ( go . Bar ( x = temp [ "Recovered" ] . nlargest ( n = 10 ) , y = temp [ "Recovered" ] . nlargest ( n = 10 ) . index , orientation = 'h' , marker = dict ( color = colors ) , hovertemplate = '<br>Count: %{x:,.2f}' , ) , row = 1 , col = 2 ) fig . append_trace ( go . Bar ( x = temp [ "Active" ] . nlargest ( n = 10 ) , y = temp [ "Active" ] . nlargest ( n = 10 ) . index , orientation = 'h' , marker = dict ( color = colors ) , hovertemplate = '<br>Count: %{x:,.2f}' ) , row = 2 , col = 2 ) fig . update_yaxes ( autorange = "reversed" ) fig . update_traces ( opacity = 0.7 , marker_line_color = 'rgb(255, 255, 255)' , marker_line_width = 2.5 ) fig . update_layout ( height = 800 , width = 1100 , showlegend = False ) return fig
Function plots top countries by confirmed, deaths, recovered, active cases.
Function plots top countries by confirmed deaths recovered active cases .
"""
    Function plots top countries by confirmed, deaths, recovered, active cases.

    :param df: DataFrame
    :param colors: list
    :param date: datetime object
    :return: plotly.figure
    """
None
df
None
colors
None
date
None