Skip to content
Related Articles
Open in App
Not now

Related Articles

D3.js band.step() Function

Improve Article
Save Article
Like Article
  • Last Updated : 23 Sep, 2020
Improve Article
Save Article
Like Article

The band.step() function in d3.js is used to find the step of the band which is calculated by finding the distance between the starts of adjacent bands.

Syntax: 

band.step()

Parameters: This function does not accept any parameter.

Return Value: This function returns the distance between the starts of adjacent bands.

Example 1:

HTML




<!DOCTYPE html>
<html>
  
<head>
    <script src=
    </script>
</head>
  
<body>
    <script>
        // Creating the band scale with 
        // specified domain and range
        var A = d3.scaleBand()
            .domain([10, 20, 30, 40, 50])
            .range([0, 10]);
  
        // Using the step() function
        let step_val = A.step();
  
        // Printing the Output  
        console.log("Step Of A: ", step_val);
    </script>
</body>
  
</html>

Output:

Step Of A:  2

Example 2:

HTML




<!DOCTYPE html>
<html>
  
<head>
    <script src=
    </script>
</head>
  
<body>
    <script>
        // Creating the band scale with 
        // specified domain and range
        var B = d3.scaleBand()
            .domain(["one", "two",
                "three", "four"])
            .range([0, 60]);
  
        // Using the step() function
        let step_val = B.step();
  
        // Printing the Output  
        console.log("Step in B: ", step_val);
    </script>
</body>
  
</html>

Output:

Step in B:  15

My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!