Related Articles

Related Articles

D3.js pow.domain() Function
  • Last Updated : 23 Aug, 2020

The pow.domain() function is used to set the scale’s domain to the specified array of numbers. The array specified here must contain two or more than two elements.

Syntax:

pow.domain([domain]);

Parameters: This function takes a single parameter that is given above and described below.

  • [domain]: An array that takes two or more values that specify the domain.

Return Value: This function does not return any value.

Example 1:



HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>
</head>
  
<body>
    <script>
        var pow = d3.scalePow()
          
            // Setting domain for the scale.
            .domain([10, 20])
            .range(["1", "2", "3", "4", "5"])
            .exponent(2);
        console.log("The domain of this is [10,20]: ");
        console.log("pow(10): " + pow(10));
        console.log("pow(11): " + pow(11));
        console.log("pow(12): " + pow(12));
    </script>
</body>
  
</html>

chevron_right


Output:

Example 2:

HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>
</head>
<style>
</style>
  
<body>
    <script>
        var pow = d3.scalePow()
            // Setting domain for the scale.
            .domain([-1, 1])
            .range(["red", "blue", "green", "white"])
            .exponent(2);
        console.log("The domain of this is [-1,1]: ");
        console.log("pow(-1): " + pow(-1));
        console.log("pow(0): " + pow(0));
        console.log("pow(1): " + pow(1));
    </script>
</body>
  
</html>

chevron_right


Output:

full-stack-img




My Personal Notes arrow_drop_up
Recommended Articles
Page :