Skip to content
Snippets Groups Projects
Commit 97460fea authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

fix(conso): adjust placeholder values between 0 & 1

parent 12f02b20
No related branches found
No related tags found
2 merge requests!10622.7 Release,!1026fix(conso): adjust placeholder values between 0 & 1
......@@ -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"
/>
......
......@@ -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,
......
......@@ -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"
/>
......
......@@ -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"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment