fixing coloring

This commit is contained in:
Peter Holmberg
2018-12-17 14:26:19 +01:00
parent 98490084a1
commit e7f966d002
+7 -8
View File
@@ -93,14 +93,14 @@ export class Gauge extends PureComponent<Props> {
}
getFontColor(value) {
const { baseColor, thresholds } = this.props;
const { baseColor, maxValue, thresholds } = this.props;
if (thresholds.length > 0) {
const foo = thresholds.filter(t => value <= t.value);
const atThreshold = thresholds.filter(threshold => value <= threshold.value);
if (foo.length > 0) {
return foo[0].color;
}
if (atThreshold.length > 0) {
return atThreshold[0].color;
} else if (value <= maxValue) {
return BasicGaugeColor.Red;
}
return baseColor;
@@ -142,8 +142,7 @@ export class Gauge extends PureComponent<Props> {
...thresholds.map((threshold, index) => {
return {
value: threshold.value,
// Hacky way to get correct color for threshold.
color: index === 0 ? threshold.color : thresholds[index - 1].color,
color: index === 0 ? threshold.color : thresholds[index].color,
};
}),
{