Published
Edited
Feb 27, 2020
1 star
Insert cell
Insert cell
Insert cell
grouped = d3.groups(incidents, d => d.district)
Insert cell
rolledup = d3.rollups(incidents, values => d3.sum(values, d => d.count), d => d.district)
Insert cell
Insert cell
districts = sorted.map(d => d[0])
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
const bars = d3.select(barChart)
.select("g#bars")
.selectAll("rect")
.data(sorted);
const lines = d3.select(lineChart)
.select("g#lines")
.selectAll("path")
.data(grouped);
const debug = html`<p>${bars.size()} bars selected</p>`;

// TODO
return debug;
}
Insert cell
{
const bars = d3.select("svg#bar-chart")
.select("g#bars")
.selectAll("rect")
.data(sorted);
const lines = d3.select("svg#line-chart")
.select("g#lines")
.selectAll("path")
.data(grouped);
const debug = html`<p>${lines.size()} lines selected</p>`;
// TODO
return debug;
}
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

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