Better y axis labels

This commit is contained in:
Johannes Zellner
2022-10-13 22:16:35 +02:00
parent db1056112c
commit 60f8ab9030
2 changed files with 12 additions and 8 deletions

View File

@@ -136,7 +136,7 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
var colors = [ '#2196F3', '#FF6384' ];
function fillGraph(canvasId, contents, chartPropertyName, divisor, max) {
function fillGraph(canvasId, contents, chartPropertyName, divisor, max, format, formatDivisor) {
if (!contents || !contents[0]) return; // no data available yet
var datasets = [];
@@ -195,12 +195,14 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
ticks: { autoSkipPadding: 50, maxRotation: 0 }
},
y: {
ticks: { maxTicksLimit: 6 },
min: 0,
beginAtZero: true
}
}
};
if (format) options.scales.y.ticks.callback = function (value) { return (formatDivisor ? (value/formatDivisor).toFixed(0) : value) + ' ' + format; };
if (max) options.scales.y.max = max;
var ctx = $(canvasId).get(0).getContext('2d');
@@ -241,8 +243,8 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
return { data: app.memory, label: app.label };
});
fillGraph('#graphsCPUChart', [{ data: result.cpu, label: 'CPU' }].concat(appsWithHighCPU), 'cpuChart', 1, 100);
fillGraph('#graphsSystemMemoryChart', [{ data: result.memory, label: 'Memory' }].concat(appsWithHighMemory), 'memoryChart', 1024 * 1024, Number.parseInt($scope.memory.memory / 1024 / 1024));
fillGraph('#graphsCPUChart', [{ data: result.cpu, label: 'CPU' }].concat(appsWithHighCPU), 'cpuChart', 1, 100, '%');
fillGraph('#graphsSystemMemoryChart', [{ data: result.memory, label: 'Memory' }].concat(appsWithHighMemory), 'memoryChart', 1024 * 1024, Number.parseInt($scope.memory.memory / 1024 / 1024), 'GiB', 1024);
$scope.graphs.busy = false;
});