D3.js | d3.scaleBand() Function Last Updated : 30 Jul, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The d3.scaleBand() function in D3.js is used to construct a new band scale with the domain specified as an array of values and the range as the minimum and maximum extents of the bands. This function splits the range into n bands where n is the number of values in the domain array. Syntax: d3.scaleBand().domain(array of values).range(array of values); Parameters: This function does not accept any parameters. Return Value: This function returns the corresponding range for the domain's value. Below programs illustrate the d3.scaleBand() function in D3.js: Example 1: javascript <!DOCTYPE html> <html> <head> <title> D3.js | d3.scaleBand() Function </title> <script src = "https://d3js.org/d3.v4.min.js"> </script> </head> <body> <script> // Calling the scaleBand() function var A = d3.scaleBand() .domain(['January', 'February', 'March', 'April', 'May']) .range([10, 50]); // Getting the corresponding range for // the domain value console.log(A('January')); console.log(A('February')); console.log(A('March')); console.log(A('April')); console.log(A('May')); </script> </body> </html> Output: 10 18 26 34 42 Example 2: javascript <!DOCTYPE html> <html> <head> <title> D3.js | d3.scaleBand() Function </title> <script src = "https://d3js.org/d3.v4.min.js"> </script> </head> <body> <script> // Calling the scaleBand() function var A = d3.scaleBand() .domain(['January', 'February', 'March', 'April', 'May']) .range([1, 2]); // Getting the corresponding range for // the domain value console.log(A('January')); console.log(A('February')); console.log(A('March')); console.log(A('April')); console.log(A('May')); </script> </body> </html> Output: 1 1.2 1.4 1.6 1.8 Reference: https://devdocs.io/d3~5/d3-scale#scaleBand Comment More infoAdvertise with us Next Article D3.js | d3.scaleBand() Function K Kanchan_Ray Follow Improve Article Tags : JavaScript Web Technologies D3.js Similar Reads D3.js | d3.scaleIdentity() Function The d3.scaleIdentity() function in D3.js is used to construct a new identity scale with the unit domain [0, 1] and the unit range [0, 1].Syntax: d3.scaleIdentity().domain(array of values).range(array of values); Parameters: This function does not accept any parameters.Return Value: This function ret 1 min read D3.js scalePoint() Function The d3.scalepoint() function is used to create and return a new point scale with a particular domain and range, no rounding, no padding, and center alignment. Syntax: d3.scalePoint([[domain, ]range]); Parameters: This function takes two parameters as given above and described below: domain: It defin 2 min read D3.js axis.scale() Function The d3.axis.scale() Function in D3.js is used to sets the scale and return the axis. If this function is not provided with a specified scale, returns the current scale. Syntax: axis.scale([scale]) Parameters: This function accepts only a single parameter as mentioned above and described below: scale 2 min read D3.js scaleQuantize() Function The d3.scaleQuantize() function in d3.js is used to create a new scale that is similar to linear scales except that linear scales use a discrete and dis-continuous scale. Syntax: d3.scaleQuantize(); Parameters: This function does not accept any parameter. Return Value: A function is returned by d3.s 2 min read D3.js scaleQuantile() Function The d3.scaleQuantile() function in D3.js is used to create and return a new quantile scale that has the specified domain and range. In case the domain or the range is not specified, each value is set to empty array by default. Syntax: d3.scaleQuantile( domain, range ) Parameters: This function accep 2 min read Like