issue #23965: bugfix future histograms
authorSteve Hackbarth <stephenhackbarth@gmail.com>
Fri, 20 Jun 2014 14:18:53 +0000 (10:18 -0400)
committerSteve Hackbarth <stephenhackbarth@gmail.com>
Fri, 20 Jun 2014 14:18:53 +0000 (10:18 -0400)
lib/enyo-x/source/widgets/chart.js

index c446236..2869a13 100644 (file)
@@ -450,16 +450,18 @@ trailing:true, white:true*/
     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;
 
@@ -478,7 +480,7 @@ trailing:true, white:true*/
           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});