Skip to content

Commit

Permalink
Rename choroplethColors to choropleth
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinkipruto committed Aug 23, 2024
1 parent 704e9a3 commit 929d778
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion apps/climatemappedafrica/src/lib/hurumap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function fetchProfile() {
locations,
preferredChildren: configuration.preferred_children,
mapType: configuration?.map_type ?? "default",
choroplethColors: configuration?.choropleth ?? null,
choropleth: configuration?.choropleth ?? null,
};
}

Expand Down
4 changes: 2 additions & 2 deletions apps/climatemappedafrica/src/pages/explore/[[...slug]].js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export async function getStaticProps({ params }) {
ghostkitSR: "",
},
};
const { locations, preferredChildren, mapType, choroplethColors } =
const { locations, preferredChildren, mapType, choropleth } =
await fetchProfile();
const [originalCode] = params?.slug || [""];
const code = originalCode.trim().toLowerCase();
Expand Down Expand Up @@ -240,7 +240,7 @@ export async function getStaticProps({ params }) {
props: {
...props,
blocks,
choroplethColors,
choropleth,
locations,
mapType,
profile,
Expand Down
4 changes: 2 additions & 2 deletions packages/hurumap-next/src/Map/LazyMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import "leaflet/dist/leaflet.css";
const LazyMap = React.forwardRef(function LazyMap(props, ref) {
const {
center,
choroplethColors,
choropleth: choroplethProps,
geography,
geometries,
isPinOrCompare,
Expand Down Expand Up @@ -51,7 +51,7 @@ const LazyMap = React.forwardRef(function LazyMap(props, ref) {
);

const { choropleth, legend } = generateChoropleth(
choroplethColors,
choroplethProps,
locations,
mapType,
);
Expand Down
11 changes: 5 additions & 6 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 = (choroplethColors, locations, mapType) => {
export const generateChoropleth = (colors, locations, mapType) => {
if (mapType !== "choropleth") return null;

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

const negativeColorRange =
choroplethColors?.negative_color_range ||
colors?.negative_color_range ||
defaultChoroplethStyles.negative_color_range;
const positiveColorRange =
choroplethColors?.positive_color_range ||
colors?.positive_color_range ||
defaultChoroplethStyles.positive_color_range;
const zeroColor =
choroplethColors?.zero_color || defaultChoroplethStyles.zero_color;
const opacity = choroplethColors?.opacity || defaultChoroplethStyles.opacity;
const zeroColor = colors?.zero_color || defaultChoroplethStyles.zero_color;
const opacity = colors?.opacity || defaultChoroplethStyles.opacity;

const positiveThresholds = hasPositiveValues
? calculateThresholds(
Expand Down

0 comments on commit 929d778

Please sign in to comment.