Skip to content

Commit

Permalink
Remove graph spikes
Browse files Browse the repository at this point in the history
  • Loading branch information
theyosh committed May 20, 2024
1 parent 9ff5cb1 commit f9cc073
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions gui/helpers/graph-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ export const smoothing = (data, smoothingValue) => {
const max_items = data.length;

for (let i = 0; i < max_items; i++) {

// Remove spikes in alarm values
if (i > 0 && i < max_items-1) {
if (data[i-1].alarm_min == data[i+1].alarm_min && data[i-1].alarm_min !== data[i].alarm_min) {
data[i].alarm_min = data[i-1].alarm_min;
}
if (data[i-1].alarm_max == data[i+1].alarm_max && data[i-1].alarm_max !== data[i].alarm_max) {
data[i].alarm_max = data[i-1].alarm_max;
}
}

// Smoothing value
const range = data.slice(Math.max(i - countBefore, 0), Math.min(i + countAfter + 1, max_items));
const new_data_point = JSON.parse(JSON.stringify(data[i]));

Expand Down

0 comments on commit f9cc073

Please sign in to comment.