Transition API in D3.js

The term transition helps you to animate the transition of DOM (Document Object Model) component from one state to another. The transitions methods can be applied to change the property for smooth transitions for stated time duration. The D3 transitions choose the components and apply a transition to a current element.

Configuration of Transition API

You can configure the Transition API as shown in below script.

Methods of Transition API

In the D3.js, the transition API methods are divided into two following types.

  • Selection Methods 
  • Timing Methods

Now, we will discuss each method category in detail.

Selection Method

In this category, we have some selection element methods explained below.


It can be applied to return a new selection transition with the name. If you don’t specify the name of transition then it will return the empty value.


This method helps you to brake off the chosen transition elements with their names. It is described in below code.


This method can be applied to return a new transition containing the stated name.

d3.interrupt(node[, name])

It can be applied to interrupt the transition of the stated name over to a described node.

This method allows you to select the first element and compare it with the defined selector. It also returns a transition on the output selection. It is explained below.


This method can be applied to combine the two given transitions. It is defined below.


If you want to choose the transition elements equivalent to the defined filter, then you need to apply this method. It is shown in below code.


It can be applied to return a new transition on the selected components. This method executes when the transition stops. After it, the new transition contains the properties of the last transition such as duration, name, and the easing.

For Example

Here, we have an example to understand the following concept.[, name])

This method can be used, if you want to return the transition with the name over to a defined node.

Timing Method

In this category, we have some timing methods that are explained below.


This method can be applied to fix the duration of the transition for a described value. If the value is undefined, then it will return the existing first value of the transition.


You can apply this method while easing the transition values of chosen elements. This method is invoked for animation frames. It goes through the normalize time denoted by ‘t’ for {0, 1} range. If you don’t define the value of the function, then it will return the existing function for the primary element.


It can be applied to fix the transition delay to the values. When a function is calculated for the components, then the function can be passed from the existing datum “d” and index “i” with the DOM element. If you don’t define the value, it returns the existing value of the first delay component.

It is explained in the below code.

Pin It on Pinterest

Share This