d3-array icon indicating copy to clipboard operation
d3-array copied to clipboard

String accessors?

Open mbostock opened this issue 4 years ago • 0 comments

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 (#236)
  • [ ] bin.value? (possibly breaking change, but why would you ever use a constant here?)

mbostock avatar Jan 25 '21 01:01 mbostock