Sunday, November 17, 2024
Google search engine
HomeLanguagesJavascriptD3.js point.domain() Function

D3.js point.domain() Function

The point.domain() function is used to set the domain of the point scale to a specified array of values. The first element in the array is mapped to the first point in the range, the second value in the domain to the second point, and so on.

Syntax:

point.domain([domain]);

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

  • domain: This parameter sets the domain of the point scale i.e the minimum and the maximum value.

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"/> 
    <title>GeekforGeeks</title
    <script src =
    </script>
      
</head
<style>
</style>
<body
    <script
    // Creating the point scale with 
   // specified domain and range.
        var point = d3.scalePoint()
                    .domain([1, 2, 3, 4]);
        
        console.log("point(1): ", point(1));
        console.log("point(2): ", point(2));
        console.log("point(3): ", point(3));
        console.log("point(4): ", point(4));
    </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"/> 
    <title>GeekforGeeks</title
    <script src =
    </script>
      
</head
<style>
</style>
<body
    <script
// Creating the point scale with specified domain and range.
        var point = d3.scalePoint()
                    .domain([1, 2, 3, 4])
                    .range([10, 50]);
        
        console.log("point(1): ", point(1));
        console.log("point(2): ", point(2));
        console.log("point(3): ", point(3));
        console.log("point(4): ", point(4));
    </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!

RELATED ARTICLES

Most Popular

Recent Comments