Skip to content

Commit 28327b9

Browse files
committed
fix: color calculation conditions
1 parent 2234947 commit 28327b9

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

client/components/V1/Utils/util.tsx

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,28 @@ export const calculateColor = (value: number, threshold: string, liikennevalo: b
1919
.split(';')
2020
.map(str => str.replace(',', '.'))
2121
.map(Number)
22-
22+
2323
if (first === 0) {
24-
if (value < second) {
25-
return LightColors.Red
26-
} else if (value < third) {
27-
return LightColors.Yellow
28-
} else if (value < fourth) {
29-
return LightColors.LightGreen
30-
} else if (value >= fourth) {
24+
if (value >= fourth) {
3125
return LightColors.DarkGreen
32-
} else if (value === first) {
26+
} else if (value >= third) {
27+
return LightColors.LightGreen
28+
} else if (value >= second) {
29+
return LightColors.Yellow
30+
} else if (value >= first) {
3331
return LightColors.Red
3432
} else {
3533
return LightColors.Grey
3634
}
3735
} else {
38-
if (value > second) {
39-
return LightColors.Red
40-
} else if (value > third) {
41-
return LightColors.Yellow
42-
} else if (value < third && value > fourth) {
43-
return LightColors.LightGreen
44-
} else if (value <= fourth) {
36+
if (value <= fourth) {
4537
return LightColors.DarkGreen
38+
} else if (value <= third) {
39+
return LightColors.LightGreen
40+
} else if (value <= second) {
41+
return LightColors.Yellow
42+
} else if (value <= first) {
43+
return LightColors.Red
4644
} else {
4745
return LightColors.Grey
4846
}

0 commit comments

Comments
 (0)