joaopedroab opened a new pull request, #38458:
URL: https://github.com/apache/superset/pull/38458

   ### SUMMARY
   
   The MapBox chart's `ScatterPlotGlowOverlay` uses disconnected sizing 
formulas for clusters and individual points:
   
   - **Clusters**: `scaledRadius = (label / maxLabel)^0.5 * radius`
   - **Single points**: `defaultRadius = radius / 6`
   
   This causes three bugs:
   1. **Small clusters appear smaller than single points** — with maxLabel=100, 
a cluster with label=1 gets 6px while single points get 10px
   2. **Zero-value clusters are invisible** — `(0/maxLabel)^0.5 * 60 = 0px`
   3. **Negative labels produce NaN** — `(-5/10)^0.5 = NaN` crashes the canvas 
arc
   
   The fix remaps cluster radius from `[0, radius]` to `[radius/6, radius]`, 
matching the single-point `defaultRadius` as the floor. Negative labels are 
clamped before the sqrt to prevent NaN.
   
   | Scenario | Label | MaxLabel | Before | After | Single Point |
   |----------|-------|----------|--------|-------|-------------|
   | Main bug | 1 | 100 | **6px** | **15px** | 10px |
   | Zero value | 0 | 50 | **0px** | **10px** | 10px |
   | Negative | -5 | 10 | **NaN** | **10px** | 10px |
   | Max cluster | 100 | 100 | 60px | 60px | 10px |
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   **Before** — small clusters are smaller than individual points:
   
   <img width="928" height="723" alt="image" 
src="https://github.com/user-attachments/assets/e062bb0c-5884-4d84-93e0-2087e5192abd";
 />
   
   **After** — clusters are properly sized and always >= individual points:
   
   <img width="1619" height="871" alt="image" 
src="https://github.com/user-attachments/assets/e245a81c-642c-4adc-860e-d47ae0e3760c";
 />
   
   ### TESTING INSTRUCTIONS
   
   1. Create a MapBox chart with a dataset containing geospatial data
   2. Set Clustering Radius to 60, Point Radius Unit to Pixels
   3. Zoom to a level where both clusters and individual points are visible
   4. Verify that no cluster circle is smaller than individual point circles
   5. Verify proportional ordering: larger-value clusters appear bigger
   
   ```bash
   cd superset-frontend
   npx jest 
plugins/legacy-plugin-chart-map-box/test/ScatterPlotGlowOverlay.test.tsx
   ```
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: Fixes #38314
   - [ ] Required feature flags:
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to