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

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