diff --git a/src/views/app.js b/src/views/app.js index 69a4765a9..1892c7b67 100644 --- a/src/views/app.js +++ b/src/views/app.js @@ -721,7 +721,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location' var borderColors = [ '#2196F3', '#FF6384' ]; var backgroundColors = [ '#82C4F844', '#FF63844F' ]; - 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 = []; @@ -779,12 +779,14 @@ angular.module('Application').controller('AppController', ['$scope', '$location' 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'); @@ -798,10 +800,10 @@ angular.module('Application').controller('AppController', ['$scope', '$location' var currentMemoryLimit = $scope.app.memoryLimit || $scope.app.manifest.memoryLimit || (256 * 1024 * 1024); - fillGraph('#graphsMemoryChart', [{ data: result.memory, label: 'Memory' }], 'memoryChart', 1024 * 1024, currentMemoryLimit / 1024 / 1024); - fillGraph('#graphsCpuChart', [{ data: result.cpu, label: 'CPU' }], 'cpuChart', 1, 100); - fillGraph('#graphsDiskChart', [{ data: result.blockRead, label: 'Read' }, { data: result.blockWrite, label: 'Write' }], 'diskChart', 1024 * 1024, null); - fillGraph('#graphsNetworkChart', [{ data: result.networkRead, label: 'Incoming' }, { data: result.networkWrite, label: 'Outgoing' }], 'networkChart', 1024 * 1024, null); + fillGraph('#graphsMemoryChart', [{ data: result.memory, label: 'Memory' }], 'memoryChart', 1024 * 1024, currentMemoryLimit / 1024 / 1024, 'GiB', 1024); + fillGraph('#graphsCpuChart', [{ data: result.cpu, label: 'CPU' }], 'cpuChart', 1, 100, '%'); + fillGraph('#graphsDiskChart', [{ data: result.blockRead, label: 'Read' }, { data: result.blockWrite, label: 'Write' }], 'diskChart', 1024 * 1024, null, 'KiB'); + fillGraph('#graphsNetworkChart', [{ data: result.networkRead, label: 'Incoming' }, { data: result.networkWrite, label: 'Outgoing' }], 'networkChart', 1024 * 1024, null, 'KiB'); $scope.graphs.busy = false; }); diff --git a/src/views/system.js b/src/views/system.js index 19074db45..42ba830e6 100644 --- a/src/views/system.js +++ b/src/views/system.js @@ -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; });