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

group.post.cap(length).() always does natural ordering #47

Open
mukherjeea opened this issue Aug 8, 2016 · 5 comments
Open

group.post.cap(length).() always does natural ordering #47

mukherjeea opened this issue Aug 8, 2016 · 5 comments

Comments

@mukherjeea
Copy link

mukherjeea commented Aug 8, 2016

var skuDim = ndx.dimension(function(d){ return d.sku; });
var skuGroup = skuDim.group();
var skuReducer = reductio().count(true).sum('hits');
skuReducer(skuGroup);
skuGroup.order(function(p) { return p.sum; });
console.log(skuGroup.top(Infinity));
console.log(skuGroup.post().cap(3)());`

crossfilter top orders correctly. reductio post().cap(length)() doesn't.

@esjewett
Copy link
Member

esjewett commented Aug 8, 2016

Sorry, I was just not familiar enough with this part of the API. I would prefer if it respected group ordering, but the way it works right now is that you need to use the sortBy option of the post processing capability like so:

group.post().sortBy('value.sum', d3.descending).cap(3)()

I'll answer on StackOverflow as well.

Longer-term, I'd prefer that the post-processing respected group order by default, so I will consider making that change for a 1.0 release and therefore leave this issue open.

Thanks,
Ethan

@esjewett esjewett added this to the 1.0 milestone Aug 8, 2016
@esjewett esjewett assigned esjewett and unassigned esjewett Aug 8, 2016
@esjewett
Copy link
Member

esjewett commented Aug 8, 2016

You'll need to create a fake group. There is an example in the dc.js FAQ: https://github.com/dc-js/dc.js/wiki/FAQ#fake-groups

Note that you could also use dc.js's ordering and capping capabilities rather than Reductio's. Up to you!

@mukherjeea
Copy link
Author

Cheers Ethan. I got it working. That's why I removed the comment here and added the comment on SO. I would be nice the have the feature as well because most of the time I'm guessing people would want to use it in charts. I don't know where it fits between dc.js and reductio but I think this might be pretty useful. Thanks again!

@raino01r
Copy link

raino01r commented Apr 7, 2017

So, is it possible to add a fake group on a reductio-ned group?

Probably the solution is already given, but to me it is not clear. Assume

reducer = reductio();
// complicate filtering on reducer
group = reducer(group)

then just doing the following looks like a lost of functionality. Am I wrong?

group = remove_empty_bins(group)

@esjewett
Copy link
Member

esjewett commented Apr 7, 2017

Please don't ask new questions on old issues being used to track features. Open a question on Stackoverflow or a new issue here with a running example of your issue/question. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants