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

Refactor D3 Map to Support Both Rate Charts and Unknowns Charts #3949

Merged
merged 52 commits into from
Feb 13, 2025

Conversation

eriwarr
Copy link
Collaborator

@eriwarr eriwarr commented Feb 4, 2025

Description and Motivation

This PR refactors the D3 map implementation to support both rate charts and unknowns charts. Key changes include:

  • Refactored renderMap.tsx to handle different chart types dynamically.
  • Updated getFillColor to adjust colors based on extremesMode for better data visualization.
  • Improved createColorScale to internally determine the appropriate scale type (sequentialSymlog vs. quantileSequential).
  • Enhanced stroke color logic to switch territory borders between gray and white based on extremesMode.

Has this been tested? How?

Tested locally

Screenshots (if appropriate)

Types of changes

  • New content or feature
  • Refactor / chore

New frontend preview link is below in the Netlify comment 😎

@eriwarr eriwarr changed the title updated tooltip and working map migrate rate map Feb 4, 2025
Copy link

netlify bot commented Feb 4, 2025

Deploy Preview for health-equity-tracker ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 049d934
🔍 Latest deploy log https://app.netlify.com/sites/health-equity-tracker/deploys/67accd79eeb1740008433d0f
😎 Deploy Preview https://deploy-preview-3949--health-equity-tracker.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@eriwarr eriwarr changed the title migrate rate map Refactor D3 Map to Support Both Rate Charts and Unknowns Charts Feb 4, 2025
@eriwarr eriwarr self-assigned this Feb 4, 2025
frontend/src/cards/UnknownsMapCard.tsx Outdated Show resolved Hide resolved
frontend/src/charts/choroplethMap/colorSchemes.ts Outdated Show resolved Hide resolved
frontend/src/charts/choroplethMap/tooltipUtils.ts Outdated Show resolved Hide resolved
frontend/src/cards/MapCard.tsx Outdated Show resolved Hide resolved
frontend/src/cards/MapCard.tsx Outdated Show resolved Hide resolved
frontend/src/charts/choroplethMap/types.ts Outdated Show resolved Hide resolved
benhammondmusic and others added 4 commits February 6, 2025 09:46
# Description and Motivation
<!--- bulleted, high level items. use keywords (eg "closes SatcherInstitute#144" or
"fixes #4323") -->

- adds feature flag
- conditionally adds "Gun Deaths" as new dropdown topic
- adds handling for gun deaths from CHR to AHR provider (maybe should be
gun violence? Maybe we should rethink the provider structure overall)


## Has this been tested? How?

e2e tests still passing. manually confirmed only working with flag
enabled on county-level data

## Screenshots (if appropriate)


![image](https://github.com/user-attachments/assets/3523411e-54c5-4ef5-bd08-5dbc3a48067b)


![image](https://github.com/user-attachments/assets/6c6489cb-bc09-4bf0-b54c-b4226ffb8fd5)


## Types of changes

(leave all that apply)

- New content or feature

## New frontend preview link is below in the Netlify comment 😎
removed unused file
fix npm security issue
Copy link
Collaborator

@benhammondmusic benhammondmusic left a comment

Choose a reason for hiding this comment

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

looks like there are some frontend test errors happening; maybe typescript errors?

also, the highest/lowest mode for CAWP is strange where it's assigning colors correctly to the territory bubbles, but switched for the states (yellow should be GOOD rates of women in gov, but it's showing the states with the worst rates 0% as yellow... only in highest/lowest but not in normal view)

Screenshot 2025-02-06 at 10 21 32 PM

Colors aren't perfectly synced with the legend yet, when expanding into extremes mode, you can see Oklahoma should have the lightest yellow color based on its rate, but it's shown as a slightly darker orange. almost like it's recalculating the color scale from only the remaining states but keeping the legend scale across ALL data points. I think either way is fine, like if the extremes mode gets its newly calculated scale, but we need to make sure the legend will match it accurately

Screenshot 2025-02-06 at 10 26 21 PM Screenshot 2025-02-06 at 10 26 24 PM

Copy link
Collaborator

@benhammondmusic benhammondmusic left a comment

Choose a reason for hiding this comment

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

awesome work! thanks for cleaning everything up and improving the legends across the board. There are some weird things still around the color scheme typing, but I think we'll be able to clean those up and simplify once we've totally switched over to the new d3 stuff (and fully removed vega)

Comment on lines +165 to +169
const mapScheme =
typeof props.mapConfig.scheme === 'string'
? props.mapConfig.scheme
: 'darkgreen'

Copy link
Collaborator

Choose a reason for hiding this comment

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

this feels weird; will we be able to remove this once we have fully migrated from vega to d3 ?

@eriwarr eriwarr merged commit 6369857 into SatcherInstitute:main Feb 13, 2025
11 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.

2 participants