Skip to content

Commit

Permalink
Merge branch 'main' into ft/hurumap-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinkipruto authored Aug 30, 2024
2 parents 1e51b8e + 5c6a2da commit 45ca4d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions packages/hurumap-next/src/Map/Layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ function Layers({
const locationCodes =
locationCodesProp?.map((c) => c.toUpperCase()) || [];
if (!locationCodes?.includes(feature.properties.code.toUpperCase())) {
geoStyles.inactive.color =
choropleth?.[0]?.color ?? geoStyles.inactive.color;
layer.setStyle(geoStyles.inactive);
} else {
const popUpContent = (level, name) =>
Expand Down
14 changes: 9 additions & 5 deletions packages/hurumap-next/src/Map/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const generateLegend = (
return legend;
};

export const generateChoropleth = (colors, locations, mapType) => {
export const generateChoropleth = (choroplethProps, locations, mapType) => {
if (mapType !== "choropleth") return null;

const filteredLocations = locations.filter(({ count }) => count !== null);
Expand All @@ -75,13 +75,16 @@ export const generateChoropleth = (colors, locations, mapType) => {
const roundedMaxCount = Math.ceil(maxCount);

const negativeColorRange =
colors?.negative_color_range ||
choroplethProps?.negative_color_range ||
defaultChoroplethStyles.negative_color_range;
const positiveColorRange =
colors?.positive_color_range ||
choroplethProps?.positive_color_range ||
defaultChoroplethStyles.positive_color_range;
const zeroColor = colors?.zero_color || defaultChoroplethStyles.zero_color;
const opacity = colors?.opacity || defaultChoroplethStyles.opacity;
const zeroColor =
choroplethProps?.zero_color || defaultChoroplethStyles.zero_color;
const opacity = choroplethProps?.opacity || defaultChoroplethStyles.opacity;
const borderColor =
choroplethProps.border_color || defaultChoroplethStyles.color;

const positiveThresholds = hasPositiveValues
? calculateThresholds(
Expand Down Expand Up @@ -125,6 +128,7 @@ export const generateChoropleth = (colors, locations, mapType) => {
code,
count,
fillColor: color,
color: borderColor,
opacity,
};
});
Expand Down

0 comments on commit 45ca4d8

Please sign in to comment.