Skip to content

fix: generalize getFinalAttribute fallback to all mark types to fix line growPoints crash#302

Merged
xile611 merged 1 commit intodevelopfrom
fix/line-growPoints-crash
Apr 13, 2026
Merged

fix: generalize getFinalAttribute fallback to all mark types to fix line growPoints crash#302
xile611 merged 1 commit intodevelopfrom
fix/line-growPoints-crash

Conversation

@xile611
Copy link
Copy Markdown
Contributor

@xile611 xile611 commented Apr 10, 2026

Problem

Line charts using the growPoints animation effect crash with:

TypeError: Cannot read properties of undefined (reading 'points')

This happens because getFinalAttribute() returns undefined for line graphics, and the VRender animation code (growPointsYIn/growPointsXIn) accesses .points on the result without null-checking.

Root Cause

The ensureRectMarkFinalAttributes method (introduced in PR #300) only patched rect and rect3d graphics with a getFinalAttribute() fallback. Line, area, and polygon graphics were not covered, causing growPoints animations to crash.

Fix

  • Renamed ensureRectMarkFinalAttributesensureMarkFinalAttributes
  • Removed the type restriction so the getFinalAttribute() fallback patch applies to all graphic types
  • The patch is universally safe — it only adds a fallback to graphic.attribute when getFinalAttribute() returns null/undefined
  • Added a unit test specifically for line graphic patching

Changes

  • packages/vstory-player/src/processor/chart/visibility.ts: Generalized patching to all mark types
  • packages/vstory-player/__tests__/unit/index.test.ts: Added test for line graphic case

The ensureRectMarkFinalAttributes method was only patching rect/rect3d
graphics. Line, area, and polygon graphics also need the getFinalAttribute
fallback when using growPoints animations (growPointsXIn/growPointsYIn),
which access graphic.getFinalAttribute().points.

Renamed to ensureMarkFinalAttributes and removed the type restriction so
the patch applies to all graphic types universally. Added a test for the
line graphic case.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
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

Generalizes the getFinalAttribute() fallback patching so non-rect marks (e.g., line) don’t crash when running growPoints* appear animations.

Changes:

  • Apply getFinalAttribute() fallback patching to all mark graphic types (not just rect / rect3d)
  • Rename ensureRectMarkFinalAttributesensureMarkFinalAttributes and update call sites
  • Add a unit test covering the line-mark / growPointsYIn scenario

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/vstory-player/src/processor/chart/visibility.ts Generalizes the recursive getFinalAttribute() fallback patch to all mark products/children before executing appear animations.
packages/vstory-player/tests/unit/index.test.ts Adds a regression test ensuring line graphics get patched so getFinalAttribute() returns an object with points.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@xile611 xile611 merged commit 56baa33 into develop Apr 13, 2026
9 of 11 checks passed
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.

3 participants