Skip to content

String accessors? #189

@mbostock

Description

@mbostock

d3-array currently uses function accessors, e.g.

d3.median(data, d => d.foo)

What if a string could be used instead of an accessor for convenience?

d3.median(data, "foo")

There’s some precedent for this, e.g. Lodash’s _.property:

_.map(data, "foo")

(However, I don’t think we want to support nested properties as in Lodash. I think these should be simple property names with no implicit DSL.)

Here’s where it might be used:

  • d3.min
  • d3.minIndex
  • d3.max
  • d3.maxIndex
  • d3.extent
  • d3.sum
  • d3.mean
  • d3.median
  • d3.cumsum
  • d3.quantile
  • d3.quantileSorted
  • d3.variance
  • d3.deviation
  • d3.fsum
  • d3.least
  • d3.leastIndex
  • d3.greatest
  • d3.greatestIndex
  • d3.bisector
  • d3.group
  • d3.groups
  • d3.index
  • d3.indexes
  • d3.rollup
  • d3.rollups
  • d3.groupSort
  • d3.count
  • d3.every
  • d3.some
  • d3.filter
  • d3.map
  • d3.sort
  • d3.rank (only implement “low” ties strategy #236)
  • bin.value? (possibly breaking change, but why would you ever use a constant here?)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions