Public
Edited
Aug 14, 2024
Importers
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = {
var resultat = []
artworksAPI.data.forEach(artwork => {
//normalise la date pour garder uniquement l'année
if(artwork.produced_at){
artwork.produced_at = artwork.produced_at.substring(0,4)
artwork.year = getYear(artwork.produced_at)
artwork.date = new Date(artwork.produced_at)
}
else
artwork.year = null

//première catégorie (pour visuel dans graphique): à simplifier pour en avoir 7-8 max idéalement

if (artwork.categories == null)
artwork.firstCat = "Inconnue"
else {
if(artwork.categories.fr[0] == "Anamorphose") //on met les anamorphoses avec les murales
artwork.firstCat = "Murale"
else if(artwork.categories.fr[0] == "Relief") //on met les reliefs avec les sculpture
artwork.firstCat = "Sculpture"
else if(artwork.categories == "Relief" || artwork.categories.fr[0] == "Gravure" || artwork.categories.fr[0] == "Multimédia"|| artwork.categories.fr[0] == "Techniques Mixtes" || artwork.categories.fr[0] == "Émail" || artwork.categories.fr[0] == "Céramique")
artwork.firstCat = "Autre"
else
artwork.firstCat = artwork.categories.fr[0]
}
//titre fr, url fr
artwork.titre = artwork.title.fr
artwork.lien = artwork.url ? artwork.url.fr : null;
resultat.push(artwork)
})

return resultat;

}
Insert cell
getYear = d3.timeParse('%Y')
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
formatYear = d3.utcFormat("%x")
Insert cell
indexOfCategories
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
noProducers = data.filter(d => d.producer == null).length
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
indexOfOwners[1].list.filter(d => d.acquisition != null && d.acquisition.fr == "Politique d'intégration des arts à l'architecture et à l'environnement du Gouvernement du Québec")
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
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
annees = {
var resultat = new Set()
data.map(d => {
resultat.add(d.produced_at)
})
return resultat
}
Insert cell
indexOfYears = {
var resultat = []

annees.forEach(o =>{
var current = data.filter(d => d.produced_at == o)
resultat.push({
name: o,
count: current.length,
list: current
})
})
return resultat.sort((a, b) => {
return a.count - b.count;
}).reverse()
}
Insert cell
Insert cell
import {ramp} from "@mbostock/ramp"
Insert cell
Insert cell
artworksAPI = d3.json("https://picasso.iro.umontreal.ca/~mona/api/v3/artworks")
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