Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String accessors? #189

Open
34 tasks
mbostock opened this issue Jan 25, 2021 · 0 comments
Open
34 tasks

String accessors? #189

mbostock opened this issue Jan 25, 2021 · 0 comments
Assignees

Comments

@mbostock
Copy link
Member

mbostock commented Jan 25, 2021

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?)
@Fil Fil self-assigned this Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants