fix(observatoire): couleurs barres considérations palette Plotly Safe
Utilise les codes hex #CC6677 (sociales) et #117733 (env) via le prop color de dbc.Progress, qui accepte les valeurs hex. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+3
-4
@@ -769,9 +769,8 @@ def compute_considerations_stats(lff: pl.LazyFrame) -> dict[str, tuple[int, int]
|
|||||||
|
|
||||||
|
|
||||||
CONSIDERATIONS_DISPLAY = [
|
CONSIDERATIONS_DISPLAY = [
|
||||||
# (clé, libellé, couleur Safe)
|
("sociales", "Sociales", "#CC6677"),
|
||||||
("sociales", "Sociales", "rgb(204, 102, 119)"),
|
("environnementales", "Environnementales", "#117733"),
|
||||||
("environnementales", "Environnementales", "rgb(17, 119, 51)"),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -799,7 +798,7 @@ def get_considerations_card_content(lff: pl.LazyFrame) -> html.Div:
|
|||||||
dbc.Progress(
|
dbc.Progress(
|
||||||
value=pct,
|
value=pct,
|
||||||
label=f"{pct} %",
|
label=f"{pct} %",
|
||||||
style={"backgroundColor": color},
|
color=color,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -134,26 +134,25 @@ def test_get_considerations_card_content_returns_two_progress_bars():
|
|||||||
|
|
||||||
assert isinstance(div, html.Div)
|
assert isinstance(div, html.Div)
|
||||||
|
|
||||||
# Récupère récursivement tous les dbc.Progress
|
|
||||||
def find_progress(component, found):
|
def find_progress(component, found):
|
||||||
children = getattr(component, "children", None)
|
|
||||||
if isinstance(component, dbc.Progress):
|
if isinstance(component, dbc.Progress):
|
||||||
found.append(component)
|
found.append(component)
|
||||||
|
children = getattr(component, "children", None)
|
||||||
if isinstance(children, (list, tuple)):
|
if isinstance(children, (list, tuple)):
|
||||||
for c in children:
|
for c in children:
|
||||||
find_progress(c, found)
|
find_progress(c, found)
|
||||||
elif children is not None:
|
elif children is not None and not isinstance(children, str):
|
||||||
find_progress(children, found)
|
find_progress(children, found)
|
||||||
return found
|
return found
|
||||||
|
|
||||||
bars = find_progress(div, [])
|
bars = find_progress(div, [])
|
||||||
assert len(bars) == 2
|
assert len(bars) == 2
|
||||||
|
|
||||||
# Sociales (rouge) : u1 -> 50%. Environnementales (vert) : u2 -> 50%.
|
# Sociales (#CC6677) : u1 -> 50%. Environnementales (#117733) : u2 -> 50%.
|
||||||
social_bar, env_bar = bars[0], bars[1]
|
social_bar, env_bar = bars[0], bars[1]
|
||||||
assert social_bar.value == 50
|
assert social_bar.value == 50
|
||||||
assert social_bar.label == "50 %"
|
assert social_bar.label == "50 %"
|
||||||
assert social_bar.style["backgroundColor"] == "rgb(204, 102, 119)"
|
assert social_bar.color == "#CC6677"
|
||||||
assert env_bar.value == 50
|
assert env_bar.value == 50
|
||||||
assert env_bar.label == "50 %"
|
assert env_bar.label == "50 %"
|
||||||
assert env_bar.style["backgroundColor"] == "rgb(17, 119, 51)"
|
assert env_bar.color == "#117733"
|
||||||
|
|||||||
Reference in New Issue
Block a user