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

   ### SUMMARY
   The Gantt chart's Y-axis category labels are custom text annotations (drawn 
via an ECharts `markLine` label rather than a normal axis label), and the chart 
reserves horizontal space for them by measuring their text width on an 
offscreen canvas. That measurement used `canvas.measureText(...).width` (the 
glyph *advance* width) with a font string built from theme tokens that never 
actually matched the font the label was rendered with. Two issues compounded:
   
   - The render font could silently drift from the measurement font, since only 
the measurement path set an explicit `font`, while the rendered label had no 
`fontSize`/`fontFamily` of its own.
   - Advance width alone can be narrower than a glyph's visible ink (e.g. 
descenders, italics, or fonts with overhanging glyphs), so even a matching font 
could still under-measure some labels.
   
   Either gap could leave the reserved left margin a few pixels too narrow, 
clipping part of the label.
   
   This PR:
   - Applies the exact same `fontSize`/`fontFamily` tokens to both the 
measurement canvas and the rendered label, so they can no longer diverge.
   - Uses the larger of the advance width and the canvas ink bounding box 
(`actualBoundingBoxLeft` + `actualBoundingBoxRight`) when computing the 
reserved width, falling back to the advance width when bounding-box metrics 
aren't available.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   N/A — this is a sub-pixel text-measurement fix; the visual difference is a 
few pixels of margin on the Y-axis and isn't meaningfully capturable in a 
screenshot.
   
   ### TESTING INSTRUCTIONS
   1. Create a Gantt chart with a category (Y-axis) field that has long and/or 
short label values.
   2. Confirm the category labels render fully to the left of the chart plot 
area, at multiple chart widths, without any letters being cut off.
   3. Confirm this holds both in Explore and after saving to a dashboard.
   4. `npm run test -- plugins/plugin-chart-echarts/test/Gantt` — includes new 
regression tests asserting the reserved label width uses the canvas ink extent 
(not just the advance width) and that the measurement font matches the rendered 
label's font.
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] 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