Friday, July 24, 2026
HomeLanguagesJavascriptD3.js scalePow() Function

D3.js scalePow() Function

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 src="https://d3js.org/d3.v4.min.js">
    </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 src="https://d3js.org/d3.v4.min.js">
    </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:

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

4 COMMENTS

Most Popular

Dominic
32520 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6902 POSTS0 COMMENTS
Nicole Veronica
12017 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12115 POSTS0 COMMENTS
Shaida Kate Naidoo
7023 POSTS0 COMMENTS
Ted Musemwa
7265 POSTS0 COMMENTS
Thapelo Manthata
6980 POSTS0 COMMENTS
Umr Jansen
6971 POSTS0 COMMENTS