VOOZH about

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

⇱ D3.js rollup() method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

D3.js rollup() method

Last Updated : 6 Apr, 2023

With the help of d3.rollup() method, we can get the reduced map from an iterable data structure having keys and values.

Syntax:

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

Return value: It will return the reduced map from iterables.

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 the d3.rollup() method, we are able to get the reduced map from an iterable data structure having keys and values.

Output:

Map { '34.0' => 1, '120.11' => 1, '12.01' => 1, '34.05' => 1 }

Example 2:

Output:

Map {
 'ABC' => Map { '11/12/2019' => 1 },
 'DEF' => Map { '11/02/2020' => 1, '03/04/2020' => 1 },
 'MNO' => Map { '01/04/2020' => 1 } 
 }
Comment
Article Tags:
Article Tags: