D3.js pow.ticks() Function

The pow.ticks() function is used to return the count values from the scale’s domain. The values returned by ticks() lies in the domain. If the count is not given as a parameter then by default it is set to 10.

Syntax:

pow.ticks([count]);

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

  • count: It is the number of equally spaced values which lie in the given domain.

Return Values: This function does not return anything.

Below given are a few examples of the function given above.

Example 1:




<!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=
    "https://d3js.org/d3-color.v1.min.js">
    </script
    <script src=
    "https://d3js.org/d3-interpolate.v1.min.js">
    </script
    <script src=
    "https://d3js.org/d3-scale-chromatic.v1.min.js">
    </script
</head
<body
    <h2 style="color: green;">Beginner for Beginner</h2>
    <p>pow.ticks() Function </p>
    <script
        var pow = d3.scalePow()
            .domain([0, 10])
            .range([0, 10])
            .ticks(8)
        document.write("<h3>"+pow+"</h3>")
    </script
</body
</html>


Output:

Example 2:




<!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=
    "https://d3js.org/d3-color.v1.min.js">
    </script
    <script src=
    "https://d3js.org/d3-interpolate.v1.min.js">
    </script
    <script src=
    "https://d3js.org/d3-scale-chromatic.v1.min.js">
    </script
</head
<body
    <h2 style="color: green;">
         Beginner for Beginner
    </h2>
    <p>pow.ticks() Function </p>
    <script
        var pow = d3.scalePow()
            .domain([-10, 10])
            .range([0, 10])
            .ticks(12)
        document.write("<h3>"+pow+"</h3>")
    </script
</body
</html>


Output:



Contact Us