Page stats avec nb de marchés par département close #21
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -0,0 +1,65 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
|
import plotly.express as px
|
||||||
|
import polars as pl
|
||||||
|
from dash import dcc, html, register_page
|
||||||
|
|
||||||
|
from src.utils import df
|
||||||
|
|
||||||
|
title = "Statistiques"
|
||||||
|
|
||||||
|
register_page(
|
||||||
|
__name__, path="/statistiques", title=f"decp.info - {title}", name=title, order=3
|
||||||
|
)
|
||||||
|
|
||||||
|
df = df.with_columns(
|
||||||
|
pl.col("lieuExecution_code").str.head(2).str.zfill(2).alias("Département")
|
||||||
|
)
|
||||||
|
df = (
|
||||||
|
df.unique(subset="uid")
|
||||||
|
.select(["uid", "Département"])
|
||||||
|
.unique(subset="uid")
|
||||||
|
.group_by("Département")
|
||||||
|
.len("uid")
|
||||||
|
)
|
||||||
|
|
||||||
|
with open("./data/departements-1000m.geojson") as f:
|
||||||
|
departements = json.load(f)
|
||||||
|
|
||||||
|
# Ajout de feature.id
|
||||||
|
for f in departements["features"]:
|
||||||
|
f["id"] = f["properties"]["code"]
|
||||||
|
|
||||||
|
fig = px.choropleth(
|
||||||
|
df,
|
||||||
|
geojson=departements,
|
||||||
|
locations="Département",
|
||||||
|
color="uid",
|
||||||
|
color_continuous_scale="Viridis",
|
||||||
|
title="Nombres de marchés attribués par département (lieu d'exécution)",
|
||||||
|
range_color=(df["uid"].min(), df["uid"].max()),
|
||||||
|
labels={"uid": "Marchés attribués"},
|
||||||
|
scope="europe",
|
||||||
|
width=1000,
|
||||||
|
height=800,
|
||||||
|
)
|
||||||
|
|
||||||
|
fig.update_geos(fitbounds="locations", visible=False)
|
||||||
|
fig.update_layout(
|
||||||
|
mapbox={
|
||||||
|
"style": "carto-positron",
|
||||||
|
"center": {"lon": 10, "lat": 10},
|
||||||
|
"zoom": 1,
|
||||||
|
"domain": {"x": [0, 1], "y": [0, 1]},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
layout = [
|
||||||
|
html.Div(
|
||||||
|
className="container",
|
||||||
|
children=[
|
||||||
|
html.H2(title),
|
||||||
|
html.Div(children=[dcc.Graph(figure=fig)]),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user