Public
Edited
Apr 10, 2024
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dataSelecteur = {
var resultat = []

colonnes.forEach(c => resultat.push({
name: c,
value: 0
}))
var total = 0;

//filtrer pour garder des œuvres des années concernées par le sélecteur
//exclut les œuvres qui n'ont pas de temporalité
var oeuvresEnCours = oeuvres.filter(an => an.produced_at >= selecteurIntervalleTemps[0] && an.produced_at <= selecteurIntervalleTemps[1])
//filtrer pour garder la catégorie
/*
switch(selectType){
case "Dons":
oeuvresEnCours = oeuvresEnCours.filter(d => d.numero.substring(0,1) == "D")

break;

case "Achats":
oeuvresEnCours = oeuvresEnCours.filter(d => d.numero.substring(0,1) == "A")
break;

case "Tous":
break;
}*/
oeuvresEnCours.forEach(oeuvre => {
total += 1

switch(oeuvre.genreSimplifie) {
case "féminin":
resultat.find(d => d.name == "artistesFemmes").value += 1
break;
case "non binaire":
resultat.find(d => d.name == "artistesNonBinaires").value += 1
break;
case "masculin":
resultat.find(d => d.name == "artistesHommes").value += 1
break;
case "inconnu":
resultat.find(d => d.name == "artistesInconnus").value += 1
break;
case "collectif":
resultat.find(d => d.name == "collectifs").value += 1
break;
case "mixte":
resultat.find(d => d.name == "artistesMixtes").value += 1
break;
default: console.log("ATTENTION : il reste un autre cas: " + oeuvre.genreSimplifie)
}

})
// retourne le résultat sans les valeurs vides, ainsi que le total
var resultat = [resultat.filter(d => d.value != 0), total]

return resultat
}
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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more