Public
Edited
Dec 12, 2023
Importers
1 star
Insert cell
Insert cell
Insert cell
Insert cell
oeuvresMacAvecGenre
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
Insert cell
oeuvresMacEtudiees = oeuvresMacAvecGenre.filter(d => d.oeuvrePrincipale == null)
Insert cell
oeuvresMacEtudiees1 = oeuvresMacAvecGenre.filter(d => d.oeuvrePrincipale == null)
Insert cell
Insert cell
Insert cell
annees = Array.from(new Set(oeuvresMac.map(d => d.dateAcquisition).sort()))
Insert cell
test2021 = oeuvresMac.filter(d => d.dateAcquisition == 2021)
Insert cell
Insert cell
collections = new Set (oeuvresMac.map(d => d.collection))
Insert cell
testDatesProd = new Set(oeuvresMac.map(d => d.dateProduction))
Insert cell
provenance = new Set(oeuvresMac.map(d => d.provenance))
Insert cell
categorie = new Set(oeuvresMac.map(d => d.categorie))
Insert cell
materiaux = [...new Set(oeuvresMac.map(d => d.materiaux))].sort()
Insert cell
Inputs.table(artistesMac)
Insert cell
cultures = new Set(oeuvresMac.map(d => d.cultures))
Insert cell
departement = new Set(oeuvresMac.map(d => d.departement))
Insert cell
nationalites = new Set(artistesMac.map(d => d.nationalites))
Insert cell
Insert cell
Inputs.table(oeuvresMac)
Insert cell
oeuvresMac.filter(d => d.id === 'hommage-a-rodin' || d.id === 'hommage-a-rodin-cathedrale-hommage-a-rodin')
Insert cell
Insert cell
donneesMandats= d3.csv("https://gist.githubusercontent.com/valentinehda/8514e6d130e840b9be522be0de0bf3c6/raw/ccca36156db53829009d08a4c76d7dee8f380e60/mandats.csv")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function associationGenreAOeuvre(listeArtistes){


//liste des genres des artistes associés à l'œuvre
var genresDesArtistes = []
var categorisation;

//console.log(listeArtistes)
//aller voir combien il y a d'artistes pour cette œuvre
var nbArtistes = listeArtistes.length
// *** Option 1: s'il n'y a qu'un·e artiste ***
if (nbArtistes == 1){
var id = listeArtistes[0].id

//si l'artiste est dans la collection du MAC
if (listeArtistes[0].artisteMac == true)
var artiste = artistesMac.find( d => d.id == id)
else
var artiste = {genre: "Inconnu"}

//tant que le genre n'est pas Collectif, on récupère juste le genre de l'artiste
if (artiste.genre != "Collectif"){
genresDesArtistes.push(artiste.genre)
}
else if (artiste.genre == "Collectif"){
var artistesDuCollectif = artiste.groupeArtistes
artistesDuCollectif.forEach( artisteDuCollectif => {
// pour chaque artiste du collectif
if (artisteDuCollectif.artisteMac == true){
//si c'est artiste du MAC, on récupère son identifiant et on ajoute son genre à la liste des genresDansCollectif
var artisteConcerne = artistesMac.find( d => d.id == artisteDuCollectif.id)
genresDesArtistes.push(artisteConcerne.genre)
}
else
genresDesArtistes.push("Inconnu")
})

}
else
console.log("ATTENTION option 1: problème dans la comptabilisation des genres")
}
else {
// ***Option 2: s'il y a plusieurs artistes***
//pour chaque artiste
listeArtistes.forEach(a => {
//récupérer l'id de l'artiste ou du collectif
var id = a.id
//si l'artiste est dans la collection du MAC
if (a.artisteMac == true){
var artiste = artistesMac.find( d => d.id == id)
//si c'est bien un artiste individuel et non un collectif, on ajoute son genre à la liste
if (artiste.genre != "Collectif"){
genresDesArtistes.push(artiste.genre)
}
else {
// dans le cas où c'est un collectif, on passe à travers de la liste des artistes du collectif (dans la propriété groupeArtistes)
var artistesDuCollectif = artiste.groupeArtistes
artistesDuCollectif.forEach( artisteDuCollectif => {
// pour chaque artiste du collectif
if (artisteDuCollectif.artisteMac == true){
//si c'est artiste du MAC, on récupère son identifiant et on ajoute son genre à la liste des genresDesArtistes
var artisteConcerne = artistesMac.find( d => d.id == artisteDuCollectif.id)
genresDesArtistes.push(artisteConcerne.genre)
}
else
genresDesArtistes.push("Inconnu")
})
}
}
else //si l'artiste n'est pas dans la collection du MAC, on ajoute genre Inconnu
genresDesArtistes.push("Inconnu")
})
}

//comptabilisation des genres
var comptabilisationDesGenres;

//compte le nombre de Féminin, Masculin et Inconnu parmi les artistes
var nbFemmes = genresDesArtistes.filter(d => d == "Féminin").length
var nbHommes = genresDesArtistes.filter(d => d == "Masculin").length
var nbInconnus = genresDesArtistes.filter(d => d == "Inconnu").length
//on vérifie que le décompte est bon
if (genresDesArtistes.length != (nbFemmes+nbHommes+nbInconnus))
console.log("ATTENTION: erreur dans le décompte")
if (genresDesArtistes.length == nbFemmes){
comptabilisationDesGenres = "Féminin"
}
else if (genresDesArtistes.length == nbHommes)
comptabilisationDesGenres = "Masculin"
else if (genresDesArtistes.length == nbInconnus){
comptabilisationDesGenres = "Inconnu"
}
else if (genresDesArtistes.includes("Féminin") && genresDesArtistes.includes("Masculin"))
comptabilisationDesGenres = "Mixte"
else if (genresDesArtistes.includes("Inconnu") && genresDesArtistes.includes("Féminin"))
comptabilisationDesGenres = "Féminin & Inconnu"
else if (genresDesArtistes.includes("Inconnu") && genresDesArtistes.includes("Masculin"))
comptabilisationDesGenres = "Masculin & Inconnu"
else {
console.log("ATTENTION option 2: problème dans la comptabilisation des genres")
console.log(genresDesArtistes)
//il y a une œuvre avec 5 Masculin et 1 Collecif, il faudrait faire une option de plus pour ça, en attendant on met à inconnu
comptabilisationDesGenres = "Masculin & Inconnu"
}
// pas possible qu'il n'y ait que des artistes inconnus
// à partir de la comptabilisation des genres
switch(comptabilisationDesGenres) {
case "Féminin":
categorisation = "Féminin"
break;
case "Féminin & Inconnu":
categorisation = "Féminin"
break;
case "Masculin":
categorisation = "Masculin"
break;
case "Masculin & Inconnu":
categorisation = "Féminin"
break;
case "Mixte":
categorisation = "Mixte"
break;
case "Inconnu":
categorisation = "Inconnu"
break;
}

return categorisation
}
Insert cell
Insert cell
Insert cell
function oeuvresTri3Categories (oeuvresConcernes) {
var resultat = [
{categorie: "1964-1991", genre: "Féminin", nombre: 0},
{categorie: "1964-1991", genre: "Mixte", nombre: 0},
{categorie: "1964-1991", genre: "Masculin", nombre: 0},
{categorie: "1964-1991", genre: "Inconnu", nombre: 0},
{categorie: "1992", genre: "Féminin", nombre: 0},
{categorie: "1992", genre: "Mixte", nombre: 0},
{categorie: "1992", genre: "Masculin", nombre: 0},
{categorie: "1992", genre: "Inconnu", nombre: 0},
{categorie: "1993-2020", genre: "Féminin", nombre: 0},
{categorie: "1993-2020", genre: "Mixte", nombre: 0},
{categorie: "1993-2020", genre: "Masculin", nombre: 0},
{categorie: "1993-2020", genre: "Inconnu", nombre: 0},
];
oeuvresConcernes.forEach(oeuvre => {
if (oeuvre.dateAcquisition < 1992) {
switch(oeuvre.genreAssocie) {
case "Féminin":
resultat[0].nombre += 1
break;
case "Mixte":
resultat[1].nombre += 1
break;
case "Masculin":
resultat[2].nombre += 1
break;
case "Inconnu":
resultat[3].nombre += 1
break;
}
}
else if (oeuvre.dateAcquisition == 1992){
switch(oeuvre.genreAssocie) {
case "Féminin":
resultat[4].nombre += 1
break;
case "Mixte":
resultat[5].nombre += 1
break;
case "Masculin":
resultat[6].nombre += 1
break;
case "Inconnu":
resultat[7].nombre += 1
break;
}
}
else if (oeuvre.dateAcquisition > 1992){
switch(oeuvre.genreAssocie) {
case "Féminin":
resultat[8].nombre += 1
break;
case "Mixte":
resultat[9].nombre += 1
break;
case "Masculin":
resultat[10].nombre += 1
break;
case "Inconnu":
resultat[11].nombre += 1
break;
}
}

})
var totalPre1992 = resultat[0].nombre+resultat[1].nombre+resultat[2].nombre+resultat[3].nombre;
var total1992 = resultat[4].nombre+resultat[5].nombre+resultat[6].nombre+resultat[7].nombre;
var totalPost1992 = resultat[8].nombre+resultat[9].nombre+resultat[10].nombre+resultat[11].nombre;

resultat[0].pourcentage = resultat[0].nombre*100/totalPre1992;
resultat[1].pourcentage = resultat[1].nombre*100/totalPre1992;
resultat[2].pourcentage = resultat[2].nombre*100/totalPre1992;
resultat[3].pourcentage = resultat[3].nombre*100/totalPre1992;
resultat[4].pourcentage = resultat[4].nombre*100/total1992;
resultat[5].pourcentage = resultat[5].nombre*100/total1992;
resultat[6].pourcentage = resultat[6].nombre*100/total1992;
resultat[7].pourcentage = resultat[7].nombre*100/total1992;
resultat[8].pourcentage = resultat[8].nombre*100/totalPost1992;
resultat[9].pourcentage = resultat[9].nombre*100/totalPost1992;
resultat[10].pourcentage = resultat[10].nombre*100/totalPost1992;
resultat[11].pourcentage = resultat[11].nombre*100/totalPost1992;
return resultat;
}
Insert cell
Insert cell
Insert cell
import {couleurs} from "26cecfbef9723965"
Insert cell
import {palette10couleurs} from "26cecfbef9723965"
Insert cell
import {toc} from "@lenamk/toc"
Insert cell
oeuvresMacAvecGenre
Type SQL, then Shift-Enter. Ctrl-space for more options.

Insert cell
oeuvresMac
Type SQL, then Shift-Enter. Ctrl-space for more options.

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