crossfilter / reductio

Reductio: Crossfilter grouping
Other
250 stars 42 forks source link

Allow built in aggregations to be pre-aliased #35

Open tannerlinsley opened 8 years ago

tannerlinsley commented 8 years ago

It looks like there are aliasing methods available like: https://github.com/esjewett/reductio#reductioaliasmapping But, it looks like none of these are actually meant to override the property name of the aggregation from the get go. To produce a clean value object, you would need to go back and remove the original aggregator property name.

My idea would is something along the lines of allowing a second parameter to override the property name of the aggregation:

reductio()
  .count(true, 'myCount')
  .sum(function(d) { return +d.num; }, 'theSum')

// eg.
[{
  key: 1,
  value: {
    myCount: 5,
    theSum: 25
  }
},{
  key: 2,
  value: {
    myCount: 3,
    theSum: 45
  }
}]
esjewett commented 8 years ago

Forgot to comment here. Good idea - implemented for count. Need to implement for other aggregations.