I am struggle to get my crossfilter groups set up right. Maybe someone can drop a hint!
My datastructure looks more or less this way:
{datetime: "2014-01-01 20:00:00", id:1}
{datetime: "2014-01-01 22:21:08", id:2}
{datetime: "2014-01-02 12:00:23", id:3} etc...
The dimension is on datetime to return the day of week:
var weekdayDimension = ndx.dimension(function(d) {
return new Date(d.datetime).getDay();
});
Now I have problems with the grouping. I want the average count of events per weekday. So far I have (of course no correct)
var weekdayAvgGroup = weekdayDimension.group(function (d) {
return d;
});
I think I do not understand what that grouping is doing exactly...
My goal is to have some chart like:
Monday => Average 40.3 Events
Tuesday => Average 35.4 Events
I created a JSFiddle please take a look.
Can anybody drop a hint please?
UPDATE:
After additional thinking I could create a dimension on the Date. All I would have to do is to know the number of days selected in order to calculate the
(total amount of events selected/number of selected days)
So I would need to count the number of groups on the date dimension. But haven't found the solution on this one either.
Thank you