Top 10 acheteurs sur les pages titulaire #55
This commit is contained in:
@@ -53,9 +53,10 @@ div.logo > a {
|
||||
|
||||
/* Réduire la taille du texte de la colonne Objet */
|
||||
|
||||
td[data-dash-column="objet"] {
|
||||
/*
|
||||
td[data-dash-column="objet"],td[data-dash-column="titulaire_nom"],td[data-dash-column="acheteur_nom"], {
|
||||
font-size: 85%;
|
||||
}
|
||||
}*/
|
||||
|
||||
/* Couleur des en-têtes */
|
||||
.dash-table-container
|
||||
|
||||
+30
-1
@@ -13,7 +13,7 @@ def get_top_org_table(data, org_type: str):
|
||||
dff_nb = dff.group_by(f"{org_type}_id", f"{org_type}_nom").agg(
|
||||
pl.len().alias("Attributions"), pl.sum("montant").alias("montant")
|
||||
)
|
||||
dff_nb = dff_nb.sort(by="Attributions", descending=True)
|
||||
dff_nb = dff_nb.sort(by="montant", descending=True)
|
||||
dff_nb = dff_nb.cast(pl.String)
|
||||
dff_nb = dff_nb.fill_null("")
|
||||
dff_nb = format_montant(dff_nb, column="montant")
|
||||
@@ -32,4 +32,33 @@ def get_top_org_table(data, org_type: str):
|
||||
page_size=10,
|
||||
columns=columns,
|
||||
tooltip_header=tooltip,
|
||||
style_cell_conditional=[
|
||||
{
|
||||
"if": {"column_id": "objet"},
|
||||
"minWidth": "350px",
|
||||
"textAlign": "left",
|
||||
"overflow": "hidden",
|
||||
"lineHeight": "14px",
|
||||
"whiteSpace": "normal",
|
||||
"fontSize": "85%",
|
||||
},
|
||||
{
|
||||
"if": {"column_id": "acheteur_nom"},
|
||||
"minWidth": "200px",
|
||||
"textAlign": "left",
|
||||
"overflow": "hidden",
|
||||
"lineHeight": "16px",
|
||||
# "fontSize": "85%",
|
||||
"whiteSpace": "normal",
|
||||
},
|
||||
{
|
||||
"if": {"column_id": "titulaire_nom"},
|
||||
"minWidth": "200px",
|
||||
"textAlign": "left",
|
||||
"overflow": "hidden",
|
||||
"lineHeight": "16px",
|
||||
"whiteSpace": "normal",
|
||||
# "fontSize": "85%",
|
||||
},
|
||||
],
|
||||
)
|
||||
|
||||
+17
-1
@@ -3,6 +3,7 @@ import datetime
|
||||
import polars as pl
|
||||
from dash import Input, Output, State, callback, dash_table, dcc, html, register_page
|
||||
|
||||
from src.callbacks import get_top_org_table
|
||||
from src.figures import point_on_map
|
||||
from src.utils import (
|
||||
add_links_in_dict,
|
||||
@@ -91,6 +92,13 @@ layout = [
|
||||
],
|
||||
),
|
||||
html.Div(className="org_map", id="titulaire_map"),
|
||||
html.Div(
|
||||
className="org_top",
|
||||
children=[
|
||||
html.H3("Top acheteurs"),
|
||||
html.Div(className="marches_table", id="top10_acheteurs"),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
# récupérer les données de l'acheteur sur l'api annuaire
|
||||
@@ -161,7 +169,7 @@ def update_titulaire_stats(data):
|
||||
nb_acheteurs = dff.unique("acheteur_id").height
|
||||
nb_acheteurs = [
|
||||
html.Strong(format_number(nb_acheteurs)),
|
||||
" titulaires (SIRET) différents",
|
||||
" acheteurs (SIRET) différents",
|
||||
]
|
||||
del dff
|
||||
|
||||
@@ -266,6 +274,14 @@ def get_last_marches_table(data) -> html.Div:
|
||||
return table
|
||||
|
||||
|
||||
@callback(
|
||||
Output(component_id="top10_acheteurs", component_property="children"),
|
||||
Input(component_id="titulaire_data", component_property="data"),
|
||||
)
|
||||
def get_top_acheteurs(data):
|
||||
return get_top_org_table(data, "acheteur")
|
||||
|
||||
|
||||
@callback(
|
||||
Output("download-titulaire-data", "data"),
|
||||
Input("btn-download-titulaire-data", "n_clicks"),
|
||||
|
||||
+1
-1
@@ -144,7 +144,7 @@ def format_montant(dff: pl.DataFrame, column: str = "montant") -> pl.DataFrame:
|
||||
|
||||
frac: pl.Expr = (
|
||||
pl.when(frac.is_not_null() & ~frac.is_in(["0"]))
|
||||
.then("," + frac)
|
||||
.then("," + frac.str.head(2))
|
||||
.otherwise(pl.lit(""))
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user