Published
Edited
16 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dms = {
let dimensions = {
width: width,
height: width * 0.6,
marginTop: 175
};

dimensions.marginLeft = dimensions.marginTop;
dimensions.marginBottom = dimensions.marginTop;
dimensions.marginRight = dimensions.marginTop;

dimensions.chartWidth =
dimensions.width - dimensions.marginLeft - dimensions.marginRight;
dimensions.chartHeight =
dimensions.height - dimensions.marginTop - dimensions.marginBottom;

return dimensions;
}
Insert cell
colors = {
return { blue: "#0A9CE5", orange: "#FF7121" };
}
Insert cell
Insert cell
data = {
const attached = await FileAttachment("DEMO@4.csv").text();

return d3.csvParse(attached);
}
Insert cell
dataByID = d3.group(data, d => d["ID"])
Insert cell
dataGeoJSON = {
const features = [];

data
.filter(e => Math.abs(+e["Lat"]) > 0 && e["Start"].length > 0)
.map(d => {
features.push({
type: "Feature",
geometry: {
type: "Point",
coordinates: [+d["Long"], +d["Lat"]]
},
properties: {}
});

return d;
});

const output = {
type: "FeatureCollection",
features: features
};

return output;
}
Insert cell
Insert cell
vectors = {
const buildings = await FileAttachment("Buildings@2.geojson").json();
const roads = await FileAttachment("Roads@2.geojson").json();
const sidewalks = await FileAttachment("Sidewalks@2.geojson").json();

return { buildings: buildings, roads: roads, sidewalks: sidewalks };
}
Insert cell
extent = await FileAttachment("Zoom.geojson").json()
Insert cell
projection = d3
.geoMercator()
.fitExtent(
[
[dms.marginLeft, dms.marginTop],
[dms.width - dms.marginRight, dms.height - dms.marginBottom]
],
dataGeoJSON
)
Insert cell
path = d3.geoPath(projection)
Insert cell
Insert cell
mouseenter = function(event, d) {
d3.select(".tooltip").text(
`Video ID: ${d["ID"]}, Start Time: ${d["Start"]}, Licensed: ${
d["Licensed"] ? "Yes" : "No"
}`
);

d3.selectAll(".video").attr("fill", colors.blue);

d3.select(this)
.attr("fill", colors.orange)
.raise();
}
Insert cell
Insert cell
mouseleave = function(event, d) {
// d3.select(".tooltip").text(
// "Hover over a vantage point for additional info."
// );
// d3.select(this)
// .attr("fill", colors.blue)
// .raise();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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