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(18858): Fix incorrect label for MCDA axes with area_km2 in denominator #772

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
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
Loading