Skip to content

fix: handle graph points sharing one pixel - #127

Merged
chrispader merged 1 commit into
margelo:mainfrom
huytdps13400:fix/95-degenerate-graph-range
Aug 24, 2026
Merged

fix: handle graph points sharing one pixel#127
chrispader merged 1 commit into
margelo:mainfrom
huytdps13400:fix/95-degenerate-graph-range

Conversation

@huytdps13400

Copy link
Copy Markdown
Contributor

Summary

Root cause

The path sampler derives an array index from the relative pixel position. With a very wide X range, flooring can map both the first and last graph points to the same pixel. The resulting endX - startX value is zero, so the computed index becomes NaN and the code reads graphData[NaN].date.

A zero-width pixel span has only one drawable pixel. The sampler now selects index zero for that degenerate case while leaving the existing interpolation unchanged for every non-zero span.

Validation

  • yarn typecheck
  • yarn lint (0 errors; existing no-shadow warning in AnimatedLineGraph.tsx)
  • yarn test --runInBand
  • yarn prepare

The regression test failed on main with Cannot read properties of undefined (reading date), then passed with a finite path after the guard.

Fixes #95.

@chrispader

Copy link
Copy Markdown
Member

Thanks for the PR. LGTM!

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.

Cannot read property 'date' of undefined when range is too large

2 participants