Skip to content

New Label positions in Funnel#6473

Merged
ckifer merged 6 commits intomainfrom
funnel-labels
Oct 18, 2025
Merged

New Label positions in Funnel#6473
ckifer merged 6 commits intomainfrom
funnel-labels

Conversation

@PavelVanecek
Copy link
Collaborator

Description

Uses upper + lower width to properly position labels inside a Funnel.

Related Issue

Fixes #6427

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • I have added a storybook story or VR test, or extended an existing story or VR test to show my changes

@PavelVanecek PavelVanecek requested a review from Copilot October 17, 2025 23:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 TrapezoidViewBox type to represent trapezoid geometry with upperWidth and lowerWidth
  • 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.

Comment on lines +514 to +516
// 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.
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Oct 17, 2025

Codecov Report

❌ Patch coverage is 85.58952% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.89%. Comparing base (8a10fcd) to head (b32ae92).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
www/src/docs/apiExamples/Funnel.tsx 41.50% 31 Missing ⚠️
src/cartesian/Funnel.tsx 96.29% 1 Missing ⚠️
src/component/Label.tsx 98.21% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codecov
Copy link

codecov bot commented Oct 17, 2025

Bundle Report

Changes will increase total bundle size by 5.03kB (0.2%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.08MB 2.26kB (0.21%) ⬆️
recharts/bundle-es6 935.9kB 2.17kB (0.23%) ⬆️
recharts/bundle-umd 499.75kB 602 bytes (0.12%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
cartesian/Area.js 42 bytes 26.01kB 0.16%
cartesian/Bar.js 62 bytes 24.01kB 0.26%
cartesian/Line.js 46 bytes 23.69kB 0.19%
cartesian/Scatter.js 66 bytes 20.78kB 0.32%
component/Label.js 1.51kB 17.87kB 9.2% ⚠️
polar/Radar.js 42 bytes 16.35kB 0.26%
cartesian/Funnel.js -199 bytes 16.19kB -1.21%
cartesian/CartesianAxis.js 58 bytes 15.01kB 0.39%
cartesian/ReferenceLine.js 95 bytes 7.74kB 1.24%
context/chartLayoutContext.js 314 bytes 6.71kB 4.91%
cartesian/ReferenceArea.js 92 bytes 6.23kB 1.5%
cartesian/ReferenceDot.js 46 bytes 5.62kB 0.82%
view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js 602 bytes 499.75kB 0.12%
view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
cartesian/Area.js 42 bytes 27.8kB 0.15%
cartesian/Bar.js 62 bytes 25.5kB 0.24%
cartesian/Line.js 46 bytes 25.19kB 0.18%
cartesian/Scatter.js 66 bytes 22.28kB 0.3%
component/Label.js 1.53kB 19.66kB 8.42% ⚠️
polar/Radar.js 42 bytes 17.74kB 0.24%
cartesian/Funnel.js -199 bytes 17.67kB -1.11%
cartesian/CartesianAxis.js 58 bytes 16.23kB 0.36%
cartesian/ReferenceLine.js 95 bytes 8.89kB 1.08%
context/chartLayoutContext.js 382 bytes 7.72kB 5.21% ⚠️
cartesian/ReferenceArea.js 92 bytes 7.29kB 1.28%
cartesian/ReferenceDot.js 46 bytes 6.64kB 0.7%

@PavelVanecek PavelVanecek requested a review from ckifer October 18, 2025 14:16
@ckifer ckifer merged commit dbc7e7b into main Oct 18, 2025
24 of 28 checks passed
@PavelVanecek PavelVanecek deleted the funnel-labels branch October 19, 2025 04:41
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.

Recharts 3 LabelsList has incorrect position within FunnelChart after upgrade from 2.x

3 participants