D3.js quantile.domain() Function

The quantile.domain() function is used to set the domain for the quantile scale. The given domain array must not be empty and must contain at least one numeric value.

Syntax:

quantile.domain([domain]);

Parameters: This function takes only one parameter as given above and described below.

  • domain: This parameter sets the domain of the scale i.e. the minimum and the maximum value. It accepts an array of discrete numeric values. The array must contain at least one numeric value.

Return Value: This function does not return any value.

Below examples illustrate the quantile.domain() function in D3.js:



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>
    <h2 style="color: green;">GeekforGeeks</h2>
  
    <p>quantile.domain() Function</p>
  
    <script>
        var quantile = d3.scaleQuantile()
            // Setting domain for the scale
            .domain([1000])
            // Setting the range of the scale
            .range([16]);
  
        // Printing the output
        document.write("<h3>quantile(10): " 
                + quantile(10) + "</h3>");
        document.write("<h3>quantile(20): " 
                + quantile(20) + "</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" />
  
    <script src="https://d3js.org/d3.v4.min.js">
    </script>
</head>
  
<body>
    <h2 style="color: green;">GeekforGeeks</h2>
  
    <p>quantile.domain() Function</p>
  
    <script>
        var quantile = d3.scaleQuantile()
            // Setting domain for the scale
            .domain([1, 2, 3, 4])
            // Setting the range of the scale
            .range([6, 16, 24, 28]);
  
        // Printing the output
        document.write("<h3>quantile(1): "
                + quantile(1) + "</h3>");
        document.write("<h3>quantile(2): " 
                + quantile(2) + "</h3>");
        document.write("<h3>quantile(3): " 
                + quantile(3) + "</h3>");
        document.write("<h3>quantile(4): " 
                + quantile(4) + "</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.