Skip to content

feat(chart): add MONOTONE line interpolation via LineInterpolation enum#206

Merged
DemchaAV merged 2 commits into
developfrom
feat/chart-line-interpolation
Jun 17, 2026
Merged

feat(chart): add MONOTONE line interpolation via LineInterpolation enum#206
DemchaAV merged 2 commits into
developfrom
feat/chart-line-interpolation

Conversation

@DemchaAV

Copy link
Copy Markdown
Owner

Why

Smooth (Catmull-Rom) line charts look good but can overshoot local extremes — on sharp value swings the curve briefly leaves the range of the data it connects, so it claims values the data never had. There was no smooth-yet-accurate option: straight segments are exact but angular, the smooth curve is pretty but inaccurate.

What changed

  • New LineInterpolation enum (LINEAR / SMOOTH / MONOTONE) replaces the boolean smooth flag on ChartSpec.Line — a single explicit knob for line shape.
  • MONOTONE emits a Fritsch-Carlson monotone cubic in LineChartLayout: as smooth as SMOOTH, but each span is constrained to stay within the value range of its two endpoints, so the curve never overshoots and preserves the data's rises and falls.
  • All modes render through the same native PDF cubic operators — one PathNode per run, zero tessellation — so geometry stays deterministic and the layout hot path is unchanged.
  • Callers migrated (smooth(true)interpolation(LineInterpolation.SMOOTH)). The chart API is unreleased (@since 1.8.0), so no deprecation bridge was needed.
  • ChartShowcaseExample gains a SMOOTH-vs-MONOTONE comparison on a volatile series; the committed assets/readme/examples/chart-showcase.pdf preview is refreshed.

Verification

  • ./mvnw test -pl .1365 tests, 0 failures.
  • ChartLayoutResolverTest.monotoneCurveStaysWithinTheDataRangeWhileSmoothOvershoots — proves the monotone curve's bounding box stays inside the LINEAR data range (ground truth) while SMOOTH bulges past the plateau.
  • monotoneLineEmitsOneNativeBezierRun + layout snapshot charts/line_monotone.

DemchaAV added 2 commits June 17, 2026 10:20
Replace the boolean smooth flag on ChartSpec.Line with a LineInterpolation
enum (LINEAR / SMOOTH / MONOTONE) — one explicit knob for line shape. The
new MONOTONE mode emits a Fritsch-Carlson monotone cubic: as smooth as the
Catmull-Rom SMOOTH curve but constrained to never overshoot, so the line
stays within the value range of the points it spans. All modes render
through the same native PDF curve operators with zero tessellation, so
geometry stays deterministic and the layout hot path is unchanged.
…NE comparison

The hero preview now shows the two volatile-price cards stacked: SMOOTH
crests above the data's peak (overshoot) while MONOTONE stays within the
value range — the accuracy difference the new interpolation mode adds.
@DemchaAV DemchaAV merged commit e1ae03b into develop Jun 17, 2026
11 checks passed
@DemchaAV DemchaAV deleted the feat/chart-line-interpolation branch June 17, 2026 09:34
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