forked from Alex/Pterodactyl-Panel
Change Console Chart yAxes to start at 0 and calculate maximum depending on server config (#1535)
* Change Console Chart to start yAxes at 0 * Add calculation for Console Chart yAxes maximum if data is recieved * Fix problem with calculating memory maximum
This commit is contained in:
parent
3290d39863
commit
cd7ec731dc
@ -255,6 +255,31 @@ $(document).ready(function () {
|
||||
|
||||
TimeLabels.push($.format.date(new Date(), 'HH:mm:ss'));
|
||||
|
||||
|
||||
// memory.cmax is the maximum given by the container
|
||||
// memory.amax is given by the json config
|
||||
// use the maximum of both
|
||||
// with no limit memory.cmax will always be higher
|
||||
// but with limit memory.amax is sometimes still smaller than memory.total
|
||||
MemoryChart.config.options.scales.yAxes[0].ticks.max = Math.max(proc.data.memory.cmax, proc.data.memory.amax) / (1000 * 1000);
|
||||
|
||||
if (Pterodactyl.server.cpu > 0) {
|
||||
// if there is a cpu limit defined use 100% as maximum
|
||||
CPUChart.config.options.scales.yAxes[0].ticks.max = 100;
|
||||
} else {
|
||||
// if there is no cpu limit defined use linux percentage
|
||||
// and find maximum in all values
|
||||
var maxCpu = 1;
|
||||
for(var i = 0; i < CPUData.length; i++) {
|
||||
maxCpu = Math.max(maxCpu, parseFloat(CPUData[i]))
|
||||
}
|
||||
|
||||
maxCpu = Math.ceil(maxCpu / 100) * 100;
|
||||
CPUChart.config.options.scales.yAxes[0].ticks.max = maxCpu;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CPUChart.update();
|
||||
MemoryChart.update();
|
||||
});
|
||||
@ -301,6 +326,13 @@ $(document).ready(function () {
|
||||
},
|
||||
animation: {
|
||||
duration: 1,
|
||||
},
|
||||
scales: {
|
||||
yAxes: [{
|
||||
ticks: {
|
||||
beginAtZero: true
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -346,6 +378,13 @@ $(document).ready(function () {
|
||||
},
|
||||
animation: {
|
||||
duration: 1,
|
||||
},
|
||||
scales: {
|
||||
yAxes: [{
|
||||
ticks: {
|
||||
beginAtZero: true
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user