Skip to content

Add curve prop for monotone area/line interpolation#20

Open
KyleKreuter wants to merge 1 commit into
Boring-Software-Inc:mainfrom
KyleKreuter:monotone-curve
Open

Add curve prop for monotone area/line interpolation#20
KyleKreuter wants to merge 1 commit into
Boring-Software-Inc:mainfrom
KyleKreuter:monotone-curve

Conversation

@KyleKreuter

@KyleKreuter KyleKreuter commented Jul 16, 2026

Copy link
Copy Markdown

What

Adds an opt-in curve prop to <Area> / <Line> so continuous series can be drawn with monotone-cubic interpolation instead of the straight-segment default.

<Area dataKey="visits" curve="monotone" />
<Line dataKey="mobile" curve="monotone" />

The default stays "linear", so existing charts render exactly as before — this is non-breaking.

Why

The value line is resampled to the backing columns with a linear pass (resample in dither-paint.ts), so with few data points the fill and outline show hard kinks at every point. resampleMonotone smooths the line while staying honest: Fritsch–Carlson tangents guarantee monotonicity, so no false peaks or valleys are introduced between data points (unlike Catmull-Rom / natural cubics).

How

  • dither-paint.ts — add resampleMonotone (pure, no new dependency).
  • chart-context.tsxCurve type + optional curve on SeriesSpec.
  • area.tsx — thread the curve prop through series registration.
  • cartesian-canvas.tsx — pick the resampler per series; top and floor use the same one so the band stays consistent.
  • index.ts — export Curve.

Bars are unaffected (curve is optional and never set for <Bar>).

Tests

tests/dither-paint.test.ts covers node pass-through, sample count, the single-value case, no-overshoot on monotonic input, and endpoint parity with resample. Full suite: 33 passing.

Registry regenerated with npm run build:registry (r/core.json, r/area-chart.json, r/dither-kit.json).

Summary by Comp AI

No blocking issues found.

Written for commit b1d0aea. New commits will trigger a re-review. Generated by Comp AI.

@comp-ai-code-review

comp-ai-code-review Bot commented Jul 16, 2026

Copy link
Copy Markdown

Comp AI code review complete — no issues found.

Reviewed commit b1d0aea.

Posted by Comp AI Code Reviews.

@tripwire-dev

tripwire-dev Bot commented Jul 16, 2026

Copy link
Copy Markdown

passed — nothing tripped. good to merge.

View on Tripwire

@comp-ai-code-review comp-ai-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No blocking issues found across the changed files.

Posted by Comp AI Code Reviews.

@KyleKreuter

Copy link
Copy Markdown
Author
grafik grafik

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.

1 participant