VOOZH about

URL: https://www.geeksforgeeks.org/javascript/d3-js-rollups-method/

⇱ D3.js rollups() method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

D3.js rollups() method

Last Updated : 14 Sep, 2020

With the help of d3.rollups() method, we can get the reduced nested array instead of map from iterable data structure having key and values.

Syntax:

 d3.rollups(iterable, reduce, ...keys)

Return value: It will return the reduced nested array instead of map.

Note: To execute the below examples you have to install the d3 library by using the command prompt for the following command.

npm install d3

Example 1: In this example, we can see that by using d3.rollups() method we are able to get the reduced nested array instead of nested map from an iterable data structure having key and values.

Output:

[ [ 'ABC', 2 ], [ 'DEF', 1 ], [ 'MNO', 1 ] ]

Example 2:

Output:

[ [ 'ABC', [ [Array] ] ],
 [ 'DEF', [ [Array], [Array]]],
 [ 'MNO', [ [Array] ] ] ]
Comment
Article Tags: