Published
Edited
Aug 31, 2020
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
data = {
let offset = 0;
const pages = [];
while (true) {
const page = await d3.csv(`${url}?$limit=50000&$offset=${offset}`);
pages.push(page);
if (page.length === 0) break;
offset += page.length;
}
return pages.flat();
}
Insert cell
data[0]
Insert cell
filtered = data.filter((d => d.fiscal_year == year && (revOrSpend === "All" ? true : d.revenue_or_spending === revOrSpend)))
.map(d => ({...d, per_capita_budget: d.budget/population }))
Insert cell
population = 881500 // San Francisco's 2019 population, roughly
Insert cell
Insert cell
Insert cell
vl.markBar()
.data(filtered)
.encode(
vl.y().fieldN('organization_group').sort('-x'),
vl.x().sum('per_capita_budget')
)
.render()
Insert cell
Insert cell
import { vl } from '@vega/vega-lite-api'
Insert cell
import { select } from '@jashkenas/inputs'
Insert cell
d3 = require('d3-fetch')
Insert cell
import { twitch } from '@codingwithfire/twitch'
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