Public
Edited
Feb 28, 2024
Insert cell
Insert cell
Insert cell
seattleZipCodes = FileAttachment("zip-codes-2015.geojson").json()
Insert cell
seattleHousePricesByZipCode = FileAttachment("SeattleHousePricesByZipCode2017.csv").csv({typed: true})
Insert cell
seattleNeighborhoodsTopojson = FileAttachment("City_Clerk_Neighborhoods-1.topojson").json()
Insert cell
seattleCensusTracts2020 = FileAttachment("Census_2020_Tracts_with_PL_94-171_Redistricting__Data_for_1990-2020.topojson").json()
Insert cell
seattleNeighborhoodsGeojson = FileAttachment("City_Clerk_Neighborhoods.geojson").json()
Insert cell
Insert cell
// start here!
{
const zipCodeSelector = vl.selectPoint('selected_point')
.on('mouseover')
.clear('mousehover');

const map = vl.markGeoshape()
.data(vl.json(seattleZipCodes).property('features'))
.params(zipCodeSelector)
.project(vl.projection('identity').reflectY(true))
.encode(
vl.color().fieldO('properties.GEOID10').legend({column:3, title: "Seattle Zip Codes", symbolLimit: 100}),
vl.opacity().if(zipCodeSelector, vl.value(0.9)).value(0.1),
vl.tooltip().fieldN('properties.GEOID10')
)
.width(500).height(600)

return map.render()
}
Insert cell
// start here!
{
const interval = vl.selectInterval()
const hist = vl.markBar()
.data(vl.topojson(seattleCensusTracts2020).feature('collection'))
.encode(
vl.x().fieldQ('properties.F2020_PL_data_TOT_POP').bin({step:200}),
vl.y().aggregate('count')
)
.width(500).height(600);

const map = vl.markGeoshape()
.data(vl.topojson(seattleCensusTracts2020).feature('collection'))
.params(interval)

.project(vl.projection('mercator').reflectY(true))
.encode(
vl.color().fieldQ('properties.F2020_PL_data_TOT_POP').legend({columns:3, title: "Seattle Census", symbolLimit: 100}),
vl.opacity().if(interval, vl.value(1)).value(0.1)
)
.width(500).height(600)
return vl.hconcat(hist, map).render()
}
Insert cell
Insert cell
import {vl} from "@vega/vega-lite-api-v5"
Insert cell
import {toc} from "@jonfroehlich/collapsible-toc"
Insert cell
import {printVegaLiteJSON} from "@jonfroehlich/vega-lite-utilities"
Insert cell
import {printTable} from "@jonfroehlich/data-utilities"
Insert cell
import {printTableTypes} from "@jonfroehlich/data-utilities"
Insert cell
import {vegalite} from "@jonfroehlich/vega-lite-utilities"
Insert cell
// for later, ignore for now
// const sharedTransforms = [
// vl.calculate("geoCentroid(null, datum.geometry)").as('centroid'),
// vl.calculate("datum.centroid[0]").as('centroidX'),
// vl.calculate("datum.centroid[1] + random()/200").as('centroidY'), // also added y jitter
// vl.filter("datum.properties.S_HOOD != 'OOO' && length(trim(datum.properties.S_HOOD)) > 0")]; //filter out 'OOO' & empty neighborhoods
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