0

I am trying to really learn crossfilter but keep struggling with grasping the concepts. One thing I don't understand that I think might help shed some light on this library is figuring out is why we need to use groupAll().reduce() instead of just group().reduce() in the function to tally up items in an array in the examples found here:

Is there a way to tell crossfilter to treat elements of array as separate records instead of treating whole array as single key?

Is there a best practice someone found for debugging and really drilling down into what is going on? I'm used to being able to set break points...

Thanks for any help!

Community
  • 1
  • 1
JSchins
  • 117
  • 10
  • Because Crossfilter's standard group approach assumes that each record belongs to a single group. In the case of items in an array, where you want to aggregate the record into the group corresponding to each item, this assumption is not valid. So you need to use groupAll, which lets you determine exactly how you want to structure your groups and which group(s) each record goes in to. – Ethan Jewett Jan 28 '16 at 19:42
  • @ethan It seems as if you can define your own reduce methods when you call group though...from the api doc => group.reduce(add, remove, initial) – JSchins Jan 30 '16 at 00:28
  • Correct, but Crossfilter manages the distribution of the records to those functions in the group case. It will send each record to a single group to be "reduced". In the groupAll scenario you can determine exactly how records are distributed to groups. – Ethan Jewett Jan 30 '16 at 02:36

0 Answers0