Skip to content

Commit

Permalink
Merge pull request #388 from NordicSemiconductor/fix/chart-fails-to-r…
Browse files Browse the repository at this point in the history
…ender

fix: remove recursice function call math.max
  • Loading branch information
kylebonnici authored Jan 8, 2024
2 parents baadcc9 + e96b705 commit 24d78f3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 4.0.0-beta6 - 2024-01-08

## Fixed

- Minor improvements to the stability of the chart rendering

## 4.0.0-beta5 - 2024-01-05

## Fixed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pc-nrfconnect-ppk",
"version": "4.0.0-beta5",
"version": "4.0.0-beta6",
"displayName": "Power Profiler",
"description": "App for use with Nordic Power Profiler Kits",
"homepage": "https://github.com/NordicSemiconductor/pc-nrfconnect-ppk",
Expand Down
21 changes: 13 additions & 8 deletions src/components/Chart/Chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,19 @@ const Chart = ({ digitalChannelsEnabled = false }) => {
}
);
const average = avgTemp.sum / avgTemp.count / 1000;
const max =
processedData.ampereLineData.length > 0
? Math.max(
...processedData.ampereLineData
.filter(v => !Number.isNaN(v.y))
.map(v => v.y ?? 0)
) / 1000
: 0;

const filteredAmpereLine = processedData.ampereLineData.filter(
v => v.y != null && !Number.isNaN(v.y)
);
let max = filteredAmpereLine.length > 0 ? -Number.MAX_VALUE : 0;

filteredAmpereLine.forEach(v => {
if (v.y != null && v.y > max) {
max = v.y;
}
});

max /= 1000;

setAmpereLineData(processedData.ampereLineData);
setBitsLineData(processedData.bitsLineData);
Expand Down

0 comments on commit 24d78f3

Please sign in to comment.