D3.js continuous.ticks() Function

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

Syntax:

continuous.ticks([count]);

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

  • count: It is the number of values to be returned in the given domain. These values are equally spaced.

Return Values This function does not return anything.

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" />
    <title>Geeks for geeks</title>
    <script src="https://d3js.org/d3.v4.min.js">
    </script>
    <script src=
    </script>
    <script src=
    </script>
    <script src=
    </script>
</head>
  
<body>
    <h2 style="color:green;">
        GeeksforGeeks
    </h2>
      
    <p>D3.js continuous.ticks() Function</p>
      
    <script>
        var x = d3.scaleLinear()
            .domain([0, 1])
            .range([0, 100]);
  
        var ticks = x.ticks(5);
        document.write("<h3>", ticks + "</h3>")
    </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" />
    <title>Geeks for geeks</title>
    <script src="https://d3js.org/d3.v4.min.js">
    </script>
    <script src=
    </script>
    <script src=
    </script>
    <script src=
    </script>
</head>
  
<body>
    <h2 style="color:green;">
        GeeksforGeeks
    </h2>
      
    <p>D3.js continuous.ticks() Function </p>
  
    <script>
        var x = d3.scaleLinear()
            .domain([-10, -10.5])
            .range(["blue", "green"]);
  
        var ticks = x.ticks(10);
        document.write("<h3>", ticks + "</h3>")
    </script>
</body>
  
</html>

chevron_right


Output:

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.