L'affichage des résultats par région/département/circonscription/commune/bureau de vote est fonctionnel
This commit is contained in:
parent
eb5a112c36
commit
5cc10f3106
@ -17,6 +17,10 @@ function App() {
|
|||||||
path: "/elections/europeennes/2024/region/:zoneId/",
|
path: "/elections/europeennes/2024/region/:zoneId/",
|
||||||
element: <Elections2024 typeResultats="regions" />,
|
element: <Elections2024 typeResultats="regions" />,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/elections/europeennes/2024/circonscription/:zoneId/",
|
||||||
|
element: <Elections2024 typeResultats="circonscriptions" />,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/elections/europeennes/2024/departement/:zoneId/",
|
path: "/elections/europeennes/2024/departement/:zoneId/",
|
||||||
element: <Elections2024 typeResultats="departements" />,
|
element: <Elections2024 typeResultats="departements" />,
|
||||||
@ -25,6 +29,10 @@ function App() {
|
|||||||
path: "/elections/europeennes/2024/commune/:zoneId/",
|
path: "/elections/europeennes/2024/commune/:zoneId/",
|
||||||
element: <Elections2024 typeResultats="communes" />,
|
element: <Elections2024 typeResultats="communes" />,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/elections/europeennes/2024/bureau_vote/:zoneId/",
|
||||||
|
element: <Elections2024 typeResultats="bureaux_vote" />,
|
||||||
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
|
@ -17,7 +17,7 @@ import {useEffect, useState} from "react"
|
|||||||
highchartsItem(Highcharts)
|
highchartsItem(Highcharts)
|
||||||
|
|
||||||
function ResultatsTable({blocs, nuances, listes, resultats, siegesParListe}) {
|
function ResultatsTable({blocs, nuances, listes, resultats, siegesParListe}) {
|
||||||
const voix_listes = resultats.voix_listes
|
const voix_listes = resultats?.voix_listes ?? {}
|
||||||
const listes_triees = listes.toSorted((l1, l2) => {
|
const listes_triees = listes.toSorted((l1, l2) => {
|
||||||
return (voix_listes[l2.numero] || 0) - (voix_listes[l1.numero] || 0)
|
return (voix_listes[l2.numero] || 0) - (voix_listes[l1.numero] || 0)
|
||||||
})
|
})
|
||||||
@ -117,6 +117,7 @@ function ParticipationTable({resultats}) {
|
|||||||
export default function Election2024({typeResultats = "france"}) {
|
export default function Election2024({typeResultats = "france"}) {
|
||||||
const {zoneId} = useParams()
|
const {zoneId} = useParams()
|
||||||
|
|
||||||
|
const [zoneName, setZoneName] = useState("France")
|
||||||
const [grouperParBloc, setGrouperParBloc] = useState(false)
|
const [grouperParBloc, setGrouperParBloc] = useState(false)
|
||||||
const [retirerSeuil, setRetirerSeuil] = useState(false)
|
const [retirerSeuil, setRetirerSeuil] = useState(false)
|
||||||
const [blocs, setBlocs] = useState([])
|
const [blocs, setBlocs] = useState([])
|
||||||
@ -150,6 +151,23 @@ export default function Election2024({typeResultats = "france"}) {
|
|||||||
}
|
}
|
||||||
}, [typeResultats, zoneId])
|
}, [typeResultats, zoneId])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!resultats || resultats.length === 0)
|
||||||
|
setZoneName("")
|
||||||
|
else if (typeResultats === "france")
|
||||||
|
setZoneName("France")
|
||||||
|
else if (typeResultats === "regions")
|
||||||
|
setZoneName(`Région ${resultats.region.nom}`)
|
||||||
|
else if (typeResultats === "departements")
|
||||||
|
setZoneName(`Département ${resultats.departement.nom}`)
|
||||||
|
else if (typeResultats === "circonscriptions")
|
||||||
|
setZoneName(`Circonscription ${resultats.circonscription.nom}`)
|
||||||
|
else if (typeResultats === "communes")
|
||||||
|
setZoneName(`Commune ${resultats.commune.nom}`)
|
||||||
|
else if (typeResultats === "bureaux_vote")
|
||||||
|
setZoneName(resultats.bureau_vote.libelle)
|
||||||
|
}, [typeResultats, resultats])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const parBloc = {}
|
const parBloc = {}
|
||||||
const parNuance = {}
|
const parNuance = {}
|
||||||
@ -301,7 +319,7 @@ export default function Election2024({typeResultats = "france"}) {
|
|||||||
type: 'column'
|
type: 'column'
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
text: 'Résultats des élections européennes 2024 en France',
|
text: `Résultats des élections européennes 2024 : ${zoneName}`,
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
labelFormat: '{name} <span style="opacity: 0.4">{x}</span>'
|
labelFormat: '{name} <span style="opacity: 0.4">{x}</span>'
|
||||||
|
@ -317,7 +317,9 @@ def exporter_resultats_bureaux_vote(engine: Engine, verbose: bool = False) -> No
|
|||||||
|
|
||||||
iterator = tqdm(bureaux_vote, desc="Bureaux de vote") if verbose else bureaux_vote
|
iterator = tqdm(bureaux_vote, desc="Bureaux de vote") if verbose else bureaux_vote
|
||||||
for bureau_vote in iterator:
|
for bureau_vote in iterator:
|
||||||
bureau_vote_json = {'id': bureau_vote.id, 'commune': bureau_vote.commune_code}
|
bureau_vote_json = {'id': bureau_vote.id,
|
||||||
|
'commune': bureau_vote.commune_code,
|
||||||
|
'circonscription': bureau_vote.circo_code}
|
||||||
bureaux_vote_json.append(bureau_vote_json)
|
bureaux_vote_json.append(bureau_vote_json)
|
||||||
|
|
||||||
resultats_bureau_vote = session.execute(
|
resultats_bureau_vote = session.execute(
|
||||||
|
Loading…
Reference in New Issue
Block a user