Skip to content
Merged
Show file tree
Hide file tree
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
21 changes: 20 additions & 1 deletion plugins/ui/src/js/src/elements/UITable/UITableModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,30 @@ class UITableModel extends IrisGridModel {
negativeColor = this.colorMap.get(negativeColor) ?? negativeColor;
}

const barColor = value >= 0 ? positiveColor : negativeColor;
const hasGradient = Array.isArray(barColor) && barColor.length > 1;
const formatTextColor = this.getFormatOptionForCell(
columnIndex,
rowIndex,
'color'
);

let textColor: string;
if (formatTextColor != null) {
textColor = this.colorMap.get(formatTextColor) ?? formatTextColor;
} else if (hasGradient) {
textColor = value >= 0 ? barColor[barColor.length - 1] : barColor[0];
} else {
textColor = Array.isArray(barColor) ? barColor[0] : barColor;
Comment thread
mofojed marked this conversation as resolved.
}

return {
columnMin: minRowValue,
columnMax: maxRowValue,
axis,
color: value >= 0 ? positiveColor : negativeColor,
color: barColor,
// @ts-expect-error TODO: bump web version
textColor,
Comment thread
mofojed marked this conversation as resolved.
Comment on lines +427 to +428
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.

We should bump the web version for this... I'll merge it for now though

valuePlacement,
opacity,
markers,
Expand Down
27 changes: 27 additions & 0 deletions tests/app.d/ui_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,30 @@ def t_selection_component():
),
],
)

t_databar_text_color = ui.table(
_stocks,
format_=[
ui.TableFormat(
cols="Size", color="red", mode=ui.TableDatabar(color="purple-800")
),
],
)

t_databar_gradient_text_color = ui.table(
_stocks,
format_=[
ui.TableFormat(
cols="Size",
color="orange",
mode=ui.TableDatabar(color=["negative", "positive"]),
),
],
)

t_databar_pos_neg_text_color = ui.table(
_stocks,
format_=[
ui.TableFormat(cols="Random", color="info", mode=ui.TableDatabar()),
],
)
3 changes: 3 additions & 0 deletions tests/ui_table.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ test.describe('UI table', () => {
't_databar_priority',
't_databar_mixed',
't_databar_gradient',
't_databar_text_color',
't_databar_gradient_text_color',
't_databar_pos_neg_text_color',
].forEach(name => {
test(name, async ({ page }) => {
await gotoPage(page, '');
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.
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.
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.
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.
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading