diff --git a/src/ui/libs/DatalensChartkit/ChartKit/components/Widget/components/Table/Bar/utils.ts b/src/ui/libs/DatalensChartkit/ChartKit/components/Widget/components/Table/Bar/utils.ts index dea8a8e478..cdb3ae18d5 100644 --- a/src/ui/libs/DatalensChartkit/ChartKit/components/Widget/components/Table/Bar/utils.ts +++ b/src/ui/libs/DatalensChartkit/ChartKit/components/Widget/components/Table/Bar/utils.ts @@ -83,7 +83,7 @@ const getLeftPosition = (align: string, width: number) => { const getMinBarStyle = (args: GetMinBarStyleArgs): React.CSSProperties => { const {value, min, color, align = 'right'} = args; - const valuePart = getRangeValuePart(min, value); + const valuePart = Math.min(100, getRangeValuePart(min, value)); return { background: color, @@ -94,7 +94,7 @@ const getMinBarStyle = (args: GetMinBarStyleArgs): React.CSSProperties => { const getMaxBarStyle = (args: GetMaxBarStyleArgs): React.CSSProperties => { const {value, max, color, align = 'left'} = args; - const valuePart = getRangeValuePart(max, value); + const valuePart = Math.min(100, getRangeValuePart(max, value)); return { background: color, diff --git a/tests/opensource-suites/__screenshots__/wizard/visualizations/flat-table/linear-indicator.test.ts/Wizard-Flat-table-Linear-indicator-with-manual-aee01-ax-value-is-less-than-the-actual-screenshot-1.png b/tests/opensource-suites/__screenshots__/wizard/visualizations/flat-table/linear-indicator.test.ts/Wizard-Flat-table-Linear-indicator-with-manual-aee01-ax-value-is-less-than-the-actual-screenshot-1.png index 5539117466..6f62090529 100644 Binary files a/tests/opensource-suites/__screenshots__/wizard/visualizations/flat-table/linear-indicator.test.ts/Wizard-Flat-table-Linear-indicator-with-manual-aee01-ax-value-is-less-than-the-actual-screenshot-1.png and b/tests/opensource-suites/__screenshots__/wizard/visualizations/flat-table/linear-indicator.test.ts/Wizard-Flat-table-Linear-indicator-with-manual-aee01-ax-value-is-less-than-the-actual-screenshot-1.png differ diff --git a/tests/opensource-suites/wizard/visualizations/flat-table/linear-indicator.test.ts b/tests/opensource-suites/wizard/visualizations/flat-table/linear-indicator.test.ts index 493f0123f2..e2966eb6b5 100644 --- a/tests/opensource-suites/wizard/visualizations/flat-table/linear-indicator.test.ts +++ b/tests/opensource-suites/wizard/visualizations/flat-table/linear-indicator.test.ts @@ -45,18 +45,45 @@ datalensTest.describe('Wizard', () => { 'id', ); - await wizardPage.createNewFieldWithFormula('max', 'max([id]) - 3'); + // an indicator with a negative minimum and positive maximum scale values + await wizardPage.createNewFieldWithFormula('ind1', 'max([id]) - 3'); await wizardPage.sectionVisualization.addFieldByClick( PlaceholderName.FlatTableColumns, - 'max', + 'ind1', ); await wizardPage.visualizationItemDialog.open( PlaceholderName.FlatTableColumns, - 'max', + 'ind1', ); await enableBar(wizardPage, [-1, 1]); await wizardPage.visualizationItemDialog.clickOnApplyButton(); + // an indicator with a positive minimum and maximum scale values + await wizardPage.createNewFieldWithFormula('ind2', 'max([id]) - 3'); + await wizardPage.sectionVisualization.addFieldByClick( + PlaceholderName.FlatTableColumns, + 'ind2', + ); + await wizardPage.visualizationItemDialog.open( + PlaceholderName.FlatTableColumns, + 'ind2', + ); + await enableBar(wizardPage, [0.1, 1]); + await wizardPage.visualizationItemDialog.clickOnApplyButton(); + + // an indicator with a positive minimum and maximum scale values + await wizardPage.createNewFieldWithFormula('ind3', 'max([id]) - 3'); + await wizardPage.sectionVisualization.addFieldByClick( + PlaceholderName.FlatTableColumns, + 'ind3', + ); + await wizardPage.visualizationItemDialog.open( + PlaceholderName.FlatTableColumns, + 'ind3', + ); + await enableBar(wizardPage, [-1, -0.1]); + await wizardPage.visualizationItemDialog.clickOnApplyButton(); + await wizardPage.sectionVisualization.addFieldByClick( PlaceholderName.FlatTableColumns, 'segment',