Skip to content
Closed
Changes from all 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 text color from model if set.
// Otherwise, fall back to the databar color for text.
const textColor = model.colorForCell(modelColumn, modelRow, theme);
if (textColor && textColor !== theme.textColor) {
Comment on lines +152 to +153
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really correct, as we may return a green/red colour for positive/negative numbers.
Instead, we should be looking if a colour is set explicitly in the Format. E.g.

const format = model.formatForCell(...);
if (format?.color != null && format?.color != '') {
  ...
} else if (hasGradient) {

context.fillStyle = textColor;
} 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
Loading