D3.js | d3.values() Function

The d3.values() function in D3.js is used to return an array containing the property values of the specified object or an associative array.

Syntax:

d3.values(object)

Parameters: This function accepts single parameter object which contains the key, value pairs.



Return Value: It returns the values of the given object.

Below programs illustrate the d3.values() function in D3.js:

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        d3.values() function
    </title>
      
    <script src = "https://d3js.org/d3.v4.min.js"></script>
</head>
  
<body>
    <script>
      
        // Initialising an object
        var month = {
            "January": 1,
            "February": 2,
            "March": 3,
            "April": 4
        };
            
        // Calling the d3.values() function
        A = d3.values(month);
        
        // Getting the values of the given object
        document.write(A);
    </script>
</body>
  
</html>                    

chevron_right


Output:

1, 2, 3, 4

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        d3.values() function
    </title>
      
    <script src = "https://d3js.org/d3.v4.min.js"></script>
</head>
  
<body>
    <script>
      
        // Initialising an object
        var month = {
            "GeeksforGeeks": 0,
            "Geeks": 2,
            "Geek": 3,
            "gfg": 4
        };
            
        // Calling the d3.values() function
        A = d3.values(month);
        
        // Getting the values of the given object
        document.write(A);
    </script>
</body>
  
</html>                     

chevron_right


Output:

0, 2, 3, 4

Reference: https://devdocs.io/d3~5/d3-collection#values



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.