Published
Edited
May 24, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
bisect = {
const bisect = d3.bisector(d => d.x).left; // Assumes your data has an "x" field
return mx => {
const domainX = x.invert(mx); // Assumes you have an x scale function
const index = bisect(data, domainX, 1);
const a = data[index - 1];
const b = data[index];
if (!b) { return a; } // Prevents errors mousing over right edge of chart
return domainX - a.x > b.x - domainX ? b : a; // Assumes your data has an "x" field
};
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
plotAreaWidth = width - margin.left - margin.right
Insert cell
plotAreaHeight = height - margin.top - margin.bottom
Insert cell
Insert cell
d3 = require("d3@5", "d3-delaunay@5")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data[0]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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