Public
Edited
Jul 9, 2024
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
t1_inscrits = (
await aq.loadCSV(
"https://raw.githubusercontent.com/taniki/legislatives-2024/main/lg2024/t1_inscrits.csv"
)
)
.derive({ tour: 1 })
.objects()
Insert cell
t1_resultats = (
await aq.loadCSV(
"https://raw.githubusercontent.com/taniki/legislatives-2024/main/lg2024/t1_resultats.csv"
)
)
.derive({ tour: 1 })
.objects()
Insert cell
t1_resultats_elus = t1_resultats.filter((d) =>
t1_resultats
.filter((d2) => d2.CodCirc2 == d.CodCirc2)
.some((d2) => d2.Elu == "OUI")
)
Insert cell
t1_resultats_elimines = t1_resultats
.filter((d) => d.Elu != "OUI")
.filter(
(d) =>
!t2_resultats.find(
(d2) =>
d2.NumPanneauCand == d.NumPanneauCand && d2.CodCirc2 == d.CodCirc2
)
)
Insert cell
t2_inscrits = (
await aq.loadCSV(
"https://raw.githubusercontent.com/taniki/legislatives-2024/main/lg2024/t2_inscrits.csv"
)
)
.derive({ tour: 2 })
.objects()
Insert cell
t2_resultats = (
await aq.loadCSV(
"https://raw.githubusercontent.com/taniki/legislatives-2024/main/lg2024/t2_resultats.csv"
)
)
.derive({ tour: 2 })
.objects()
Insert cell
final_inscrits = d3.merge([t1_inscrits, t2_inscrits])
Insert cell
final_resultats = d3.merge([t1_resultats_elus, t2_resultats])
Insert cell
candidates_all = d3.merge([
t1_resultats_elus.filter((d) => d.Elu == "OUI"),
t1_resultats_elimines,
t2_resultats
])
Insert cell
data = {
return d3.rollups(
final_resultats,
(d) => ({
voix: d3.sum(d, (c) => c.NbVoix),
candidats: d.length,
sieges: d3.filter(d, (c) => c.Elu == "OUI").length,
inscrits: d3.sum(
d.map(
(c) =>
final_inscrits.find(
(c2) => c2.CodCirc2 == c.CodCirc2 && c2.tour == c.tour
).Inscrits
)
)
}),
(d) => (d.CodNuaCand in groupes ? groupes[d.CodNuaCand] : "Autres")
);
}
Insert cell
exprimes = d3.sum(data, (d) => d[1].voix)
Insert cell
couleurs_mdpt = ({
NFP: "#fc392b",
ENS: "#f0b500",
LR: "#4292c6",
RN: "#662506",
Autres: "#bbb"
})
Insert cell
groupes = ({
UG: "NFP",
ENS: "ENS",
UDI: "ENS",
HOR: "ENS",
LR: "LR",
RN: "RN",
UXD: "RN"
})
Insert cell
default_options = ({
caption:
"source : ministère de l'intérieur · traitement des données et infographie : tam kien duong"
})
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more