Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gradient coloring of the table for zero values #1623

Merged
merged 1 commit into from
Sep 30, 2024
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
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();
});
});
});
Loading