Skip to content

Commit

Permalink
Merge pull request #122 from ImpeccableHQ/fix/chart-bug
Browse files Browse the repository at this point in the history
fix: check for existing past value
  • Loading branch information
guerrap authored Nov 8, 2022
2 parents b137fea + ce3a25d commit b5e5454
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/Chart/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ const Chart = ({ title, tooltipTitle, data, type, dataType, overridingActiveFilt
.filter((key) => key !== 'time')
.forEach((key) => {
currentHeaderValue += weeklyAggregatedData[weeklyAggregatedData.length - 1][key];
pastHeaderValue += weeklyAggregatedData[weeklyAggregatedData.length - 2][key];
pastHeaderValue +=
weeklyAggregatedData.length >= 2 ? weeklyAggregatedData[weeklyAggregatedData.length - 2][key] : 0;
});

setActiveDate(weeklyAggregatedData[weeklyAggregatedData.length - 1].time);
Expand All @@ -68,7 +69,7 @@ const Chart = ({ title, tooltipTitle, data, type, dataType, overridingActiveFilt
.filter((key) => key !== 'time')
.forEach((key) => {
currentHeaderValue += data[data.length - 1][key];
pastHeaderValue += data[data.length - 2][key];
pastHeaderValue += data.length >= 2 ? data[data.length - 2][key] : 0;
});

setActiveDate(data[data.length - 1].time);
Expand Down

0 comments on commit b5e5454

Please sign in to comment.