Open In App
Related Articles

D3.js | d3.map.values() Function

Improve Article
Improve
Save Article
Save
Like Article
Like

The map.values() function in D3.js used to return an array of values for every entry in the created map. The order of the returned values are arbitrary.

Syntax:

d3.map.values()

Parameters: This function does not accept any parameters.

Return Value: This function returns an array of values for every entry in the created map. Order of those returned values are arbitrary.

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

Example 1:




<!DOCTYPE html>
<html>
     
<head>
    <title> d3.map.values() Function</title>
     
    <script src='https://d3js.org/d3.v4.min.js'></script>
</head>
  
<body>   
  <script>
       
     // Creating a map
     var map = d3.map({"Ram": 5, "Geeks": 10, "gfg": 15});
       
     // Calling the map.values() function
     A = map.values();
       
     // Getting an array of values for
     // every entry in the map.
     console.log(A);
  </script>
</body>
  
</html>

Output:

[5, 10, 15]

Example 2:




<!DOCTYPE html>
<html>
     
<head>
    <title> d3.map.values() Function</title>
     
    <script src='https://d3js.org/d3.v4.min.js'></script>
</head>
  
<body>
  <script>
       
     // Creating some maps
     var map1 = d3.map({"Ram": 5});
     var map2 = d3.map({"Geeks": 10});
     var map3 = d3.map({"Ram": 5, "Geeks": 10});
     var map4 = d3.map();
       
     // Calling the map.values() function
     A = map1.values();
     B = map2.values();
     C = map3.values();
     D = map4.values();
       
     // Getting an array of values for
     // every entry in the map.
     console.log(A);
     console.log(B);
     console.log(C);
     console.log(D);
  </script>
</body>
  
</html>

Output:

[5]
[10]
[5, 10]
[]

Ref: https://devdocs.io/d3~5/d3-collection#map_values


Last Updated : 28 Jun, 2019
Like Article
Save Article
Similar Reads
Related Tutorials