Skip to content

Commit

Permalink
[tg] - ajout %déchets dans graph par secteurs
Browse files Browse the repository at this point in the history
  • Loading branch information
tgazagnes committed May 29, 2024
1 parent 4c048eb commit f7dc00c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dashboards/app/pages/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,11 @@ def french_format(x: int) -> str:
top_secteur_df["Nombre de déchets"] = top_secteur_df[
"Nombre de déchets"
].astype(int)
# Calcul du pourcentage
top_secteur_df["Pourcentage"] = (
top_secteur_df["Nombre de déchets"]
/ top_secteur_df["Nombre de déchets"].sum()
)

# Data pour le plot responsabilités
rep_df = duckdb.query(
Expand Down Expand Up @@ -1304,6 +1309,7 @@ def french_format(x: int) -> str:
y="Secteur",
color="Secteur",
title="Top 10 des secteurs économiques identifiés dans les déchets comptés",
hover_data=["Pourcentage"],
labels={
"Nombre de déchets": "Nombre total de déchets (échelle logarithmique)",
},
Expand Down Expand Up @@ -1331,7 +1337,7 @@ def french_format(x: int) -> str:

# Paramétrage de l'infobulle
fig_secteur.update_traces(
hovertemplate="Secteur : <b>%{y}</b><br> Quantité : <b>%{x:,.0f} déchets</b>"
hovertemplate="Secteur : <b>%{y}</b><br> Quantité : <b>%{x:,.0f} déchets</b><br> Part du total déchets : <b>%{customdata[0]:.0%}</b>"
)

with st.container(border=True):
Expand Down Expand Up @@ -1405,7 +1411,7 @@ def french_format(x: int) -> str:
textfont=dict(size=16),
hovertemplate="%{label}<br>"
+ "Quantité de déchets : <b>%{value:,.0f}</b><br>"
+ "<b>Part du total ramassé : %{percentRoot:.1%}</b>",
+ "Part des déchets catégorisés : <b>%{percentRoot:.1%}</b>",
)

with st.container(border=True):
Expand Down

0 comments on commit f7dc00c

Please sign in to comment.