D3.js | d3.entries() Function
Disclaimer: in version 6 of D3.js function d3.entries got deprecated. Object.entries should be used instead.
The d3.entries function in D3.js is used to return an array containing the property names and property values of the specified object.
Syntax:
d3.entries(object)
Parameters: the function accepts a single parameter — a JavaScript object.
Return Value: It returns an array containing the property names and values of the specified object.
The programs below illustrate the d3.entries function in D3.js:
Example 1:
javascript
<!DOCTYPE html>
<html>
<head>
<title> d3.entries() function </title>
</head>
<body>
<script>
var month = { "January" : 1, "February" : 2, "March" : 3};
A = d3.entries(month);
console.log(A);
</script>
</body>
</html>
|
Output:
[{"key":"January","value":1},{"key":"February","value":2},
{"key":"March","value":3}]
Example 2:
javascript
<!DOCTYPE html>
<html>
<head>
<title> d3.entries function </title>
</head>
<body>
<script>
var month = { "GeeksforGeeks" : 0, "Geeks" : 2,
"Geek" : 3, "gfg" : 4};
A = d3.entries(month);
console.log(A);
</script>
</body>
</html>
|
Output:
[{"key":"GeeksforGeeks","value":0},{"key":"Geeks","value":2},
{"key":"Geek","value":3},{"key":"gfg","value":4}]
Reference: https://devdocs.io/d3~5/d3-collection#entries
Last Updated :
03 May, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...