31 lines
754 B
Python
31 lines
754 B
Python
# pastille.py
|
|
|
|
from typing import Any
|
|
|
|
PASTILLE_ICONS = {
|
|
"vert": "✅",
|
|
"orange": "🔶",
|
|
"rouge": "🔴"
|
|
}
|
|
|
|
def pastille(indice: str, valeur: Any, seuils: dict = None) -> str:
|
|
try:
|
|
import streamlit as st
|
|
seuils = seuils or st.session_state.get("seuils", {})
|
|
if indice not in seuils:
|
|
return ""
|
|
|
|
seuil = seuils[indice]
|
|
vert_max = seuil["vert"]["max"]
|
|
rouge_min = seuil["rouge"]["min"]
|
|
val = float(valeur)
|
|
|
|
if val < vert_max:
|
|
return PASTILLE_ICONS["vert"]
|
|
elif val > rouge_min:
|
|
return PASTILLE_ICONS["rouge"]
|
|
else:
|
|
return PASTILLE_ICONS["orange"]
|
|
except (KeyError, ValueError, TypeError):
|
|
return ""
|