healthyregions / chicago-environment-explorer

ChiVes harmonizes & standardizes environmental data across dozens of sources to make it accessible for full exploration, alongside a growing list of resources on the Chicago Environment, cultivated by a community of curators.
8 stars 1 forks source link

feat: support variable colorScale length, use jenks natural breaks for default legend #134

Closed bodom0015 closed 4 months ago

bodom0015 commented 4 months ago

Problem

colorScale is hard-coded, quantiles are currently using hard-coded percentiles

Jenks natural breaks might be better than quantiles in some scenarios

Approach

How to Test

TBD

netlify[bot] commented 4 months ago

Deploy Preview for chicago-env-explorer ready!

Name Link
Latest commit 9d6fd5c6ce70f43c80be047a955da88fc4156e0f
Latest deploy log https://app.netlify.com/sites/chicago-env-explorer/deploys/65df982367a53d0008fdd74a
Deploy Preview https://deploy-preview-134--chicago-env-explorer.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.

bodom0015 commented 4 months ago

Initially, some data (such as "Observed Particulate Matter (PM2.5)") didn't agree with the jenks method:

react-dom.development.js:11340 Uncaught TypeError: Cannot read properties of undefined (reading '2')
    at jenksBreaks (jenks_breaks.js:21:1)
    at jenks (jenks.js:37:1)
    at SummaryMapPage (SummaryAndMap.js:207:1)
    at renderWithHooks (react-dom.development.js:14985:1)
    at mountIndeterminateComponent (react-dom.development.js:17811:1)
    at beginWork (react-dom.development.js:19049:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
    at invokeGuardedCallback (react-dom.development.js:4056:1)
    at beginWork$1 (react-dom.development.js:23964:1)

There is one or more data point in this set that has a value of NaN (not a number), and this caused the above error. Filtering out the NaN values before computing allows us to get the jenks natural breaks or quantile bins without encountering the same error :+1: