diff --git a/static/js/directives/ui/heatmap.js b/static/js/directives/ui/heatmap.js index 4c4d5800f..0939a590f 100644 --- a/static/js/directives/ui/heatmap.js +++ b/static/js/directives/ui/heatmap.js @@ -49,15 +49,30 @@ angular.module('quay').directive('heatmap', function () { }); } - cal.update(formatData(data)); + var formatted = formatData(data); + cal.update(formatted.data); + cal.setLegend(formatted.legendDomain); }; var formatData = function(data) { var timestamps = {}; + var max = 1; data.forEach(function(entry) { timestamps[moment(entry.date).unix()] = entry.count; + max = Math.max(max, entry.count); }); - return timestamps; + + var domain = []; + var current = 1; + for (var i = 0; i < 4; ++i) { + domain.push(current); + current += max / 5; + } + + return { + data: timestamps, + legendDomain: domain + }; }; $scope.$watch('data', function() {