The d3.scalePow() function is used to create and return a new continuous scale. This scale has a specified domain and range. Generally, it acts as a linear scale but when used with exponent it works in a different way.
Syntax:
d3.scalePow([[domain, ]range]);
Parameters: This function accepts two parameters as mentioned above and described below.
- domain: This parameter always accepts two or more than two numbers.
- range: This parameter accepts a number or a string array.
Return Values: This function does not return anything.
Below examples illustrate the scalePow() function in D3.js:
Example 1:
HTML
<!DOCTYPE html> <html lang="en"> Â Â <head> Â Â Â Â <meta charset="UTF-8" /> Â Â Â Â <meta name="viewport" path1tent= Â Â Â Â Â Â Â Â "width=device-width,initial-scale=1.0"/> Â Â Â Â </script> Â Â Â Â <script src= Â Â Â Â </script> Â Â Â Â <script src= Â Â Â Â </script> Â Â Â Â <script src= Â Â Â Â </script> </head> Â Â <body> Â Â Â Â <h2 style="color:green;">Geeks for neveropen</h2> Â Â Â Â Â Â <p>d3.scalePow() Function </p> Â Â Â Â Â Â <script> Â Â Â Â Â Â Â Â var pow = d3.scalePow() Â Â Â Â Â Â Â Â Â Â Â Â .domain([0, 1]) Â Â Â Â Â Â Â Â Â Â Â Â .range([1, 2, 3, 4, 5, 6]); Â Â Â Â Â Â Â Â Â Â document.write("<h3> pow(1): " Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â + pow(1) + "</h3>"); Â Â Â Â Â Â Â Â document.write("<h3>pow(2): "Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â + pow(2) + "</h3>"); Â Â Â Â Â Â Â Â document.write("<h3>pow(3): "Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â + pow(3) + "</h3>"); Â Â Â Â </script> </body> Â Â </html> |
Output:
Example 2:
HTML
<!DOCTYPE html> <html lang="en"> Â Â <head> Â Â Â Â <meta charset="UTF-8" /> Â Â Â Â <meta name="viewport" path1tent= Â Â Â Â Â Â Â Â "width=device-width,initial-scale=1.0"/> Â Â Â Â </script> Â Â Â Â <script src= Â Â Â Â </script> Â Â Â Â <script src= Â Â Â Â </script> Â Â Â Â <script src= Â Â Â Â </script> </head> Â Â <body> Â Â Â Â <h2 style="color:green;">Geeks for neveropen</h2> Â Â Â Â Â Â <p>d3.scalePow() Function </p> Â Â Â Â Â Â <script> Â Â Â Â Â Â Â Â var pow = d3.scalePow() Â Â Â Â Â Â Â Â Â Â Â Â .domain([0, 1]) Â Â Â Â Â Â Â Â Â Â Â Â .range([1, 2, 3, 4, 5, 6]) Â Â Â Â Â Â Â Â Â Â Â Â .exponent(4); Â Â Â Â Â Â Â Â Â Â document.write("<h3> pow(1): " Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â + pow(1) + "</h3>"); Â Â Â Â Â Â Â Â document.write("<h3>pow(2): "Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â + pow(2) + "</h3>"); Â Â Â Â Â Â Â Â document.write("<h3>pow(3): "Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â + pow(3) + "</h3>"); Â Â Â Â </script> </body> Â Â </html> |
Output:

