Skip to main content
100%

Gist 6311048

✓ Published0🌍 Public
Aalanmclean
Last edited Aug 22, 2013
Created on Aug 22, 2013

A D3.js visualization demonstrates post-selection for customizing axis elements, even during animated transitions. The example shows a time-series chart with a currency-formatted y-axis and dashed gridlines, where axis text labels are repositioned after rendering via `selectAll("text")`. When the y-axis domain transitions from $1 million to $3 million, the code uses `transition.tween` with null values to cancel default attribute tweens, allowing the custom label offsets to persist. The SVG rendering uses `d3.svg.axis` with linear and time scales, and the animation runs over 2.5 seconds.

AI-generated description

This example demonstrates the use of post-selection to customize an axis, even across transitions. After the axis is rendered, its elements (such as text labels, here) are reselected and modified to produce the desired appearance. When transitioning the axis, the post-selection modifies entering, updating and exiting elements. Passing null values to transition.tween cancels default tweens scheduled by the axis in favor of the customized styles.

Similar vizzes