HomeLanguagesJavascriptD3.js pow.exponent() Function

D3.js pow.exponent() Function

The pow.exponent() function is used to specify the exponent to the given value. It returns the current exponent when the exponent is not specified. The value of the current exponent defaults to one.

Syntax:

pow.exponent( exponent )

Parameters: This function accepts one parameter as mentioned above and described below.

  • exponent: This parameter accepts a numeric value that sets the current exponent to the given value. It is an optional value.

Return Values: This function does not return anything.

The program below illustrates the pow.exponent() function in D3.js:

Example 1:

HTML




<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" 
        content="width=device-width,
                 initial-scale=1.0" />
  <title>neveropen</title>
  <script src=
  </script>
  <script src=
  </script>
  <script src=
  </script>
  <script src=
  </script>
</head>
<body>
  <script>
    var pow = d3.scalePow()
      .domain([10, 20])
      .range(["1", "2", "3", "4", "5"])
      .exponent(2);
  
    console.log("The value of pow(10) is: " + pow(10));
    console.log("The value of pow(12) is: " + pow(12));
    console.log("The value of pow(13) is: " + pow(13));
    console.log("The value of pow(14) is: " + pow(14));
  </script>
</body>
</html>


Output:

Example 2:

HTML




<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" 
        content="width=device-width,
                 initial-scale=1.0" />
  <title>neveropen</title>
  <script src=
  </script>
  <script src=
  </script>
  <script src=
  </script>
  <script src=
  </script>
</head>
<body>
  <script>
    var pow = d3.scalePow()
      .domain([-1, 1])
      .range([10, 20, 30, 40, 50])
      .exponent(10);
  
    console.log("The value of pow(-1) is: " + pow(-1));
    console.log("The value of pow(0) is: " + pow(0));
    console.log("The value of pow(1) is: " + pow(1));
  </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

2 COMMENTS

Most Popular

Dominic
32548 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6922 POSTS0 COMMENTS
Nicole Veronica
12037 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12143 POSTS0 COMMENTS
Shaida Kate Naidoo
7057 POSTS0 COMMENTS
Ted Musemwa
7296 POSTS0 COMMENTS
Thapelo Manthata
7014 POSTS0 COMMENTS
Umr Jansen
7001 POSTS0 COMMENTS