Public
Edited
Mar 22
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//
Insert cell
chartConfig = ({
radiusSize: 20,
padding: 2
})
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
data = fetch(
`https://data.cityofnewyork.us/resource/25th-nujf.json?$limit=2000&$where=rnk <= ${maxRank}&brth_yr=${selectedYear}`
).then((response) => response.json())
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
playNote = note => {
synth.triggerAttackRelease(note, "8n");
}
Insert cell
// Create notes off of name count...
freq = d3
.scaleQuantize()
.domain(d3.extent(data.map(d => d.cnt)))
.range(outNotes)
Insert cell
freqWithKey = key =>
d3
.scaleQuantize()
.domain(d3.extent(data.map(d => d.cnt)))
.range(noteRange(key)(`${key}2`, `${key}8`))
Insert cell
Insert cell
outNotes = noteRange("c")("C2", "C8")
Insert cell
now = Tone.now()
Insert cell
// Create keys based off of categories
key = d3
.scaleQuantize()
.domain(ethnicGroups)
.range(["c", "g", "a", "f"])
Insert cell
frequencyScales = {
let scales = new Map();
for (let group of ethnicGroups) {
console.log(freqWithKey(key(group)));
debugger;
const noteScale = freqWithKey(key(group));
scales.set(group, noteScale);
}
return scales;
}
Insert cell
// Create notes from scale
noteRange = note => Tonal.Scale.rangeOf(`${note.toUpperCase()} major`)
Insert cell
Tonal = import("https://cdn.jsdelivr.net/npm/tonal@6.4.1/+esm")
Insert cell
Insert cell
import { checkbox } from "@jashkenas/inputs"
Insert cell
import {text} from "@jashkenas/inputs"
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