Skip to content

Commit

Permalink
feat(rankedPlantations): make items lowerCase to match colors
Browse files Browse the repository at this point in the history
  • Loading branch information
wri7tno committed Nov 25, 2024
1 parent 666345a commit 7518baa
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions components/widgets/land-cover/ranked-plantations/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ export const parseData = createSelector(
const totalArea = regionExtent && regionExtent.total_area;
plantationKeys.forEach((key) => {
const labelFromKey =
regionGroup && regionGroup.find((p) => p.plantations === key);
regionGroup &&
regionGroup.find(
(p) => p.plantations.toLowerCase() === key.toLowerCase()
);
const pExtent = labelFromKey && labelFromKey.intersection_area;
const pPercentage = (pExtent / totalRegionPlantations) * 100;
yKeys[key] = pPercentage || 0;
yKeys[`${key} label`] = key;
yKeys[key.toLowerCase()] = pPercentage || 0;
yKeys[`${key.toLowerCase()} label`] = key.toLowerCase();
});

return {
Expand All @@ -83,12 +86,12 @@ export const parseConfig = createSelector(
colors: colorsByType,
unit: '%',
xKey: 'region',
yKeys: dataKeys,
yKeys: dataKeys.map((item) => item.toLowerCase()),
yAxisDotFill: '#d4d4d4',
tooltip: dataKeys.map((item) => ({
key: item,
key: item.toLowerCase(),
label: item,
color: colorsByType[item],
color: colorsByType[item.toLowerCase()],
unitFormat: (value) => formatNumber({ num: value, unit: '%' }),
})),
};
Expand Down

0 comments on commit 7518baa

Please sign in to comment.