Merge pull request #1573 from coreos-inc/linear-heatmap

Have heat map adjust its color range based on linear scale
This commit is contained in:
josephschorr 2016-06-23 13:41:01 -04:00 committed by GitHub
commit 1c3075f6cf

View file

@ -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() {