D3.js continuous.range() Function Last Updated : 09 Feb, 2021 Comments Improve Suggest changes Like Article Like Report The continuous.range() function in d3.js is used to set the range of the scale to the specified array of values that must contain two or more than two values. The elements in the range can be number or string. Syntax: continuous.range([range]); Parameters: This function accepts a single parameter as mentioned above and described below. [range]: This is an array that contains the range for the domain specified. Return Values: This function does not return anything. Below examples illustrate the D3.js continuous.range() function in JavaScript: Example1: When the range array is of a string of colors. HTML <!DOCTYPE html> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" path1tent="width=device-width, initial-scale=1.0"/> <script src= "https://d3js.org/d3.v4.min.js"> </script> <script src= "https://d3js.org/d3-color.v1.min.js"> </script> <script src= "https://d3js.org/d3-interpolate.v1.min.js"> </script> <script src= "https://d3js.org/d3-scale-chromatic.v1.min.js"> </script> </head> <body style ="text-align: center"> <h2 style="color: green;">Geeksforgeeks</h2> <p>D3.js continuous.range() Function </p> <script> var continuous = d3.scaleLinear() // Domain ranges -1, 0, 1 .domain([-1, 0, 1]) // Range for the domain .range(["red", "green", "blue"]); document.write("<br/>") document.write("<h3>"+continuous(0)+"</h3>"); document.write("<h3>"+continuous(1)+"</h3>"); document.write("<h3>"+continuous(0.5)+"</h3>"); document.write("<h3>"+continuous(-1)+"</h3>"); // Out of domain values document.write("<h3>"+continuous(1.5)+"</h3>"); document.write("<h3>"+continuous(2)+"</h3>"); </script> </body> </html> Output: Example 2: When the range array is of type number. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" path1tent="width=device-width, initial-scale=1.0"/> <script src= "https://d3js.org/d3.v4.min.js"> </script> <script src= "https://d3js.org/d3-color.v1.min.js"> </script> <script src= "https://d3js.org/d3-interpolate.v1.min.js"> </script> <script src= "https://d3js.org/d3-scale-chromatic.v1.min.js"> </script> </head> <body style ="text-align: center"> <h2 style="color: green;">Geeksforgeeks</h2> <p>D3.js continuous.range() Function </p> <script> var continuous = d3.scaleLinear() // Domain ranges -1, 0, 1 .domain([-1, 0, 1]) // Range for the domain .range([1,2,3,4,5,6,7,8,9]); document.write("<br/>") document.write("<h3>"+continuous(0)+"</h3>"); document.write("<h3>"+continuous(1)+"</h3>"); document.write("<h3>"+continuous(0.5)+"</h3>"); document.write("<h3>"+continuous(-1)+"</h3>"); document.write("<h3>"+continuous(1.5)+"</h3>"); document.write("<h3>"+continuous(2)+"</h3>"); </script> </body> </html> Output: Comment More infoAdvertise with us Next Article D3.js continuous.ticks() Function T tarun007 Follow Improve Article Tags : JavaScript Web Technologies D3.js Similar Reads D3.js continuous.rangeRound() Function The continuous.rangeRound() function is used set the range of the scale to the specified array of values. It also sets the interpolator to interpolatorRound. The rounding interpolator may be useful for avoiding antialiasing artifacts. Syntax: continuous.rangeRound( [range] ) Parameters: This functio 3 min read D3.js | d3.continuous() Function The d3.continuous() function in D3.js is used to return the corresponding value from the range if a value from the domain is given.Syntax: d3.continuous().domain(array of values).range(array of values); Parameters: This function does not accept any parameters.Return Value: This function returns the 1 min read D3.js continuous.ticks() Function The continuous.ticks() function is used to return the count values from the scale's domain. If the count is not given as a parameter then by default it is set to 10. The values returned by tick lies in the domain. Syntax: continuous.ticks([count]); Parameters: This function accepts a single paramete 2 min read D3.js continuous.copy() Function The continuous.copy() function is used to create and return an exact copy of the given scale. Any change in the original scale will not affect the return scale and vice-versa. Syntax: continuous.copy(); Parameters: This function does not accept any parameters. Return Value: This function returns a c 2 min read D3.js band.range() Function The band.range() function in D3.js library is used to set the range of the scale to the specified two-element array of numbers. The default value of the range is [0, 1]. Syntax: band.range([range]); Parameters: This function accepts single parameters as given above and described below. range: This p 2 min read D3.js continuous.domain() Function The continuous.domain() function is used to set the scale's domain to the specified array of numbers. The array specified here contains two or more than two elements in it. Syntax: continuous.domain([domain]); Parameters: This function accepts a single parameter as mentioned above and described belo 2 min read Like