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

Feature/map tooltip #662

Open
wants to merge 4 commits into
base: staging
Choose a base branch
from

Conversation

olavG91
Copy link

@olavG91 olavG91 commented Jun 20, 2024

This fix adds colors to data in the map according to labels and improves the text.

Fixes #647

Copy link

vercel bot commented Jun 20, 2024

@olavG91 is attempting to deploy a commit to the Klimatbyrån Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@LudwikJaniuk LudwikJaniuk left a comment

Choose a reason for hiding this comment

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

Good job! Requesting a few changes for the sake of code quality.

@@ -264,11 +298,19 @@ function Map({
if (!isMunicipalityData(mData) || onTouchDevice()) {
return null // tooltips on touch devices are handled separately
}
return {

const dataPointColor = getColorFromDataPoint(mData.dataPoint);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it makes sense to inline this variable

<span style={{ textDecoration: 'underline' }}>{`${tInfo.mData.name}`}</span>
{`: ${tInfo.mData.formattedDataPoint}`}
<span style={{ textDecoration: 'underline' }}>{`${tInfo.mData.name}`}:</span>
<span style={{ color: dataPointColor, fontWeight: 'bold' }}>{`${tInfo.mData.formattedDataPoint}%`}</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please run "npm run lint" to get a list of small nitpicks that will need to be addressed.

@@ -117,6 +149,8 @@ export function isMunicipalityData(
}

function MobileTooltip({ tInfo }: { tInfo: MunicipalityTapInfo }) {
const dataPointColor = getColorFromDataPoint(tInfo.mData.dataPoint);
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO this would be more readable inlined

@@ -98,6 +98,38 @@ const getColor = (
return colors[5]
}

const getColorFromDataPoint = (dataPoint: number | string): string => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This gets the job done, but would mean we have two independent definitions of the boundaries. I see there's a "boundaries" array as well. Could that be something to use?

@LudwikJaniuk
Copy link
Contributor

image
The darker colors are problematic. This isnt' well readable if you're on a bad screen or in bad lighting conditions.

@LudwikJaniuk
Copy link
Contributor

Good job on the code side of the changes!

@LudwikJaniuk
Copy link
Contributor

I don't know what's a good way to address the darker regions but we don't want to sacrifice readability for a nicer accent color. If you have any ideas I'm happy to discuss. Note it's midsummer weekend now so responses might be delayed.

@olavG91
Copy link
Author

olavG91 commented Jun 21, 2024

That will be a problem on the darker colors.
Alternative is to use the uptrend or downtrend arrows as in the label list for better contrast.

Maby we can discuss a good solution for this on Discord after holidays.

@LudwikJaniuk
Copy link
Contributor

Sounds good! Glad midsummer! talk to you next week

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.

Improve tooltip appearance on regional map
2 participants