Public
Edited
Jan 28, 2024
Insert cell
Insert cell
Insert cell
Insert cell
numbers = Array.from({length: 1000}, (_, i) => i )
Insert cell
Insert cell
curveInterpolate(maxSoFar[0][1])
Insert cell
curveInterpolate = (points) => {
const extent = d3.extent(points, p => p.daynum)
return Array.from({length: extent[1] - extent[0]},(v,k)=> k + extent[0]).map(day => {
const maxScore = d3.max(points.filter((d) => d.daynum <= day), d => d.maxScore);
return {
daynum: day,
maxScore: maxScore
}
})
}
Insert cell
rollingmax = (t) => t.sort((a,b) => a.daynum < b.daynum ? -1 : 1).reduce((agg, cur) => {
if(agg.length == 0) {
return [{daynum: cur.daynum, maxScore: cur.score}]
}
if(cur.score > agg[agg.length - 1].maxScore) {
agg.push({daynum: cur.daynum, maxScore: cur.score});
}
return agg;
}
, [])
Insert cell
maxSoFar = d3.rollups(flatData, v => rollingmax(v), d => d.competition)
Insert cell
flatData = data.flat()
Insert cell
data = Array.from({ length: 100 }, (_, comp) => {
const offset = Math.floor(Math.random() * 1000);
const maxTime = Math.floor(Math.random() * 56) + 42;
const baseline = Math.random()
return Array.from({ length: 100 }, (_, sub) => {
return {
competition: comp,
score: Math.random() * baseline,
daynum: Math.floor(Math.random() * maxTime) + offset,
};
})
})
Insert cell
import {Scrubber} from "@mbostock/scrubber"
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