Skip to content

Commit

Permalink
chore: show totals per day
Browse files Browse the repository at this point in the history
  • Loading branch information
mdvanes committed May 9, 2024
1 parent 079688f commit 56dbfa7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions apps/client/src/Components/Pages/Energy/charts/ElectricChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,21 @@ export const ElectricChart: FC<{
}
);

// TODO This is very inaccurate, should come directly from Domoticz endpoint. Include in the getElectricExports response?
const year1Item1Sum = year1[0].entries?.reduce((acc, next) => {
return acc + (next?.v ?? 0);
}, 0);
const year2Item1Sum = year2[0].entries?.reduce((acc, next) => {
return acc + (next?.v ?? 0);
}, 0);

return (
<>
<Typography variant="h4">
Daily usage, averaged over {year1.length} and {year2.length}
{label}
{`Daily usage, averaged over ${year1.length} and ${year2.length} ${label}`}
</Typography>
<Typography variant="h5">
{`${year1Item1Year} ${year1Item1Sum} avg per day vs ${year2Item1Year} ${year2Item1Sum} avg per day`}
</Typography>
<EnergyChart
data={entries}
Expand Down

0 comments on commit 56dbfa7

Please sign in to comment.