Skip to content

Commit

Permalink
Fix gradient coloring of the table for zero values (#1623)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuzmadom authored Sep 30, 2024
1 parent 19399a0 commit 7ac7f96
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ function mapAndColorizeTableCells(rows: TableCellsRow[], colorsConfig: ChartColo
if (typeof cell === 'object') {
const colorValue =
typeof cell.color !== 'number' || Number.isNaN(cell.color) ? null : cell.color;
const backgroundColor = colorValue ? gradientColors[colorValue] : undefined;
const backgroundColor =
colorValue === null ? undefined : gradientColors[colorValue];

if (backgroundColor && !cell.css) {
cell.css = {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {expect} from '@playwright/test';
import {
ChartKitQa,
GradientType,
Operations,
WizardPageQa,
WizardVisualizationId,
} from '../../../../../src/shared';
Expand Down Expand Up @@ -68,5 +69,30 @@ datalensTest.describe('Wizard', () => {
await expect(chart).toBeVisible();
await expect(chartContainer).toHaveScreenshot();
});

datalensTest('Gradient coloring for zero values @screenshot', async ({page}) => {
const wizardPage = new WizardPage({page});
const chartContainer = page.locator(slct(WizardPageQa.SectionPreview));
const previewLoader = chartContainer.locator(slct(ChartKitQa.Loader));

await wizardPage.sectionVisualization.addFieldByClick(PlaceholderName.Filters, 'id');
await wizardPage.filterEditor.selectFilterOperation(Operations.LTE);
await wizardPage.filterEditor.setInputValue('2');
await wizardPage.filterEditor.apply();

await wizardPage.sectionVisualization.addFieldByClick(
PlaceholderName.FlatTableColumns,
'id',
);

await wizardPage.createNewFieldWithFormula('evenOrOdd', 'max([id]) % 2');
await wizardPage.sectionVisualization.addFieldByClick(
PlaceholderName.Colors,
'evenOrOdd',
);

await expect(previewLoader).not.toBeVisible();
await expect(chartContainer).toHaveScreenshot();
});
});
});

0 comments on commit 7ac7f96

Please sign in to comment.