Skip to content

Commit

Permalink
Merge pull request #385 from NordicSemiconductor/fix/max-zero-at-end
Browse files Browse the repository at this point in the history
Fix: max goes to zero when one of the values is NaN
  • Loading branch information
kylebonnici authored Jan 4, 2024
2 parents 5699e6e + e09a397 commit 55f759a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/Chart/Chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,11 @@ const Chart = ({ digitalChannelsEnabled = false }) => {
const average = avgTemp.sum / avgTemp.count / 1000;
const max =
processedData.ampereLineData.length > 0
? Math.max(...processedData.ampereLineData.map(v => v.y ?? 0)) /
1000
? Math.max(
...processedData.ampereLineData
.filter(v => !Number.isNaN(v.y))
.map(v => v.y ?? 0)
) / 1000
: 0;

setAmpereLineData(processedData.ampereLineData);
Expand Down

0 comments on commit 55f759a

Please sign in to comment.