diff --git a/src/components/Analysis/MaxConsumptionCard/__snapshots__/MaxConsumptionCard.spec.tsx.snap b/src/components/Analysis/MaxConsumptionCard/__snapshots__/MaxConsumptionCard.spec.tsx.snap index 3ab2406153e28c2d338addd47c2d264f0a895368..c7b9d88446a2c31b5f36e58cee76e0d97662e27e 100644 --- a/src/components/Analysis/MaxConsumptionCard/__snapshots__/MaxConsumptionCard.spec.tsx.snap +++ b/src/components/Analysis/MaxConsumptionCard/__snapshots__/MaxConsumptionCard.spec.tsx.snap @@ -208,7 +208,7 @@ exports[`MaxConsumptionCard component should be rendered correctly 1`] = ` </g> <g class="barFill" - transform="translate(54.6875, 0)" + transform="translate(54.6875, 168.73935065329292)" > <defs> <lineargradient @@ -235,13 +235,13 @@ exports[`MaxConsumptionCard component should be rendered correctly 1`] = ` a4,4 0 0 1 4,-4 h210.75 a4,4 0 0 1 4,4 - v176 + v7.260649346707083 h-218.75 z" /> </g> <g - transform="translate(54.6875, 0)" + transform="translate(54.6875, 168.73935065329292)" > <defs> <lineargradient @@ -269,7 +269,7 @@ exports[`MaxConsumptionCard component should be rendered correctly 1`] = ` a4,4 0 0 1 4,-4 h210.75 a4,4 0 0 1 4,4 - v176 + v7.260649346707083 h-218.75 z" /> @@ -291,7 +291,7 @@ exports[`MaxConsumptionCard component should be rendered correctly 1`] = ` </g> <g class="barFill" - transform="translate(328.125, 19.57862281603289)" + transform="translate(328.125, 168.73935065329292)" > <defs> <lineargradient @@ -318,13 +318,13 @@ exports[`MaxConsumptionCard component should be rendered correctly 1`] = ` a4,4 0 0 1 4,-4 h210.75 a4,4 0 0 1 4,4 - v156.4213771839671 + v7.260649346707083 h-218.75 z" /> </g> <g - transform="translate(328.125, 19.57862281603289)" + transform="translate(328.125, 168.73935065329292)" > <defs> <lineargradient @@ -352,7 +352,7 @@ exports[`MaxConsumptionCard component should be rendered correctly 1`] = ` a4,4 0 0 1 4,-4 h210.75 a4,4 0 0 1 4,4 - v156.4213771839671 + v7.260649346707083 h-218.75 z" /> diff --git a/src/components/Charts/Bar.tsx b/src/components/Charts/Bar.tsx index cc5f723bef3a1c85d640681cd5d1bc54ad8f9f3f..da8f0f73f3b2dba3300cb4c0ca570fc0fa4872cc 100644 --- a/src/components/Charts/Bar.tsx +++ b/src/components/Charts/Bar.tsx @@ -76,14 +76,31 @@ const Bar = ({ setCompareAnimationEnded(true) } + /** Get date of each fluid to display placeholder bar for multifluid */ + const lastDataDates = fluidStatus.map( + fluid => fluid.lastDataDate ?? DateTime.local(0) + ) + const lastDataDate = DateTime.max(...lastDataDates) + + const dataMissingUpcoming = Boolean( + dataload.date > lastDataDate && dataload.date < DateTime.local() + ) + let value = dataload.value - /** - * Use 10% of average as the placeholder if average is above 1, - * otherwise use a minimum of 1 as the placeholder. - */ - if (value === -1 && average) { - value = average > 1 ? average * 0.1 : 1 + + /** Adjust value for upcoming data (placeholder bars) */ + if (dataMissingUpcoming && average) { + if (average < 0) { + // Use 1 if average is negative + value = 1 + } else if (average > 1) { + // Use 10% of average if average is above 1 + value = average * 0.1 + } else { + value = average + } } + const yScaleValue = yScale(value) ?? 0 const yScaleCompareValue = yScale(compareDataload?.value ?? 0) ?? 0 @@ -130,16 +147,6 @@ const Bar = ({ return compare ? xScale.bandwidth() / 2 : xScale.bandwidth() } - /** Get date of each fluid to display placeholder bar for multifluid */ - const lastDataDates = fluidStatus.map( - fluid => fluid.lastDataDate ?? DateTime.local(0) - ) - const lastDataDate = DateTime.max(...lastDataDates) - - const dataMissingUpcoming = Boolean( - dataload.date > lastDataDate && dataload.date < DateTime.local() - ) - const topRoundedRect = ( x: number, y: number, diff --git a/src/components/Charts/__snapshots__/BarChart.spec.tsx.snap b/src/components/Charts/__snapshots__/BarChart.spec.tsx.snap index c4118a6aa4b18a039f9ec4eb8332068db54650f3..57ffaf1973a018c655d6a057bfe19515c1e904a5 100644 --- a/src/components/Charts/__snapshots__/BarChart.spec.tsx.snap +++ b/src/components/Charts/__snapshots__/BarChart.spec.tsx.snap @@ -106,7 +106,7 @@ exports[`BarChart component should render correctly 1`] = ` </g> <g class="barFill" - transform="translate(33.43750000000003, 0)" + transform="translate(33.43750000000003, 309.3554761977037)" > <defs> <lineargradient @@ -133,13 +133,13 @@ exports[`BarChart component should render correctly 1`] = ` a4,4 0 0 1 4,-4 h125.75 a4,4 0 0 1 4,4 - v326 + v16.644523802296305 h-133.75 z" /> </g> <g - transform="translate(33.43750000000003, 0)" + transform="translate(33.43750000000003, 309.3554761977037)" > <defs> <lineargradient @@ -167,7 +167,7 @@ exports[`BarChart component should render correctly 1`] = ` a4,4 0 0 1 4,-4 h125.75 a4,4 0 0 1 4,4 - v326 + v16.644523802296305 h-133.75 z" /> @@ -189,7 +189,7 @@ exports[`BarChart component should render correctly 1`] = ` </g> <g class="barFill" - transform="translate(200.62500000000003, 35.89414182939363)" + transform="translate(200.62500000000003, 309.3554761977037)" > <defs> <lineargradient @@ -216,13 +216,13 @@ exports[`BarChart component should render correctly 1`] = ` a4,4 0 0 1 4,-4 h125.75 a4,4 0 0 1 4,4 - v290.1058581706064 + v16.644523802296305 h-133.75 z" /> </g> <g - transform="translate(200.62500000000003, 35.89414182939363)" + transform="translate(200.62500000000003, 309.3554761977037)" > <defs> <lineargradient @@ -250,7 +250,7 @@ exports[`BarChart component should render correctly 1`] = ` a4,4 0 0 1 4,-4 h125.75 a4,4 0 0 1 4,4 - v290.1058581706064 + v16.644523802296305 h-133.75 z" /> diff --git a/yarn.lock b/yarn.lock index 5560e50acb345ea94fb7125fa623238cd080f9f1..6012e789d6906e9108c14524782edc68c3b28144 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12836,9 +12836,9 @@ msgpack5@^4.0.2: readable-stream "^2.3.6" safe-buffer "^5.1.2" -"mui-bottom-sheet@git+https://github.com/cozy/mui-bottom-sheet.git#v1.0.9": +"mui-bottom-sheet@https://github.com/cozy/mui-bottom-sheet.git#v1.0.9": version "1.0.8" - resolved "git+https://github.com/cozy/mui-bottom-sheet.git#3dc4c2a245ab39079bc2f73546bccf80847be14c" + resolved "https://github.com/cozy/mui-bottom-sheet.git#3dc4c2a245ab39079bc2f73546bccf80847be14c" dependencies: "@juggle/resize-observer" "^3.1.3" jest-environment-jsdom-sixteen "^1.0.3"