Skip to content
Related Articles
Open in App
Not now

Related Articles

D3.js quantile.invertExtent() Function

Improve Article
Save Article
  • Last Updated : 23 Aug, 2020
Improve Article
Save Article

The quantile.invertExtent() function in d3.js is used to return the extent of the values that are present in the specified domain for the corresponding value in the range.

Syntax:

quantile.invertExtent( value )

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

  • value: It is the value that corresponds to the specified range.

Return Values: This function returns a value from the specified domain.

Below programs illustrate the quantile.invertExtent() function in D3.js:

Example 1:

HTML




<!DOCTYPE html>
<html>
  
<head>
    <script src="https://d3js.org/d3.v4.min.js">
    </script>
    <script src=
    </script>
    <script src=
    </script>
    <script src=
    </script>
</head>
  
<body>
    <h1 style="color: green;">
        GeeksforGeeks
    </h1>
  
    <p>quantile.invertExtent() Function </p>
  
    <script>
        var quantile = d3.scaleQuantile()
            // Setting domain for the scale.
            .domain([1, 10])
            // Setting the range of the scale.
            .range([0, 960]);
  
        // Printing the output
        document.write("<h3>" +
            quantile.invertExtent(960) +
            "</h3>");
        document.write("<h3>" +
            quantile.invertExtent(0) +
            "</h3>");
    </script>
</body>
  
</html>

Output:

Example 2:

HTML




<!DOCTYPE html>
<html>
  
<head>
    <script src="https://d3js.org/d3.v4.min.js">
    </script>
    <script src=
    </script>
    <script src=
    </script>
    <script src=
    </script>
</head>
  
<body>
    <h1 style="color: green;">
        GeeksforGeeks
    </h1>
  
    <p>quantile.invertExtent() Function </p>
  
    <script>
        var quantile = d3.scaleQuantile()
            // Setting domain for the scale.
            .domain([1, 10])
            // Setting the range of the scale.
            .range(["red", "blue", "orange"]);
  
        // Printing the output
        document.write(
            "<h3>quantile.invertExtent(\"blue\"): " +
            quantile.invertExtent("blue") + "</h3>");
        document.write(
            "<h3>quantile.invertExtent(\"red\"): " +
            quantile.invertExtent("red") + "</h3>");
    </script>
</body>
  
</html>

Output:


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!