Skip to content

Commit

Permalink
Fix linear indicator with min or max value only (#1760)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuzmadom authored Oct 30, 2024
1 parent ff75e22 commit e77ad3f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
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 @@ -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',
Expand Down

0 comments on commit e77ad3f

Please sign in to comment.