Skip to content

fix: render points sharing one date - #131

Merged
chrispader merged 2 commits into
margelo:mainfrom
huytdps13400:fix/86-duplicate-date-points
Sep 17, 2026
Merged

chrispader merged 2 commits into
margelo:mainfrom
huytdps13400:fix/86-duplicate-date-points

Conversation

@huytdps13400

Copy link
Copy Markdown
Contributor

Summary

  • keep matching points inside a zero-duration X range
  • center the degenerate range on the canvas
  • draw every value at the shared X coordinate so Skia receives a visible vertical path

Root cause

When the first and last timestamps are equal, X normalization divides by zero. The resulting NaN causes getPointsInRange to discard every point before path creation. Even after normalizing the shared timestamp, the one-pixel sampler selects only the first point, leaving Skia with a move command but no drawable segment.

The patch maps the shared timestamp to the center of the range, rejects non-matching timestamps from an explicit zero-duration range, and preserves all same-date values at that X coordinate. The existing behavior for different dates that merely floor to one canvas pixel remains unchanged.

Validation

Using the repository Node.js version (22.20.0):

  • yarn test --runInBand — 5/5 tests pass
  • yarn typecheck
  • yarn lint — 0 errors; one existing no-shadow warning in AnimatedLineGraph.tsx
  • yarn prepare
  • git diff --check

Fixes #86

@riteshshukla04

Copy link
Copy Markdown
Collaborator

3 year old issue :)

@chrispader
chrispader merged commit 64957b2 into margelo:main Sep 17, 2026
@chrispader

Copy link
Copy Markdown
Member

I've added some more changes for better performance, thanks for the PR!

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.

Bug: Graph not shown if at least 2 points exists with same date

3 participants