Skip to content

Commit 3e3bedd

Browse files
committed
Misc fixes
1 parent 75a714d commit 3e3bedd

File tree

1 file changed

+46
-21
lines changed
  • src/views/testingPerfs/content/compare/comparisonTable

1 file changed

+46
-21
lines changed

src/views/testingPerfs/content/compare/comparisonTable/index.tsx

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,47 @@ const useStyles = makeStyles({
4949
},
5050
});
5151

52-
const colorGradient = (value: number) => {
53-
if (value < -0.5) {
54-
return '#ff0000';
55-
} else if (value < -0.2) {
56-
return '#e06666';
57-
} else if (value < -0.1) {
58-
return '#ea9999';
59-
} else if (value < 0) {
60-
return '#f4c7c3';
61-
} else if (value > 0.5) {
62-
return '#6aa74f';
63-
} else if (value > 0.2) {
64-
return '#92c47c';
65-
} else if (value > 0.1) {
66-
return '#b5d8a7';
67-
} else if (value > 0) {
68-
return '#b5d8a6';
52+
const colorGradient = (value: number, invert = false) => {
53+
if (invert === true) {
54+
if (value < -0.5) {
55+
return '#ff0000';
56+
} else if (value < -0.2) {
57+
return '#e06666';
58+
} else if (value < -0.1) {
59+
return '#ea9999';
60+
} else if (value < 0) {
61+
return '#f4c7c3';
62+
} else if (value > 0.5) {
63+
return '#6aa74f';
64+
} else if (value > 0.2) {
65+
return '#92c47c';
66+
} else if (value > 0.1) {
67+
return '#b5d8a7';
68+
} else if (value > 0) {
69+
return '#b5d8a6';
70+
} else {
71+
return '#fff';
72+
}
6973
} else {
70-
return '#fff';
74+
if (value < -0.5) {
75+
return '#6aa74f';
76+
} else if (value < -0.2) {
77+
return '#92c47c';
78+
} else if (value < -0.1) {
79+
return '#b5d8a7';
80+
} else if (value < 0) {
81+
return '#b5d8a6';
82+
} else if (value > 0.5) {
83+
return '#ff0000';
84+
} else if (value > 0.2) {
85+
return '#e06666';
86+
} else if (value > 0.1) {
87+
return '#ea9999';
88+
} else if (value > 0) {
89+
return '#f4c7c3';
90+
} else {
91+
return '#fff';
92+
}
7193
}
7294
};
7395

@@ -258,7 +280,7 @@ const ComparisonTable: React.FC<connectedProps> = (props: connectedProps) => {
258280
...col,
259281
refValue: Math.round(refValue),
260282
compValue: Math.round(compValue),
261-
compDiff: Math.round(compDiff * 100),
283+
compDiff: compDiff,
262284
};
263285
})
264286
.map((col: any) => (
@@ -270,10 +292,13 @@ const ComparisonTable: React.FC<connectedProps> = (props: connectedProps) => {
270292
<TableCell
271293
align="right"
272294
style={{
273-
backgroundColor: colorGradient(col.compDiff),
295+
backgroundColor:
296+
col.id === 'throughput'
297+
? colorGradient(col.compDiff)
298+
: colorGradient(col.compDiff, true),
274299
}}
275300
>
276-
{col.compDiff}%
301+
{Math.round(col.compDiff * 100)}%
277302
</TableCell>
278303
</>
279304
)}

0 commit comments

Comments
 (0)