Properly display missing data in run graphs
This commit fixes the display of missing run data on the run stat graphs. Previously d3 would interpolate between any 2 consecutive data points regardless if there were missing samples between them. In an earlier commit we updated the rest api to return an empty list for samples that have no data. This commit builds off of that and treats those empty lists as 0 for all values in that timestamp. Change-Id: I137e4cfa1f22aaf2d932aa3d3420ebd841abca43
This commit is contained in:
parent
073ae81f4b
commit
6cf4f2ae9f
@ -12,10 +12,15 @@ function HomeController(healthService, startDate, projectService) {
|
|||||||
return project2.metrics.failRate - project1.metrics.failRate;
|
return project2.metrics.failRate - project1.metrics.failRate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var byDate = function(entryA, entryB) {
|
||||||
|
return entryA.x - entryB.x;
|
||||||
|
};
|
||||||
|
|
||||||
var processData = function(data) {
|
var processData = function(data) {
|
||||||
var projects = projectService.createProjects(data.runs);
|
var projects = projectService.createProjects(data.runs);
|
||||||
|
var blanks = projectService.findBlanks(data.runs);
|
||||||
var dateStats = projectService.getStatsByDate(projects);
|
var dateStats = projectService.getStatsByDate(projects);
|
||||||
var entries = getChartEntries(dateStats);
|
var entries = getChartEntries(dateStats, blanks);
|
||||||
|
|
||||||
vm.chartData = [
|
vm.chartData = [
|
||||||
{ key: 'Passes', values: entries.passes, color: "blue" },
|
{ key: 'Passes', values: entries.passes, color: "blue" },
|
||||||
@ -27,15 +32,22 @@ function HomeController(healthService, startDate, projectService) {
|
|||||||
.map(function(project) { return generateGaugeData(project); });
|
.map(function(project) { return generateGaugeData(project); });
|
||||||
};
|
};
|
||||||
|
|
||||||
var getChartEntries = function(dateStats) {
|
var getChartEntries = function(dateStats, blanks) {
|
||||||
var entries = { passes: [], failures: [], failRate: [] };
|
var entries = { passes: [], failures: [], failRate: [] };
|
||||||
|
angular.forEach(blanks, function(date) {
|
||||||
|
var tempDate = new Date(date);
|
||||||
|
entries.passes.push(generateChartData(tempDate, 0));
|
||||||
|
entries.failures.push(generateChartData(tempDate, 0));
|
||||||
|
entries.failRate.push(generateChartData(tempDate, 0));
|
||||||
|
});
|
||||||
angular.forEach(dateStats, function(stats) {
|
angular.forEach(dateStats, function(stats) {
|
||||||
entries.passes.push(generateChartData(stats.date, stats.metrics.passes));
|
entries.passes.push(generateChartData(stats.date, stats.metrics.passes));
|
||||||
entries.failures.push(generateChartData(stats.date, stats.metrics.failures));
|
entries.failures.push(generateChartData(stats.date, stats.metrics.failures));
|
||||||
entries.failRate.push(generateChartData(stats.date, stats.metrics.failRate));
|
entries.failRate.push(generateChartData(stats.date, stats.metrics.failRate));
|
||||||
});
|
});
|
||||||
|
entries.passes = entries.passes.sort(byDate);
|
||||||
|
entries.failures = entries.failures.sort(byDate);
|
||||||
|
entries.failRate = entries.failRate.sort(byDate);
|
||||||
return entries;
|
return entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -26,6 +26,16 @@ var projectService = function(projectFactory, metricsService) {
|
|||||||
return { date: date, metrics: metricsService.getNewMetrics() };
|
return { date: date, metrics: metricsService.getNewMetrics() };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
service.findBlanks = function(runsJson) {
|
||||||
|
var blanks = [];
|
||||||
|
angular.forEach(runsJson, function(projectsJson, dateString) {
|
||||||
|
if (typeof projectsJson == 'undefined' || projectsJson.length == 0) {
|
||||||
|
blanks.push(dateString);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return blanks;
|
||||||
|
};
|
||||||
|
|
||||||
service.createProjects = function(runsJson) {
|
service.createProjects = function(runsJson) {
|
||||||
var projects = [];
|
var projects = [];
|
||||||
var index = {};
|
var index = {};
|
||||||
|
@ -31,7 +31,8 @@ describe('HomeController', function() {
|
|||||||
};
|
};
|
||||||
projectService = {
|
projectService = {
|
||||||
createProjects: function() { return []; },
|
createProjects: function() { return []; },
|
||||||
getStatsByDate: function() { return []; }
|
getStatsByDate: function() { return []; },
|
||||||
|
findBlanks: function() { return []; }
|
||||||
};
|
};
|
||||||
|
|
||||||
homeController = $controller('HomeController', {
|
homeController = $controller('HomeController', {
|
||||||
|
Loading…
Reference in New Issue
Block a user