aggregateData: function (groupedData) {
var that = this,
now = new Date().getTime(),
- earliestDate = now, // won't be now for long
+ earliestDate = now, // might not be now for long
+ latestDate = now, // might not be now for long
dataPoints = _.reduce(groupedData, function (memo, group) {
_.each(group, function (item) {
var dateInt = item.get(that.getDateField()).getTime();
earliestDate = Math.min(earliestDate, dateInt);
+ latestDate = Math.max(latestDate, dateInt);
});
return memo + group.length;
}, 0),
binCount = Math.ceil(Math.sqrt(dataPoints)),
- binWidth = Math.ceil((now - earliestDate) / binCount),
+ binWidth = Math.ceil((latestDate - earliestDate) / binCount),
histoGroup = _.map(groupedData, function (group, groupKey) {
var binnedData, summedData, hole, findHole, foundData;
findHole = function (datum) {
return datum.x === String(hole);
};
- for (hole = earliestDate; hole <= now; hole += binWidth) {
+ for (hole = earliestDate; hole <= latestDate; hole += binWidth) {
foundData = _.find(summedData, findHole);
if (!foundData) {
summedData.push({x: String(hole), y: 0});