diff --git a/src/server/modes/charts/plugins/datalens/utils/color-helpers.ts b/src/server/modes/charts/plugins/datalens/utils/color-helpers.ts index 03fca22b98..9e5af0e96c 100644 --- a/src/server/modes/charts/plugins/datalens/utils/color-helpers.ts +++ b/src/server/modes/charts/plugins/datalens/utils/color-helpers.ts @@ -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 = { diff --git a/tests/opensource-suites/__screenshots__/wizard/visualizations/flat-table/coloring.test.ts/Wizard-Flat-table-Gradient-coloring-for-zero-values-screenshot-1.png b/tests/opensource-suites/__screenshots__/wizard/visualizations/flat-table/coloring.test.ts/Wizard-Flat-table-Gradient-coloring-for-zero-values-screenshot-1.png new file mode 100644 index 0000000000..bc355cff03 Binary files /dev/null and b/tests/opensource-suites/__screenshots__/wizard/visualizations/flat-table/coloring.test.ts/Wizard-Flat-table-Gradient-coloring-for-zero-values-screenshot-1.png differ diff --git a/tests/opensource-suites/wizard/visualizations/flat-table/coloring.test.ts b/tests/opensource-suites/wizard/visualizations/flat-table/coloring.test.ts index 6bb57817e5..844dfab87d 100644 --- a/tests/opensource-suites/wizard/visualizations/flat-table/coloring.test.ts +++ b/tests/opensource-suites/wizard/visualizations/flat-table/coloring.test.ts @@ -3,6 +3,7 @@ import {expect} from '@playwright/test'; import { ChartKitQa, GradientType, + Operations, WizardPageQa, WizardVisualizationId, } from '../../../../../src/shared'; @@ -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(); + }); }); });