Public
Edited
Sep 24, 2021
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
bisect = {
const bisect = d3.bisector(d => d.test).left;
return mx => {
const date = xBisect.invert(mx);
const index = bisect(data, date, 1);
const a = data[index - 1];
const b = data[index];
return b && (date - a.date > b.date - date) ? b : a;
};
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = d3.csvParse(await FileAttachment("avgTerm@1.csv").text(), ({term, House, Senate, test}) => ({term: term, house: +House, senate: +Senate, test: +test}))
Insert cell
d3 = require("d3@6.7")
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