Brush Snapping II
✓ Published0🌍 Public
Mmbostock
Last edited Aug 2, 2019
Created on Aug 14, 2013
A time-series brush snaps selections to day boundaries on a date axis. The visualization uses a D3 v4 SVG chart with a horizontal brush, where brushing fires a *brush* event that rounds the selection’s start and end dates to the nearest day. The code uses `d3.brushX` with an `.on("brush")` listener, `d3.event.selection.map(x.invert)`, `d3.timeDay.round`, and `d3.select(this).call(d3.event.target.move, …)` to adjust the brush’s extent. The axis grid highlights hourly ticks with reduced opacity.
AI-generated descriptionThis brush snaps to day boundaries. The brush fires brush events during brushing, allowing a listener to modify the brush selection. Compare this approach to using brush transitions on end.
gpl-3.0 Licensed