formatCircoForTable = (c) => {
const resEst = resultats[c];
let min = undefined,
dernierQ = undefined;
for (let q of resEst.qualifies) {
const score = resEst.estimation[q];
if (min && score > min) continue;
min = score;
dernierQ = q;
}
return {
circonscription: getCircoLabel(resEur2024[c]),
code: c,
configuration: resEst.qualifies.join(", "),
"Nombre qualifiés": resEst.qualifies.length,
"Bloc sortant": resEst.sortant,
"Parti NFP": accordNFP[c],
Exprimés: Math.round(resEst.exprimes),
Inscrits: Math.round(resEst.inscrits),
"participation (%)": ((resEst.exprimes / resEst.inscrits) * 100).toFixed(1),
"Dernier qualifié": dernierQ,
"Seuil qualif dernier (%)": (
(resEst.estimation[dernierQ] /
(qualifExpr ? resEst.exprimes : resEst.inscrits)) *
100
).toFixed(1),
"Seuil qualif NFP (%)": resEst.estimation.NFP
? (
(resEst.estimation.NFP /
(qualifExpr ? resEst.exprimes : resEst.inscrits)) *
100
).toFixed(1)
: "",
"NFP (%)": resEst.estimationPourcentage.NFP
? resEst.estimationPourcentage.NFP.toFixed(1)
: "",
"MP (%)": resEst.estimationPourcentage.MP
? resEst.estimationPourcentage.MP.toFixed(1)
: "",
"D (%)": resEst.estimationPourcentage.D
? resEst.estimationPourcentage.D.toFixed(1)
: "",
"REC (%)": resEst.estimationPourcentage.REC
? resEst.estimationPourcentage.REC.toFixed(1)
: "",
"RN (%)": resEst.estimationPourcentage.RN
? resEst.estimationPourcentage.RN.toFixed(1)
: "",
"RN+REC+D/2 (%)":
resEst.estimationPourcentage.RN ||
resEst.estimationPourcentage.REC ||
resEst.estimationPourcentage.D
? (
(resEst.estimationPourcentage.RN || 0) +
(resEst.estimationPourcentage.REC || 0) +
0.5 * (resEst.estimationPourcentage.D || 0)
).toFixed(1)
: "",
"MP+D/2 (%)":
resEst.estimationPourcentage.MP || resEst.estimationPourcentage.D
? (
(resEst.estimationPourcentage.MP || 0) +
0.5 * (resEst.estimationPourcentage.D || 0)
).toFixed(1)
: "",
"NFP+MP*2/3 (%)":
resEst.estimationPourcentage.NFP || resEst.estimationPourcentage.MP
? (
(resEst.estimationPourcentage.NFP || 0) +
((resEst.estimationPourcentage.MP || 0) * 2) / 3
).toFixed(1)
: ""
};
}