Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/grid/src/DataBarCellRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,13 @@ class DataBarCellRenderer extends CellRenderer {

context.save();
context.textAlign = textAlign;
if (hasGradient) {

// Use explicit format color if set.
// Otherwise, fall back to the databar color for text.
const formatColor = model.formatColorForCell(modelColumn, modelRow);
if (formatColor != null) {
context.fillStyle = formatColor;
} else if (hasGradient) {
const color =
value >= 0 ? dataBarColor[dataBarColor.length - 1] : dataBarColor[0];
context.fillStyle = color;
Expand Down Expand Up @@ -230,6 +236,10 @@ class DataBarCellRenderer extends CellRenderer {
context.restore(); // Restore gradient translate/scale
} else {
// Draw normal bar
const barColor = Array.isArray(dataBarColor)
? dataBarColor[0]
: dataBarColor;
context.fillStyle = barColor;
context.beginPath();
context.roundRect(dataBarX, dataBarY, dataBarWidth, rowHeight, 1);
context.fill();
Expand Down
12 changes: 12 additions & 0 deletions packages/grid/src/GridModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ abstract class GridModel<
return theme.textColor;
}

/**
* Get the explicitly set format color for a cell
* Unlike colorForCell, this only returns a color that was explicitly
* set via formatting not type-based theme colors.
* @param column Column to get the format color for
* @param row Row to get the format color for
* @returns Explicitly set format color, or null if none was set
*/
formatColorForCell(_column: ModelIndex, _row: ModelIndex): NullableGridColor {
return null;
}

/**
* Get the background color for the cell
* @param column Column to get the background color for
Expand Down
4 changes: 4 additions & 0 deletions packages/iris-grid/src/IrisGridTableModelTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,10 @@ class IrisGridTableModelTemplate<
return theme.textColor;
}

formatColorForCell(x: ModelIndex, y: ModelIndex): string | null {
return this.formatForCell(x, y)?.color ?? null;
}

backgroundColorForCell(
x: ModelIndex,
y: ModelIndex,
Expand Down
Loading