Published
Edited
Dec 10, 2020
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// FileAttachment("provincal_data@6.csv")
FileAttachment("provincial_data@2.csv")
Insert cell
// data = d3.csvParse(await FileAttachment("provincal_data@6.csv").text(), d3.autoType)
data = d3.csvParse(await FileAttachment("provincial_data@2.csv").text(), d3.autoType)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function getCorrectDate(y,m,d, date) {
if (date.getHours() < 12) {
return (y + '-' + two(m+1) + '-' + two(d))
} else if ([0,2,4,6,7,9,11].includes(m) && d == 31) {
return (y + '-' + two(m+2) + '-' + two(1))
} else if ([3,5,8,10].includes(m) && d == 30) {
return (y + '-' + two(m+2) + '-' + two(1))
} else if (m == 1 && date.getFullYear() % 4 == 0 && d == 29) {
return (y + '-' + two(m+2) + '-' + two(1))
} else if (m == 1 && date.getFullYear() % 4 != 0 && d == 28) {
return (y + '-' + two(m+2) + '-' + two(1))
} else {
return (y + '-' + two(m+1) + '-' + two(d+1))
}


return (y + '-' + two(m+1) + '-' + two(d+1))
}
Insert cell
date = new Date(getCorrectDate(timeScale.invert(scrubber).getFullYear(), timeScale.invert(scrubber).getMonth(), timeScale.invert(scrubber).getDate(), timeScale.invert(scrubber)))
// date = new Date(getCorrectDate(tempDate))
Insert cell
function getData(data, province_id, date) {
return data.filter(function(row) {
return row.date.getTime() === date.getTime() && row.iso_3166_2_code == province_id;
}).map(d => d[chosen_category])
}
Insert cell
getData(data, 'CA-MB', date)
Insert cell
Insert cell
Insert cell
format = d => d[0] != null ? `${d}%` : 'N/A'
Insert cell
surprise_format = d => d[0] != null ? `${parseFloat(d).toFixed(8)}` : 'N/A'
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
FileAttachment("province_surprise_data@5.csv")
Insert cell
surprise_data = d3.csvParse(await FileAttachment("province_surprise_data@5.csv").text(), d3.autoType)
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

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