Skip to content

Commit d4f14d4

Browse files
committed
move color resolution to dataBar options
1 parent 41685bd commit d4f14d4

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

plugins/ui/src/js/src/elements/UITable/UITableModel.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -402,21 +402,28 @@ class UITableModel extends IrisGridModel {
402402
negativeColor = this.colorMap.get(negativeColor) ?? negativeColor;
403403
}
404404

405-
const formatColor = this.getFormatOptionForCell(
405+
const barColor = value >= 0 ? positiveColor : negativeColor;
406+
const hasGradient = Array.isArray(barColor) && barColor.length > 1;
407+
const formatTextColor = this.getFormatOptionForCell(
406408
columnIndex,
407409
rowIndex,
408410
'color'
409411
);
410-
const textColor =
411-
formatColor != null
412-
? this.colorMap.get(formatColor) ?? formatColor
413-
: undefined;
412+
413+
let textColor: string;
414+
if (formatTextColor != null) {
415+
textColor = this.colorMap.get(formatTextColor) ?? formatTextColor;
416+
} else if (hasGradient) {
417+
textColor = value >= 0 ? barColor[barColor.length - 1] : barColor[0];
418+
} else {
419+
textColor = Array.isArray(barColor) ? barColor[0] : barColor;
420+
}
414421

415422
return {
416423
columnMin: minRowValue,
417424
columnMax: maxRowValue,
418425
axis,
419-
color: value >= 0 ? positiveColor : negativeColor,
426+
color: barColor,
420427
// @ts-expect-error TODO: bump web version
421428
textColor,
422429
valuePlacement,

0 commit comments

Comments
 (0)