liveBook · Manning

Easing

As explained in D3.js in Action, Third Edition

An easing function controls the rate at which an animated interpolation progresses over time.

An easing function controls how an animated interpolation changes over time. Instead of moving at a constant rate, a transition can start slowly, accelerate, decelerate, overshoot, or bounce, making chart updates feel more natural. section 7.2.4

Customize a D3 transition by choosing:

  • duration(), measured in milliseconds; D3 uses 250 ms by default. section 7.2.4
  • delay(), measured in milliseconds; the default delay is 0. section 7.2.4
  • ease(), which selects the transition’s rate of change. D3 includes quadratic, cubic, exponential, sinusoidal, circle, polynomial, elastic, overshoot, and bounce behaviors. section 7.2.4
d3.selectAll("#histogram rect")
  .data(updatedBins)
  .transition()
    .duration(500)
    .ease(d3.easeCubicOut)
    .attr("y", d => yScale(d.length))
    .attr("height", d => innerHeight - yScale(d.length));

Apply easing to a histogram update by placing ease() after transition parameters and before the animated attributes. Only properties chained after transition() are animated. section 7.2.4

How D3.js in Action, Third Edition covers it

How deep it goes
Compares easing curves and demonstrates duration, delay, and ease configuration, without developing their mathematical formulas.
Examples
Uses an updating histogram, comparative easing graphs, and D3 examples including d3.easeCubicOut.
What you can do after
Apply easing via D3’s ease() method when building animated data visualizations.
How it connects
Connects easing with D3 transitions, CSS easing terminology, animation timing, and visual properties such as position, color, and opacity.

Also explained in

Compare how 2 books explain easing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of D3.js in Action, Third Edition. The section links point to the parts of the book it draws on.