Skip to content

Instantly share code, notes, and snippets.

View nickbenes's full-sized avatar

Nick Benes nickbenes

  • Leesburg, VA
View GitHub Profile
@nickbenes
nickbenes / README.md
Last active January 7, 2016 19:58 — forked from mbostock/.block
Brush Snapping with varying timespans

Tweaks to http://bl.ocks.org/mbostock/6232537 that adds data-driven timespans to the widget. This version allows timespans of varying sizes. It also modifies the brushend listener to log information based on the timespans where the brush's endpoints are located.

This brush snaps to day boundaries. When the user releases the brush, the brush fires a brushend event, allowing a listener to adjust the brush extent. Using the new brush transitions released in D3 3.3, the brush smoothly interpolates from the original extent to the rounded extent. Compare this approach to using immediate snapping while brushing.