Ajout des détails sur les sources de données #32

This commit is contained in:
Colin Maudry
2025-09-21 11:42:29 +02:00
parent 90af1f6eb4
commit 89a419a8d2
4 changed files with 60 additions and 7 deletions
+45
View File
@@ -2,6 +2,7 @@ import json
import plotly.express as px
import polars as pl
from dash import dash_table, html
def get_map_count_marches(lf: pl.LazyFrame):
@@ -112,3 +113,47 @@ def get_barchart_sources(lf: pl.LazyFrame, type_date: str):
)
return fig
def get_sources_tables(source_path) -> html.Div:
df = pl.read_csv(source_path)
df = df.with_columns(
(
pl.lit('<a href = "')
+ pl.col("url")
+ pl.lit('">')
+ pl.col("nom")
+ pl.lit("</a>")
).alias("nom")
)
df = df.drop("url")
df = df.sort(by=["nb_marchés"], descending=True)
datatable = dash_table.DataTable(
id="source_table",
columns=[
{
"name": i,
"id": i,
"presentation": "markdown",
"type": "text",
"format": {"nully": "N/A"},
}
for i in df.schema.names()
],
style_cell_conditional=[
{
"if": {"column_id": ["nom", "organisation"]},
"minWidth": "350px",
"textAlign": "left",
"overflow": "hidden",
"lineHeight": "14px",
"whiteSpace": "normal",
},
],
sort_action="native",
markdown_options={"html": True},
)
datatable.data = df.to_dicts()
return html.Div(children=datatable)