Public
Edited
Apr 6, 2024
1 star
Insert cell
Insert cell
Insert cell
Insert cell
oeuvresVilleMTL
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
oeuvresVilleMTL = oeuvres.filter(d => d.owner == "Ville de Montréal")
Insert cell
Insert cell
Insert cell
oeuvresBAP = {
var resultat = []
bap_donneesouvertes.forEach(d => {
var art = {
title : d.Titre,
}

if (d.DateFinProduction != null){
var prod = d.DateFinProduction.replace("/Date(", '').replace(")/", '')
var time = d3.timeParse("%Q%Z")(String(prod))
if (time == null){
//tried counting the days but not sure how to substract (using miliseconds?)
//var posTime = d3.timeParse("%Q%Z")(String(prod.slice(1))) //remove the minus and get the positive value
//var days = d3.timeDay.count(d3.timeParse("%Q")(0), posTime) //get the number of days since UNIX epoch

//tried changing string time zone to :00 to use js → new Date() as it accepts negative values
//console.log("prod", prod)
//var test = prod.replace('-(\d)(\d)00', '-$1$2:00') //doesn't work but maybe just move last two chars and add ':00'
//console.log("test", test)
//-126298800000-0500
//console.log(test)

art.dateProduction = 1900 //1900 en attendant
}else{
art.dateProduction = time
}
} else {
art.dateProduction = null
}
if (d.DateAccession!=null){
var acqu = d.DateAccession.replace("/Date(", '').replace(")/", '')
art.dateAcquisition = d3.timeParse("%Q%Z")(String(acqu))
} else {
art.dateAcquisition = null
}
resultat.push(art)
})
return resultat
}
Insert cell
d3.timeParse("%Q")(0)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
oeuvresBAP.filter(d => d.dateAcquisition != null && d.dateProduction == null)
Insert cell
test = {
var result = []

oeuvresBAP.forEach(d => {
if (d.dateProduction != null)
d.date = d.dateProduction
else
d.date = null

result.push(d)
})
return result.filter(d => d.date == null)
}
Insert cell
bap_donneesouvertes
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
bap_donneesouvertes = FileAttachment("BAP_donneesouvertes.json").json()
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