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:

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

chevron_right


Output:

Example 2:

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

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.