May 2019
Beginner to intermediate
650 pages
14h 50m
English
In an identity scale, which is created with d3.scaleIdentity(), the domain and range are identical. These scales are useful when you need to call an axis function (which requires a scale function) that uses pixel coordinates. In the following example, values are used to set the circle radii, along a width of 1,000 pixels:
const data = d3.range(0,1001,25);const scale = d3.scaleIdentity() .range(d3.extent(data));d3.select("svg") .attr("cx", d => scale(d));
The result is as follows:

Read now
Unlock full access