Skip to content

Add Map chart support (closes #100)#101

Merged
PeiyangYu merged 2 commits into
masterfrom
feat/issue-100-map-chart-support
May 14, 2026
Merged

Add Map chart support (closes #100)#101
PeiyangYu merged 2 commits into
masterfrom
feat/issue-100-map-chart-support

Conversation

@PeiyangYu

@PeiyangYu PeiyangYu commented May 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a Map chart series (type: "map") so users can render GEO/region maps such as the official USA example without writing a custom SeriesOption.
  • Mirrors the structure of existing charts (Funnel/Treemap/Heatmap): origin interfaces under org.icepear.echarts.origin.chart.map.* and Lombok data classes under org.icepear.echarts.charts.map.*, with a MapChart wrapper extending Chart<MapChart, MapSeries>.
  • Map-specific extras: MapItemStyle.areaColor, setMap, setRoam (Boolean/String overloads), setLayoutCenter / setLayoutSize, setBoundingCoords, setNameMap, setNameProperty, setProjection, setShowLegendSymbol, setMapValueCalculation, setAspectScale, setGeoIndex.

Public API added

  • MapChart
  • charts.map.MapSeries, MapDataItem, MapEmphasis, MapItemStyle
  • origin.chart.map.MapSeriesOption, MapStateOption, MapEmphasisOption, MapDataItemOption, MapItemStyleOption

Example usage

MapChart chart = new MapChart()
    .setTitle(new Title().setText("USA Population Estimates (2012)").setLeft("right"))
    .setTooltip(new Tooltip().setTrigger("item"))
    .setVisualMap(new ContinousVisualMap().setMin(500_000).setMax(38_000_000)
        .setColor(new String[]{"orangered","yellow","lightskyblue"}).setCalculable(true))
    .addSeries(new MapSeries()
        .setName("USA PopEstimates")
        .setMap("USA")
        .setRoam(true)
        .setItemStyle(new MapItemStyle().setAreaColor("rgb(135, 169, 240)").setBorderColor("#fff"))
        .setEmphasis(new MapEmphasis()
            .setLabel(new SeriesLabel().setShow(true))
            .setItemStyle(new MapItemStyle().setAreaColor("rgb(177, 195, 245)")))
        .setData(new MapDataItem[]{
            new MapDataItem().setName("California").setValue(38041430),
            new MapDataItem().setName("Texas").setValue(26059203),
            // ...
        }));

String json = new EChartsSerializer().toJson(chart.getOption());

Tests added (23 new tests, all passing locally)

  • simple/map/BasicMapTest — minimal happy-path snapshot
  • advanced/map/UsaMapChartTest — reproduces the issue's USA example
  • charts/map/MapSeriesTest — 19 unit tests covering setter overloads (roam Bool/String, layoutSize Number/String, BoxLayout overloads, raw Object data overload), null-omission semantics, areaColor nested under itemStyle, MapEmphasis.disabled, nameMap/nameProperty, boundingCoords, geoIndex, MapChart chaining
  • render/simple/RenderMapByChartTest — exercises the Handlebars render Engine end-to-end with the Map chart

Test plan

  • mvn test -Dtest=BasicMapTest — 1/1 pass
  • mvn test -Dtest=UsaMapChartTest — 1/1 pass
  • mvn test -Dtest=MapSeriesTest — 19/19 pass
  • mvn test -Dtest=RenderMapByChartTest — 2/2 pass
  • mvn test (full suite) — all 23 new tests pass; only the 3 pre-existing float-precision failures (TwoValueAxesInPolar1Test, TwoValueAxesInPolar2Test, BasicPolarLineTest) remain, present on master before this branch and unrelated to this change

Closes #100

CleanShot.2026-05-10.at.17.58.01.mp4

Adds a Map chart series (type: "map") so users can render GEO/region maps
such as the USA example without dropping down to a custom SeriesOption
implementation. Mirrors the structure used by other charts (Funnel,
Treemap, Heatmap): origin interfaces under origin/chart/map and Lombok
data classes under charts/map, plus a MapChart wrapper extending
Chart<MapChart, MapSeries>.

The new public API:
- MapChart, MapSeries, MapDataItem, MapEmphasis, MapItemStyle
- MapSeriesOption, MapStateOption, MapEmphasisOption,
  MapDataItemOption, MapItemStyleOption (with map-specific areaColor)

Covers: simple snapshot test, advanced USA-map snapshot reproducing the
example from the issue, render-engine smoke test, and direct unit tests
exercising every public setter (including roam/layoutSize overloads,
boundingCoords, nameMap, projection, emphasis flags). 23 new tests, all
passing.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This was referenced May 10, 2026
@icepear-jzx

Copy link
Copy Markdown
Member

Please follow the pattern in scripts/, define json files and generate java files by running config-to-java.py. Also format the generated files.

Adds scripts/config JSON definitions for the Map series following the
established Funnel/Treemap/Heatmap pattern, so MapSeries, MapDataItem,
MapEmphasis, MapItemStyle and the corresponding origin interfaces are
produced by scripts/config-to-java.py rather than hand-written.

Regenerated Java mirrors the previous hand-written files; only field
order shifts to put inherited fields ahead of own fields, matching what
the generator emits for every other chart.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@PeiyangYu

Copy link
Copy Markdown
Collaborator Author

Please follow the pattern in scripts/, define json files and generate java files by running config-to-java.py. Also format the generated files.

@icepear-jzx added

@PeiyangYu PeiyangYu merged commit ebcb0d0 into master May 14, 2026
1 check passed
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.

Support for GEO/Map charts

3 participants