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

Allows reduce() to accept object containing three functions #124

Closed
wants to merge 1 commit into from
Closed

Allows reduce() to accept object containing three functions #124

wants to merge 1 commit into from

Conversation

wssbck
Copy link

@wssbck wssbck commented Sep 11, 2014

This is a bit hacky but here is the intent. If reduce() could accept not only three functions but also an object containing three functions, it would be easier to build custom aggregations for crossfilter.

For example, a function:

weightedMean(freq, weight)

with "freq" being frequencies accessor function and "weight" being weights accessor function, would return something along the lines of:

{
    add : weightedMeanAdd,
    remove : weightedMeanRemove,
    initial : weightedMeanInitial
}

All fields of this object would be functions, similar to

crossfilter_reduceAdd(value), crossfilter_reduceSubtract(value), crossfilter_zero

@jasondavies
Copy link
Collaborator

Hello! Thanks for the contribution. However, I’m afraid this is a duplicate of existing requests for the same feature: #113, #115, and related #102. We’ve taken the decision not to extend the API to support this, as we’d prefer to keep it simple. As noted in these tickets, it’s possible to have a tiny helper function that unpacks an object and makes the appropriate reduce call, if that’s something that you really need.

@gordonwoodhull
Copy link

@wssbck, you might look at the way Ethan Jewett's reductio library does this: by generating the helper function @jasondavies mentions. https://github.com/esjewett/reductio

@wssbck
Copy link
Author

wssbck commented Sep 14, 2014

OK, thanks for the tips, at first I will just focus on implementing as many reduction functions as possible.

jdar pushed a commit to jdar/crossfilter that referenced this pull request Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants