D3 Collection Versions Save

Handy data structures for elements keyed by string.

v1.0.7

5 years ago
  • Housekeeping.

v1.0.6

5 years ago
  • Update dependencies, again.

v1.0.5

5 years ago
  • Update dependencies.

v1.0.4

6 years ago

v1.0.3

7 years ago
  • Update dependencies.

v1.0.2

7 years ago
  • Update dependencies.

v1.0.1

7 years ago
  • Add module entry point to package.json.

v1.0.0

7 years ago
  • First stable release!

Changes since D3 3.x

The d3.set constructor now accepts an existing set for making a copy. If you pass an array to d3.set, you can also pass a value accessor. This accessor takes the standard arguments: the current element (d), the index (i), and the array (data), with this undefined. For example:

var yields = [
  {yield: 22.13333, variety: "Manchuria",        year: 1932, site: "Grand Rapids"},
  {yield: 26.76667, variety: "Peatland",         year: 1932, site: "Grand Rapids"},
  {yield: 28.10000, variety: "No. 462",          year: 1931, site: "Duluth"},
  {yield: 38.50000, variety: "Svansota",         year: 1932, site: "Waseca"},
  {yield: 40.46667, variety: "Svansota",         year: 1931, site: "Crookston"},
  {yield: 36.03333, variety: "Peatland",         year: 1932, site: "Waseca"},
  {yield: 34.46667, variety: "Wisconsin No. 38", year: 1931, site: "Grand Rapids"}
];

var sites = d3.set(yields, function(d) { return d.site; }); // Grand Rapids, Duluth, Waseca, Crookston

The d3.map constructor also follows the standard array accessor argument pattern.

The map.forEach and set.forEach methods have been renamed to map.each and set.each respectively. The order of arguments for map.each has also been changed to value, key and map, while the order of arguments for set.each is now value, value and set. This is closer to ES6 map.forEach and set.forEach. Also like ES6 Map and Set, map.set and set.add now return the current collection (rather than the added value) to facilitate method chaining. New map.clear and set.clear methods can be used to empty collections.

The nest.map method now always returns a d3.map instance. For a plain object, use nest.object instead. When used in conjunction with nest.rollup, nest.entries now returns {key, value} objects for the leaf entries, instead of {key, values}. This makes nest.rollup easier to use in conjunction with hierarchies, as in this Nest Treemap example.

See CHANGES for all D3 changes since 3.x.

v0.3.1

7 years ago
  • Export to the global d3 in vanilla environments (d3/d3#2840).

v0.3.0

7 years ago
  • Export to the global d3 in vanilla environments (d3/d3#2840).