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:
commit
1c3075f6cf
1 changed files with 17 additions and 2 deletions
|
@ -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() {
|
||||
|
|
Reference in a new issue