From fcd7c7e5e993539fa8676643196afaea7a85439a Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 23 Jun 2016 13:19:37 -0400 Subject: [PATCH] Have heat map adjust its color range based on linear scale --- static/js/directives/ui/heatmap.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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() {