Published
Edited
Dec 19, 2018
Importers
Insert cell
Insert cell
Insert cell
loadTimetable = (url) => {
let x = 42
return d3.tsv(url)
.then ((tsOrig) => {
// Change column names ("." inherited from the R world) and turn some text fields into numbers.
let columns = _.keys(tsOrig[0]);
let colNewNames = {}
_.each(columns, (c)=>{
if(c.indexOf('.') >0){
colNewNames[c] = c.replace(/\./g, '_');
}
});

// transform the row element names accordingly to the mapping defained above
// transform numerical fields
let ts = _.map(tsOrig,
(rOrig) => {
let r = _.clone(rOrig)
_.each(colNewNames,
(newName, oldName) => {
r[newName]=r[oldName]
delete r[oldName]
})
r.trip_distance = +r.trip_distance
r.h_departure_time = +r.h_departure_time
r.next_trip_distance = +r.next_trip_distance
r.next_h_arrival_time = +r.next_h_arrival_time
r.q80_next_delta_arrival_min = +r.q80_next_delta_arrival_min
return r
})

return ts
})
}
Insert cell
Insert cell
dimensions = {
return {
overall: {
height: 400,
width: 800
},
margins:{
left: 100,
right: 10,
top: 10,
bottom: 30
}
}
}
Insert cell
newSVG = () => {
return d3.select(DOM.svg(dimensions.overall.width, dimensions.overall.height));
}

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