Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

D3.js | d3.values() Function

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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:




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

Output:

1, 2, 3, 4

Example 2:




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

Output:

0, 2, 3, 4

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


My Personal Notes arrow_drop_up
Last Updated : 28 Jun, 2019
Like Article
Save Article
Similar Reads
Related Tutorials