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

Heatmap, color customisation and marker aggregation #7

Merged
merged 16 commits into from
Apr 25, 2024
Merged

Conversation

jsbnr
Copy link
Contributor

@jsbnr jsbnr commented Mar 28, 2024

No description provided.

@@ -94,6 +132,10 @@ const Regions = () => {
location={location}
tooltipConfig={tooltipConfig}
defaultHeader={feature.properties.ADMIN}
heatMap={getGradientColor}
heatMapSteps={gradientSteps}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theres probbaly a better way to do this. In order for the region color to update when the config changed i had to pass ll this information over to use in the useEffect trigger. I cant help but feel the gradient generator function should live within Region.tsx, but its here because it needs information form all the regions for the gradient bucketing to be derived.

const isTooltip = key.includes("tooltip_");
const isIconLabel = key === "icon_label" && !key.includes("_precision");

if (isTooltip || isIconLabel) {
if (!isClusterData && (isTooltip || isIconLabel)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can think of a better way to derive the cluster icon settings from the individual marker settings. i wanted to avoid adding any more config options and so chose to derive the settings from the data itself.

@@ -2,58 +2,66 @@ import { MARKER_COLOURS } from "../constants";
import { sentenceCase } from "text-case";

// Utility function to get color attributes based on location status
const getColorAttributes = (status) => {
export const getColorAttributes = (status,customColors) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these two functions are ripe for refactoring ;)

return null;
}

setHMSteps(heatMapSteps && heatMapSteps!="" ? parseInt(heatMapSteps) : 0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This state setting was all to try and force a re-render whne config options changed. It seemed unnecessary to me but i couldnt find anbother way to trigger the re-render on prop change.

@@ -34,7 +56,7 @@ const Region = ({ region, location, tooltipConfig, defaultHeader }) => {
};

return (
<GeoJSON key={location.status} data={region} style={style} onClick={handleRegionClick}>
<GeoJSON key={key+"-"+location.value+"-"+style.fillColor} data={region} style={style} onClick={handleRegionClick}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this so that if the color changes it re-renders, is there a better way?

@jsbnr jsbnr mentioned this pull request Apr 22, 2024
---------

Co-authored-by: matewilk <matewilk@gmail.com>
Copy link
Collaborator

@matewilk matewilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work, thanks @jsbnr !

@matewilk matewilk merged commit 0c6cd15 into main Apr 25, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants