cpu metrics: fix typo in null check

This commit is contained in:
Girish Ramakrishnan
2025-05-21 18:31:46 +02:00
parent fcfc9572f1
commit b54d34127e

View File

@@ -45,16 +45,9 @@ async function liveRefresh() {
gMetricStream.onerror = (error) => console.log('event stream error:', error);
gMetricStream.onmessage = (message) => {
const data = JSON.parse(message.data);
if (data.cpu[0]) return; // value can be null if no previous value
if (!data.cpu[0]) return; // value can be null if no previous value
gGraph.data.labels.push(moment(data.cpu[1]*1000).format('hh:mm'));
gGraph.data.datasets[0].data.push(data.cpu[0]);
// Limit the number of data points to keep the chart readable
if (gGraph.data.datasets[0].data.length > 40) {
gGraph.data.labels.shift();
gGraph.data.datasets[0].data.shift();
}
gGraph.update();
};
}
@@ -100,7 +93,8 @@ async function refresh() {
ticks: {
autoSkip: true, // skip tick labels as needed
autoSkipPadding: 20, // padding between ticks
maxRotation: 0 // don't rotate the labels
maxRotation: 0, // don't rotate the labels
maxTicksLimit: 15 // max tick labels to show
}
},
y: {