Skip to content
Related Articles

Related Articles

D3.js quantile.domain() Function
  • Last Updated : 26 Aug, 2020

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




<!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>

Output:

Example 2:

HTML




<!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>

Output:

My Personal Notes arrow_drop_up
Recommended Articles
Page :