Skip to content

Add Lines chart support#103

Merged
PeiyangYu merged 2 commits into
masterfrom
feat/lines-series
May 14, 2026
Merged

Add Lines chart support#103
PeiyangYu merged 2 commits into
masterfrom
feat/lines-series

Conversation

@PeiyangYu

@PeiyangYu PeiyangYu commented May 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds the lines series — draws lines/curves between coordinate pairs. The standard pick for flight paths, geo flows, and migration visualizations. Pairs naturally with map (PR Add Map chart support (closes #100) #101) and effectScatter (PR Add EffectScatter chart support #102) for the canonical "animated flows on a map" pattern.
  • Lines extends the base Chart (not CartesianCoordChart), so empty xAxis / yAxis arrays aren't auto-emitted — important when the user is using coordinateSystem: "geo". For cartesian2d usage, axes can be wired via Option directly.

Public API added

  • Lines
  • charts.lines.LinesSeries, LinesDataItem, LinesEmphasis, LinesEffect
  • origin.chart.lines.LinesSeriesOption, LinesStateOption, LinesEmphasisOption, LinesDataItemOption, LinesEffectOption

How to use

Cartesian (no map needed)

Lines chart = new Lines()
    .setTitle("Flight paths")
    .addSeries(new LinesSeries()
        .setCoordinateSystem("cartesian2d")
        .setPolyline(false)
        .setEffect(new LinesEffect().setShow(true).setSymbol("arrow").setTrailLength(0.7))
        .setData(new LinesDataItem[] {
            new LinesDataItem().setCoords(new Number[][] { {0, 0}, {50, 80} }),
            new LinesDataItem().setCoords(new Number[][] { {50, 80}, {120, 30} })
        }));

Geo (paired with the map series from PR #101)

new LinesSeries()
    .setCoordinateSystem("geo")
    .setEffect(new LinesEffect().setShow(true).setSymbol("arrow").setTrailLength(0.6))
    .setLineStyle(new LineStyle().setColor("#a6c8ff").setWidth(1).setOpacity(0.6))
    .setData(/* lng/lat pairs */);

For a runnable visual demo with 5 "flight paths" on a dark canvas, see src/test/java/org/icepear/echarts/demo/LinesDemo.java — run mvn test -Dtest=LinesDemo then open /tmp/lines-demo.html.

Tests added (25 new, all passing)

  • simple/lines/BasicLinesTest — snapshot
  • charts/lines/LinesSeriesTest — 21 unit tests covering every setter overload, all three coordinate systems, effect nesting, lineStyle nesting, emphasis flags, the no-empty-axis-arrays invariant, null-omission, and round-trip serialization
  • render/simple/RenderLinesByChartTest — Engine smoke test
  • demo/LinesDemo — opt-in HTML writer for visual inspection

Test plan

  • mvn test -Dtest=BasicLinesTest — 1/1
  • mvn test -Dtest=LinesSeriesTest — 21/21
  • mvn test -Dtest=RenderLinesByChartTest — 2/2
  • mvn test -Dtest=LinesDemo then open /tmp/lines-demo.html — animated arrows render correctly
  • mvn test (full suite) — 101 tests, only the 3 pre-existing polar/float-precision failures remain
CleanShot.2026-05-10.at.20.08.04.mp4

PeiyangYu and others added 2 commits May 10, 2026 19:40
Adds the lines series (type: "lines") — draws lines/curves between
coordinate pairs, the standard pick for flight paths, geo flows, and
migration visualizations. Pairs naturally with the map and effectScatter
series for animated map overlays.

The new public API:
- Lines (top-level wrapper, extends base Chart so xAxis/yAxis are not
  auto-emitted; users wire axes via Option for cartesian usage)
- LinesSeries, LinesDataItem, LinesEmphasis, LinesEffect

Key fields:
- coords: Number[][] on each LinesDataItem (start/end or polyline points)
- coordinateSystem: "geo" | "cartesian2d" | "polar"
- polyline, large, largeThreshold
- LinesEffect: show, period, delay, constantSpeed, symbol, symbolSize,
  color, trailLength, loop, roundTrip — drives the moving-symbol animation

Tests (25 new, all passing):
- BasicLinesTest (snapshot)
- LinesSeriesTest (21 unit tests covering every setter overload, all
  three coordinate systems, effect nesting, lineStyle nesting, emphasis
  flags, the no-empty-axis-arrays invariant, null-omission)
- RenderLinesByChartTest (Engine smoke test)
- LinesDemo (writes /tmp/lines-demo.html — opt-in)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds scripts/config JSON definitions for the Lines series so
LinesSeries, LinesEffect, LinesDataItem, LinesEmphasis and the
corresponding origin interfaces are produced by
scripts/config-to-java.py rather than hand-written. Field ordering on
the class shifts to put inherited fields ahead of own fields, matching
generator output across other charts. setSeriesLayoutBy collapses to a
single String setter because LinesSeriesOption does not extend
SeriesEncodeOptionMixin; no tests exercised the prior Object overload.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@PeiyangYu PeiyangYu merged commit 6662f86 into master May 14, 2026
1 check passed
@PeiyangYu PeiyangYu mentioned this pull request May 14, 2026
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.

2 participants