Skip to content

fix: preserve irregularly spaced graph points - #135

Open
huytdps13400 wants to merge 1 commit into
margelo:mainfrom
huytdps13400:fix/103-irregular-time-sampling
Open

fix: preserve irregularly spaced graph points#135
huytdps13400 wants to merge 1 commit into
margelo:mainfrom
huytdps13400:fix/103-irregular-time-sampling

Conversation

@huytdps13400

Copy link
Copy Markdown
Contributor

Summary

  • sample graph data using each point's timestamp-derived X coordinate
  • preserve irregularly spaced intermediate values that the index-based sampler skipped
  • keep the existing two-pixel density cap and always retain boundary points

Fixes #103.

Root cause

The path sampler selected a data index as if points were uniformly distributed across the X range, then required that point's actual timestamp-derived X coordinate to match the sampled pixel. For irregular time series, those two positions diverge, so valid intermediate values were dropped from the Skia path.

The sampler now walks the already-filtered, chronologically ordered data and applies the same density limit to each point's real X coordinate. This keeps path command counts bounded while representing irregular timestamps correctly.

Verification

Using the repository Node.js version (22.20.0):

  • focused regression observed RED before the fix: expected 3 cubic commands, received 2
  • yarn test --runInBand — 2 suites, 4 tests passed
  • yarn typecheck
  • yarn lint — 0 errors; one pre-existing no-shadow warning in src/AnimatedLineGraph.tsx
  • yarn prepare
  • CI=1 yarn workspace react-native-graph-example expo export --platform web --output-dir /tmp/graph-103-web-dist
  • git diff --check

Scope

No public API or dependency changes. Static and animated graphs continue to create paths only when their input/layout changes, not per animation frame.

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.

Innacurate line drawing

1 participant