Skip to content

Commit

Permalink
Fix databar sizing for with and without grid lines
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrunyon committed Aug 23, 2024
1 parent b292fcb commit 850d476
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions packages/grid/src/DataBarCellRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ class DataBarCellRenderer extends CellRenderer {
const rowY = getOrThrow(allRowYs, row);
const textAlign = model.textAlignForCell(modelColumn, modelRow);
const text = model.textForCell(modelColumn, modelRow);
const { x: textX, width: textWidth } = GridUtils.getTextRenderMetrics(
state,
column,
row
);
const {
x: textX,
y: textY,
width: textWidth,
} = GridUtils.getTextRenderMetrics(state, column, row);

const fontWidth = fontWidths?.get(context.font) ?? DEFAULT_FONT_WIDTH;
const truncationChar = model.truncationCharForCell(modelColumn, modelRow);
Expand Down Expand Up @@ -152,12 +152,21 @@ class DataBarCellRenderer extends CellRenderer {
context.font = theme.font;

if (valuePlacement !== 'hide') {
context.fillText(truncatedText, textX, rowY + rowHeight * 0.5);
context.fillText(truncatedText, textX, textY);
}

const hasRowDividers = theme.gridRowColor != null;
const yOffset = hasRowDividers ? 2 : 1;

context.save();
context.beginPath();
context.roundRect(dataBarX, rowY + 1, dataBarWidth, rowHeight - 2, 1);
context.roundRect(
dataBarX,
rowY + yOffset, // yOffset includes 1px for top padding
dataBarWidth,
rowHeight - 1 - yOffset, // 1px for bottom padding
1
);
context.clip();
context.globalAlpha = opacity;

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/styleguide.spec.ts-snapshots/grids-data-bar-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 850d476

Please sign in to comment.