Skip to content

Commit

Permalink
fix(18858): Fix incorrect label for MCDA axes with area_km2 in denomi…
Browse files Browse the repository at this point in the history
…nator (#772)

* fix(18858): Remove special case for generating MCDA axis label (case where denominator === area_km2)

* test: remove obsolete test
  • Loading branch information
albaranau authored Jun 26, 2024
1 parent b58ad55 commit 60b43bb
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 37 deletions.
28 changes: 0 additions & 28 deletions src/utils/bivariate/labelFormatters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,34 +90,6 @@ describe('BivariateLegend labels formatting', () => {
expect(formatBivariateAxisLabel(quotients)).toEqual('NDVI (avg) to Test (index)');
});

it('denominator - area_km2', () => {
const quotients: Axis['quotients'] = [
{
name: 'highway_length_6_months',
label: 'OSM: new road length (last 6 months)',
direction: [['bad'], ['good']],
unit: {
id: 'km',
shortName: 'km',
longName: 'kilometers',
},
},
{
name: 'area_km2',
label: 'Area',
direction: [['neutral'], ['neutral']],
unit: {
id: 'km2',
shortName: 'km²',
longName: 'square kilometers',
},
},
];
expect(formatBivariateAxisLabel(quotients)).toEqual(
'OSM: new road length (last 6 months) (km/km²)',
);
});

it('other cases', () => {
const quotients: Axis['quotients'] = [
{
Expand Down
9 changes: 0 additions & 9 deletions src/utils/bivariate/labelFormatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ export const formatBivariateAxisLabel = (quotients: Axis['quotients']): string =
if (!hasUnits(denominator.unit.id)) {
return `${numerator.label} to ${denominator.label} (${numerator.unit.shortName})`;
}
// cases for both units
if (denominator.name === 'area_km2') {
return `${numerator.label} (${numerator.unit.shortName}/${denominator.unit.shortName})`;
}

return `${numerator.label} to ${denominator.label} (${numerator.unit.shortName}/${denominator.unit.shortName})`;
};
Expand All @@ -53,11 +49,6 @@ export const formatBivariateAxisUnit = (quotients: Axis['quotients']): string |
return numerator.unit.shortName;
}

// cases for both units
if (denominator.name === 'area_km2') {
return `${numerator.unit.shortName}/${denominator.unit.shortName}`;
}

return `${numerator.unit.shortName}/${denominator.unit.shortName}`;
};

Expand Down

0 comments on commit 60b43bb

Please sign in to comment.