Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes label positioning in Funnel charts by introducing proper trapezoid geometry support. The changes enable labels to be positioned correctly based on the varying upper and lower widths of funnel shapes, rather than treating them as rectangles.
Key changes:
- Introduced
TrapezoidViewBoxtype to represent trapezoid geometry withupperWidthandlowerWidth - Updated label positioning logic to account for trapezoid shapes
- Added comprehensive test coverage for funnel label positions
Reviewed Changes
Copilot reviewed 26 out of 38 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/util/types.ts | Added TrapezoidViewBox type definition with trapezoid-specific properties |
| src/component/Label.tsx | Updated label positioning calculations to use trapezoid geometry |
| src/cartesian/Funnel.tsx | Modified to provide TrapezoidViewBox with proper upper/lower width values |
| src/context/chartLayoutContext.tsx | Added conversion utility between CartesianViewBox and TrapezoidViewBox |
| src/component/LabelList.tsx | Updated to use TrapezoidViewBox type |
| www/src/docs/apiExamples/Label.tsx | Added visual demo for funnel label positions |
| www/src/docs/apiExamples/Funnel.tsx | New file with funnel component examples |
| test/component/Label.getAttrsOfCartesianLabel.spec.ts | Added comprehensive tests for trapezoid label positioning |
| src/util/FunnelUtils.tsx | Updated type definitions for funnel trapezoid props |
| Multiple component files | Updated to provide trapezoid dimensions for non-trapezoid shapes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // TODO: This is not quite right. The width of the trapezoid changes with y. | ||
| // A percentage-based x should be relative to the width at that y. | ||
| // For now, we use the mid-height width as a reasonable approximation. |
There was a problem hiding this comment.
This TODO comment identifies a known limitation in percentage-based positioning for trapezoids. Consider creating a GitHub issue to track this technical debt so it doesn't get lost.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6473 +/- ##
==========================================
- Coverage 93.94% 93.89% -0.05%
==========================================
Files 418 419 +1
Lines 38486 38630 +144
Branches 4506 4518 +12
==========================================
+ Hits 36155 36272 +117
- Misses 2315 2342 +27
Partials 16 16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bundle ReportChanges will increase total bundle size by 5.03kB (0.2%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: recharts/bundle-es6Assets Changed:
view changes for bundle: recharts/bundle-umdAssets Changed:
view changes for bundle: recharts/bundle-cjsAssets Changed:
|
Description
Uses upper + lower width to properly position labels inside a Funnel.
Related Issue
Fixes #6427
Types of changes
Checklist: