![]() |
VOOZH | about |
The d3.range() function in D3.js is used to return an array containing an arithmetic progression starting from the start parameter and iterated over a sequence of uniformly-spaced numeric value called a step and ends with a stop parameter.
Syntax:
d3.range(start, stop, step)
Parameters: This function accepts three parameter which are illustrated below:-
Return Value: It returns an array containing an arithmetic progression.
Below programs illustrate the d3.range() function in D3.js.
Example 1:
Output:
[0,1,2,3] [10,20,30,40,50,60,70,80,90] [5,10,15,20,25,30,35,40,45] [1,3,5,7,9]
Example 2:
Output:
1 [10,11,12,13,14,15,16,17,18,19] [0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5] [1,1.9,2.8,3.7,4.6,5.5,6.4,7.3,8.2,9.1]
Note:In the above code, some range() functions did not take step value so its default value is considered as 1.
Reference: https://devdocs.io/d3~5/d3-array#range