Map graph not displayed after deployment

Hi guys
I have used a call back function to switch between two types of maps in my covid 19 dashboard , on my local host it was working well but once I deployed the app it stopped working ,
this is call back function :

@app.callback(
Output(“graph”, “figure”),
Input(“selection”, “value”))
def display_animated_graph(selection):
if selection==‘Trajectory of Pandemic’:

            df_country=df.groupby(['Countrycode','Country','date']).sum().reset_index()
            fig = px.choropleth(df_country, locations="Countrycode", color = "total_cases",
                                    hover_name= "Country",animation_frame=date,
                                    hover_data = df[['total_cases','new_cases','total_deaths']],
                                    color_continuous_scale=px.colors.sequential.Plasma)

            fig.update_layout(transition={'duration':1000},paper_bgcolor='#000000',geo=dict(bgcolor= '#000000'),margin=dict(l=0,r=0,t=0,b=0))
            fig.update_traces(marker_line_color='rgba(255,255,255,0)', selector=dict(type='choroplethmapbox'))
            fig.layout.template='plotly_dark'
 
            
    else:
        
            df_country=df.groupby(['Countrycode','Country']).sum().reset_index()
            yesterdays_date=df['date'].max()
            fig = px.choropleth(df_country, locations="Countrycode", color = "total_cases",
                                    hover_name= "Country",
                                    hover_data = ['total_cases','new_cases','total_deaths'],
                                    projection="orthographic",
                                    color_continuous_scale=px.colors.sequential.OrRd_r)
            fig.update_layout(paper_bgcolor='#000000',geo=dict(bgcolor= '#000000'),
                            title=f"Cumulative Cases since the start of pandemic untill {yesterdays_date}")
            fig.layout.template='plotly_dark'

    return fig

if name==‘main’:
app.run_server(debug=True, port=8000)
the app is available here https://bahageel-corona-covid19-dashboard.onrender.com/
and view my code visit my repo here and help me address this problem
GitHub - Datascientist88/Dash_Dashboard_COVID19_NO_ONE
just what is wrong what my call back function in order to rectify it and learn from my mistake
thanks lovely community

It looks like the update request is timing out after 30s… It is difficult to say exactly why without any info about the deployment environment, but you can try to generate the two plots in the global environment and just switch between them using the callback (they don’t depend on other inputs).

2 Likes

Thank you very much indeed for your kind cooperation and advice I will do exactly what you told me
With best regards

Hi beloved companions at plotly dash community
I would like to thank you very much indeed for your answers ,the problem is solved by just transferring the map plots into a global environment to reduce the load time and the delay that causes call back failure
the code is accessible at my repository on github GitHub - Datascientist88/Dash_Dashboard_COVID19_NO_ONE
and the application is accessible at : https://bahageel-corona-covid19-dashboard.onrender.com/
I would like to take this opportunity and extend my heart_felt gratitude to all plotly community members for their kind cooperation
and special thanks are extended to @jlfsjunior @adamschroeder for their dedication to provide me with all the assistance I asked for
this part I modified in my work :
image
with best regards
Bahageel