Published
Edited
Apr 8, 2020
1 fork
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
timeParse = d3.timeParse("%d/%m/%Y")
Insert cell
filters = ["Explore", "Announce", "Exit", "Presumptive"];
Insert cell
chartData = csvData.map((d, idx) => {
var dates = [];
for(let i = 0; i < filters.length; i++) {
if(d[filters[i]] !== "") {
dates.push([timeParse(d[filters[i]]), idx + 1, i]);
}
}
return {
candidate: d.Candidate,
dates
};
});
Insert cell
csvData = d3.tsvParse(`Candidate Explore Announce Exit Presumptive
Biden 25/04/2019 08/04/2020
Sanders 19/02/2019 08/04/2020
Gabbard 11/01/2019 19/03/2020
Warren 31/12/2018 09/02/2019 05/03/2020
Bloomberg 24/11/2019 04/03/2020
Klobuchar 10/02/2019 02/03/2020
Buttigieg 23/01/2019 14/04/2019 01/03/2020
Steyer 09/07/2019 29/02/2020
Patrick 14/11/2019 12/02/2020
Yang 06/11/2017 11/02/2020
Bennet 02/05/2019 11/02/2020
Delaney 28/07/2017 31/01/2020
Booker 01/02/2019 13/01/2020
Williamson 15/11/2018 28/01/2019 10/01/2020
Castro 12/12/2018 12/01/2019 02/01/2020
Harris 21/01/2019 03/12/2019
Bullock 14/05/2019 02/12/2019
Sestak 23/06/2019 01/12/2019
Messam 13/03/2019 28/03/2019 19/11/2019
O’Rourke 14/03/2019 01/11/2019
Ryan 04/04/2019 24/10/2019
de Blasio 16/05/2019 20/09/2019
Gillibrand 15/01/2019 17/03/2019 28/08/2019
Moulton 22/04/2019 23/08/2019
Inslee 01/03/2019 21/08/2019
Hickenlooper 04/03/2019 15/08/2019
Gravel 19/03/2019 02/04/2019 06/08/2019
Swalwell 08/04/2019 08/07/2019
Ojeda 11/11/2018 25/01/2019`)
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