Sunday, November 17, 2024
Google search engine
HomeLanguagesJavascriptD3.js band.round() Function

D3.js band.round() Function

The band.round() function is used to set the round true or false i.e it enables or disables the rounding. If the round is et to true then the start and stop of each band will be an integer. 

Syntax:

band.round([round]);

Parameters: This function accepts single parameters as given above and described below:

  • round: This parameter accepts a boolean value of true or false.

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 =
    </script>
      
</head
<body
    <script
    // Creating the band scale with
    // specified domain and range.
        var band = d3.scaleBand()
          .domain([0.001, 0.002, 0.003, 0.004])
        // When range is in string
                    .range(["0", "15"]);
        
console.log("When round function is set to false:");
      // Setting round to false
        band.round(false);
        
        console.log("band(0.001): ", band(0.001));
        console.log("band(0.002): ", band(0.002));
    </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 =
    </script>
</head
<body
    <script
    // Creating the band scale with 
   //specified domain and range.
        var band = d3.scaleBand()
   .domain([0.001, 0.002, 0.003, 0.004])
        // When range is in string
                    .range(["0", "15"]);
        
 console.log("When round function is set to true:");
      // Setting round to true
        band.round(true);
        
        console.log("band(0.001): ", band(0.001));
        console.log("band(0.002): ", band(0.002));
    </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!

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments