import pandas as pd
import plotly.express as px

# Data for top 10 countries by GDP (2023 est. in trillions USD) - Source: IMF
data = {
    'Country': ['USA', 'China', 'Germany', 'Japan', 'India', 'UK', 'France', 'Italy', 'Brazil', 'Canada'],
    'GDP (Trillions USD)': [26.95, 17.70, 4.43, 4.24, 3.70, 3.33, 3.05, 2.19, 2.13, 2.12]
}

df_gdp = pd.DataFrame(data)

# Create a pie chart
fig = px.pie(df_gdp,
             values='GDP (Trillions USD)',
             names='Country',
             title='Top 10 Countries by GDP (2023 Est.)',
             hover_name='Country',
             hover_data={'GDP (Trillions USD)': ':.2f'},
             color_discrete_sequence=px.colors.sequential.RdBu) # You can change the color sequence here

# Update layout to hide the Plotly mode bar
fig.update_layout(
    title_x=0.5,
    hoverlabel=dict(bgcolor="white", font=dict(size=12, family="Arial")),
    margin=dict(l=20, r=20, t=60, b=20)
)

# Disable mode bar by setting config
config = {
    'displayModeBar': False
}

# Display the chart without the mode bar
fig.show(config=config)

# Save the chart as an HTML file
fig.write_html("top_10_gdp_pie_chart.html", include_plotlyjs='cdn', config=config)

print("Pie chart saved as 'top_10_gdp_pie_chart.html'")