@amcharts/amcharts5-mcp 1.9.0 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -10
- package/content/SKILL.md +4 -0
- package/content/flow.md +2 -0
- package/content/gantt.md +2 -0
- package/content/hierarchy.md +2 -0
- package/content/json.md +501 -0
- package/content/map.md +2 -0
- package/content/pie.md +2 -0
- package/content/radar.md +2 -0
- package/content/stock.md +3 -0
- package/content/timeline.md +2 -0
- package/content/venn.md +2 -0
- package/content/wordcloud.md +2 -0
- package/content/xy.md +30 -0
- package/extended/examples/column-bar/column-chart-with-patterns.md +170 -0
- package/extended/examples/json-configs/flow-arc-diagram.md +198 -0
- package/extended/examples/json-configs/flow-chord-directed.md +211 -0
- package/extended/examples/json-configs/flow-chord-non-ribbon.md +253 -0
- package/extended/examples/json-configs/flow-chord.md +203 -0
- package/extended/examples/json-configs/flow-sankey.md +191 -0
- package/extended/examples/json-configs/gantt-multilevel.md +190 -0
- package/extended/examples/json-configs/gantt-simple.md +167 -0
- package/extended/examples/json-configs/gauge-bands.md +379 -0
- package/extended/examples/json-configs/gauge.md +94 -0
- package/extended/examples/json-configs/hierarchy-force-directed.md +131 -0
- package/extended/examples/json-configs/hierarchy-pack.md +137 -0
- package/extended/examples/json-configs/hierarchy-partition.md +131 -0
- package/extended/examples/json-configs/hierarchy-sunburst.md +160 -0
- package/extended/examples/json-configs/hierarchy-tree.md +135 -0
- package/extended/examples/json-configs/hierarchy-treemap.md +159 -0
- package/extended/examples/json-configs/hierarchy-voronoi-treemap.md +533 -0
- package/extended/examples/json-configs/map-altitude-arcs.md +238 -0
- package/extended/examples/json-configs/map-animating-along-lines.md +217 -0
- package/extended/examples/json-configs/map-auto-home.md +85 -0
- package/extended/examples/json-configs/map-clustered-points.md +387 -0
- package/extended/examples/json-configs/map-day-and-night.md +68 -0
- package/extended/examples/json-configs/map-globe-rotate-to-country.md +131 -0
- package/extended/examples/json-configs/map-globe-with-projected-circles.md +377 -0
- package/extended/examples/json-configs/map-pixel-map.md +175 -0
- package/extended/examples/json-configs/map-sankey-waypoints.md +845 -0
- package/extended/examples/json-configs/map-sankey.md +191 -0
- package/extended/examples/json-configs/map-satellite-day-and-night.md +81 -0
- package/extended/examples/json-configs/map-satellite-globe.md +120 -0
- package/extended/examples/json-configs/map-surface-bullets.md +195 -0
- package/extended/examples/json-configs/map-us-heat-map.md +378 -0
- package/extended/examples/json-configs/map-with-bubbles.md +344 -0
- package/extended/examples/json-configs/map-zoom-to-country.md +103 -0
- package/extended/examples/json-configs/pie-chart.md +109 -0
- package/extended/examples/json-configs/pie-donut-chart.md +113 -0
- package/extended/examples/json-configs/radar-date-range-columns.md +188 -0
- package/extended/examples/json-configs/radar-heat-map.md +1163 -0
- package/extended/examples/json-configs/radar-line.md +194 -0
- package/extended/examples/json-configs/sliced-funnel.md +112 -0
- package/extended/examples/json-configs/sliced-pictorial-stacked.md +98 -0
- package/extended/examples/json-configs/sliced-pyramid.md +111 -0
- package/extended/examples/json-configs/timeline-linear-process-diagram.md +1145 -0
- package/extended/examples/json-configs/timeline-serpentine-chart.md +509 -0
- package/extended/examples/json-configs/timeline-spiral-chart.md +301 -0
- package/extended/examples/json-configs/venn-diagram.md +146 -0
- package/extended/examples/json-configs/wordcloud-with-data.md +275 -0
- package/extended/examples/json-configs/wordcloud-with-text.md +75 -0
- package/extended/examples/json-configs/xy-100-percent-stacked-column.md +415 -0
- package/extended/examples/json-configs/xy-bubble.md +774 -0
- package/extended/examples/json-configs/xy-candlestick.md +556 -0
- package/extended/examples/json-configs/xy-clustered-column.md +474 -0
- package/extended/examples/json-configs/xy-column.md +250 -0
- package/extended/examples/json-configs/xy-comparing-periods.md +269 -0
- package/extended/examples/json-configs/xy-dumbbell-plot.md +324 -0
- package/extended/examples/json-configs/xy-gapless-date-axis.md +306 -0
- package/extended/examples/json-configs/xy-line.md +2145 -0
- package/extended/examples/json-configs/xy-multiple-synced-value-axes.md +483 -0
- package/extended/examples/json-configs/xy-percent-change-comparison.md +1185 -0
- package/extended/examples/json-configs/xy-pulsing-last-bullet.md +260 -0
- package/extended/examples/json-configs/xy-smoothed-line.md +272 -0
- package/extended/examples/json-configs/xy-stacked-and-clustered-column.md +517 -0
- package/extended/examples/json-configs/xy-stacked-column.md +483 -0
- package/extended/examples/json-configs/xy-stacked-step.md +324 -0
- package/extended/examples/maps/map-with-patterns.md +3 -3
- package/extended/getting-started/integrations/am5-chart-element.md +2 -0
- package/package.json +5 -2
- package/src/content.js +26 -1
- package/src/tools.js +210 -46
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# amCharts 5 MCP Server
|
|
2
2
|
|
|
3
|
-
An [MCP (Model Context Protocol)](https://modelcontextprotocol.io) server that gives AI assistants on-demand access to the complete amCharts 5 knowledge base: **160+ documentation pages**, **
|
|
3
|
+
An [MCP (Model Context Protocol)](https://modelcontextprotocol.io) server that gives AI assistants on-demand access to the complete amCharts 5 knowledge base: **160+ documentation pages**, **350+ code examples** (including 60+ complete JSON configs), and **1,300+ API reference pages**.
|
|
4
4
|
|
|
5
5
|
Works with **Claude Code**, **Claude Desktop**, **Cursor**, **Windsurf**, **VS Code + GitHub Copilot**, and any other MCP-compatible AI tool.
|
|
6
6
|
|
|
@@ -21,13 +21,15 @@ Point your AI client at:
|
|
|
21
21
|
https://mcp.amcharts.com/mcp
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
The amCharts 5 docs are also on [Context7](https://context7.com/amcharts/amcharts5) as `/amcharts/amcharts5`.
|
|
25
|
+
|
|
24
26
|
**Claude Code**
|
|
25
27
|
|
|
26
28
|
```bash
|
|
27
29
|
claude mcp add --transport http amcharts5 https://mcp.amcharts.com/mcp
|
|
28
30
|
```
|
|
29
31
|
|
|
30
|
-
**Claude Desktop
|
|
32
|
+
**Claude (claude.ai, Desktop)** — add amCharts 5 from the [Connectors Directory](https://claude.ai/directory/amcharts). Or Settings → Connectors → **Add custom connector**, then paste `https://mcp.amcharts.com/mcp`.
|
|
31
33
|
|
|
32
34
|
**Cursor** — `.cursor/mcp.json`:
|
|
33
35
|
|
|
@@ -66,7 +68,7 @@ claude mcp add --transport http amcharts5 https://mcp.amcharts.com/mcp
|
|
|
66
68
|
}
|
|
67
69
|
```
|
|
68
70
|
|
|
69
|
-
**ChatGPT** (
|
|
71
|
+
**ChatGPT** (also on the Free plan) — open [Plugins](https://chatgpt.com/plugins) → **+** → **Add custom MCP server**. Give it a name, set the URL to `https://mcp.amcharts.com/mcp` and Authentication to **No authentication**, then **Create as a plugin**. In a chat, type **@amCharts** to use it.
|
|
70
72
|
|
|
71
73
|
**Cline** (VS Code extension) — open the **MCP Servers** panel → **Remote Servers**, paste `https://mcp.amcharts.com/mcp`, or add to its MCP settings JSON:
|
|
72
74
|
|
|
@@ -204,15 +206,15 @@ npm start
|
|
|
204
206
|
|
|
205
207
|
| Tool | Description |
|
|
206
208
|
|------|-------------|
|
|
207
|
-
| `get_core_reference` | Get core amCharts 5 docs — setup, themes, colors, events, common pitfalls |
|
|
208
|
-
| `get_chart_reference` | Get
|
|
209
|
+
| `get_core_reference` | Get core amCharts 5 docs — setup, themes, colors, events, common pitfalls. An overview: its first sections, up to 12,000 characters, and a list of the others; `full: true` for the whole file |
|
|
210
|
+
| `get_chart_reference` | Get the reference for a chart type (e.g. "pie", "sankey", "xy"). One longer than 12,000 characters comes as an overview with the rest listed for `get_section`; `full: true` for the whole file |
|
|
209
211
|
| `list_chart_types` | List all available chart types and their keywords |
|
|
210
212
|
| `search_docs` | Search the skill reference docs by keyword (`scope: "all"` adds the full docs, API reference and examples) |
|
|
211
213
|
| `search_all` | Search across **everything** — skill docs, full documentation, and code examples |
|
|
212
214
|
| `get_doc` | Get a full documentation page (e.g. "charts/xy-chart/axes", "concepts/events") |
|
|
213
|
-
| `get_section` | Get a specific section from a reference file by heading |
|
|
215
|
+
| `get_section` | Get a specific section from a reference file by heading (a `###` subsection heading returns just that subsection) |
|
|
214
216
|
| `get_quick_start` | Get a minimal working template for any chart type |
|
|
215
|
-
| `list_examples` | Browse all
|
|
217
|
+
| `list_examples` | Browse all 350+ examples, optionally filtered by category |
|
|
216
218
|
| `get_example` | Get the full code for a specific example |
|
|
217
219
|
| `get_api_reference` | Get the API reference for a class, interface or function — settings with their defaults, events, inheritance and the import line |
|
|
218
220
|
| `list_geodata` | Find map (geodata) files — world, continents, countries, regional packs and the per-Congress US congressional district packs — with each file's CDN path, script global and ES import |
|
|
@@ -231,13 +233,13 @@ Once connected, your AI assistant can:
|
|
|
231
233
|
|
|
232
234
|
## Content
|
|
233
235
|
|
|
234
|
-
The server includes **1,
|
|
236
|
+
The server includes **1,900+ documents**:
|
|
235
237
|
|
|
236
238
|
- **160+ documentation pages** — getting started, chart guides, concepts (themes, events, adapters, data binding, animations, accessibility, etc.), and framework integration guides for amCharts' React, Vue, Angular, Svelte and React Native packages (with Next.js, Nuxt, SvelteKit, React Router and Remix 3)
|
|
237
|
-
- **
|
|
239
|
+
- **350+ code examples** — 290+ working demos across 16 categories including column/bar, line/area, pie/donut, maps, hierarchy, flow, radar/polar, stock, gauges, Gantt, timeline, and more, plus 60+ complete JSON configs from the amCharts npm package
|
|
238
240
|
- **1,300+ API reference pages** — every class, interface and function in the amCharts 5 library, generated from the release's typings: settings with their real defaults (theme rules included), events, properties, data item fields, the inheritance chain and the import line
|
|
239
241
|
- **670+ geodata entries** — every map in `@amcharts/amcharts5-geodata`, for `list_geodata`
|
|
240
|
-
- **Curated skill reference** — quick-start templates
|
|
242
|
+
- **Curated skill reference** — quick-start templates, chart-specific guides and a guide to writing JSON configs, from the [amCharts 5 AI Skill](https://github.com/amcharts/amcharts5-skill)
|
|
241
243
|
|
|
242
244
|
## Security
|
|
243
245
|
|
package/content/SKILL.md
CHANGED
|
@@ -87,6 +87,7 @@ Based on the chart type the user is building, read the relevant reference file f
|
|
|
87
87
|
| Word cloud, tag cloud, sentence cloud | `references/wordcloud.md` |
|
|
88
88
|
| Venn diagram, set overlap visualization | `references/venn.md` |
|
|
89
89
|
| Interactive controls: buttons, sliders, steppers, color pickers | `references/ui-elements.md` |
|
|
90
|
+
| A chart as a JSON config: "JSON config", "amCharts JSON", a `<am5-chart>` element, a framework package's `config` prop, a Chart Maker link | `references/json.md` (with the chart type's reference for its settings) |
|
|
90
91
|
|
|
91
92
|
If the chart type is unclear, start with `references/xy.md` — XY charts are by far the most common.
|
|
92
93
|
|
|
@@ -741,6 +742,8 @@ Without `dateFormat`, since 5.21.1 the browser's `Date` parses the strings, so I
|
|
|
741
742
|
|
|
742
743
|
## Serializing to JSON (ChartSerializer / JsonParser)
|
|
743
744
|
|
|
745
|
+
**To write a config by hand** (a "JSON config", `<am5-chart>`, a framework package's `config` prop, a Chart Maker link), read `references/json.md`. It covers the exact format, with a complete config per chart family. A config is not `{ "chart": …, "series": … }`; every object has `"type"`, its options go in `"settings"`, and its parts and data go in `"properties"`.
|
|
746
|
+
|
|
744
747
|
`am5plugins_json.ChartSerializer` turns a live chart into a JSON config and `am5plugins_json.JsonParser` rebuilds it (`await parser.parse(config, { parent: root.container })`). Rules that keep round-trips working:
|
|
745
748
|
|
|
746
749
|
- **Serialize the chart's top-level container child:** `serializer.serializeAll(root.container.children.getIndex(0))` — the chart, or on chart-less types (hierarchy, flow, word cloud, Venn) the series itself. Before 5.21.0 a series placed straight in `root.container`, or one whose `selectedDataItem` points back at itself, overflowed the stack (`Maximum call stack size exceeded`) or broke `JSON.stringify`; 5.21.0 serializes them. A drilled-down hierarchy's `selectedDataItem` is still not restored (it is written as `"@self.dataItems.-1"`).
|
|
@@ -1034,6 +1037,7 @@ onMount(() => { const root = am5.Root.new(chartdiv); /* ... */ return () => root
|
|
|
1034
1037
|
39. **Several colors in one `am5.Graphics` `draw`** — `endFill()` fills everything since the last `beginPath()`, so start each color with `display.beginPath()`, or the last color paints over all shapes. Don't give such a Graphics its own `fill` either: after `draw` runs it fills the current path once more, so the last shape takes the Graphics' own `fill` (the default theme sets none). E.g. `draw: function (display) { display.beginPath(); display.beginFill(am5.color(0xff0000)); display.drawRect(0, 0, 10, 10); display.endFill(); display.beginPath(); display.beginFill(am5.color(0x0000ff)); display.drawRect(10, 0, 10, 10); display.endFill(); }`.
|
|
1035
1038
|
40. **Changing a value on a data item moves nothing** — series draw from the working values: set `valueYWorking` (XY) or `valueWorking` (pie) along with the value, or use `series.data.setIndex()`. See "Dynamic data".
|
|
1036
1039
|
41. **A setting changed after a hover snaps back on unhover** — the `"default"` state keeps the value from before the first hover. Change it there too: `sprite.states.lookup("default")?.set("fill", c)`. See "States".
|
|
1040
|
+
42. **`templateField` goes on the template, not on the series** — per-item settings from data rows are read by the elements a template makes: `series.columns.template.set("templateField", "columnSettings")`, likewise `slices.template`, `mapPolygons.template` or a bullet sprite. Set on the series, `templateField` does nothing and every column stays the same. For a pattern per column, see `references/xy.md` → "Different pattern per column".
|
|
1037
1041
|
|
|
1038
1042
|
## Easing functions
|
|
1039
1043
|
|
package/content/flow.md
CHANGED
package/content/gantt.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Gantt Chart
|
|
2
2
|
|
|
3
|
+
> **As a JSON config:** see `references/json.md`. The settings below go into each object's `"settings"` there.
|
|
4
|
+
|
|
3
5
|
Docs: https://www.amcharts.com/docs/v5/charts/gantt/
|
|
4
6
|
|
|
5
7
|
Gantt is a standalone chart class (not just a simulated XY chart). It auto-creates axes, series, and toolbar — you only provide data. It supports editable tasks, task linking, progress tracking, collapsible groups, weekends/holidays, and a color picker.
|
package/content/hierarchy.md
CHANGED
package/content/json.md
ADDED
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
# JSON Configs — Writing a Chart as JSON
|
|
2
|
+
|
|
3
|
+
A JSON config describes a chart as data. The JSON plugin's `JsonParser` builds the chart from it. Write one when the user asks for a "JSON config" or "amCharts JSON", a `<am5-chart>` element, the `config` prop of an amCharts framework package, or a Chart Maker link. For a chart written in code, use the chart type's reference instead.
|
|
4
|
+
|
|
5
|
+
What code passes to `.new(root, { … })` goes into `settings` here, unchanged. Only the wrapping differs, and it must be exact: the parser does not guess.
|
|
6
|
+
|
|
7
|
+
## Where a config goes
|
|
8
|
+
|
|
9
|
+
| Destination | How |
|
|
10
|
+
|---|---|
|
|
11
|
+
| HTML page | `<am5-chart config='…'>` or `<am5-chart src="chart.json">` (see "Delivering a config") |
|
|
12
|
+
| JavaScript | `am5plugins_json.JsonParser.new(root).parse(config, { parent: root.container })`. It returns a promise of the chart. |
|
|
13
|
+
| React, Vue, Angular, Svelte, React Native | the package's `config` prop or input, e.g. `<AmChart config={config} themes={[am5themes_Animated]} />` (SKILL.md "Frameworks") |
|
|
14
|
+
| Chart Maker (live.amcharts.com) | a link that carries the config (see "Delivering a config") |
|
|
15
|
+
|
|
16
|
+
**Themes are not part of a config.** Pass them separately: the element's `themes` attribute, the packages' `themes` prop, `root.setThemes()` in code, or the link's `theme` parameter. Never put `"themes"` in a config.
|
|
17
|
+
|
|
18
|
+
**Script files.** With script tags, load `index.js`, then `plugins/json.js`, then every chart package the config uses, plus geodata for maps. The parser does not load a missing package from the CDN: without `percent.js`, a pie config fails with "Cannot read properties of undefined (reading 'call')". With npm, the parser imports chart packages itself.
|
|
19
|
+
|
|
20
|
+
| Family | Files after `index.js` and `plugins/json.js` |
|
|
21
|
+
|---|---|
|
|
22
|
+
| XY | `xy.js` |
|
|
23
|
+
| Pie, donut, funnel, pyramid | `percent.js` |
|
|
24
|
+
| Map | `map.js`, plus the geodata, e.g. `geodata/worldLow.js` |
|
|
25
|
+
| Sankey, chord, arc | `flow.js` |
|
|
26
|
+
| Treemap, sunburst, force-directed, pack | `hierarchy.js` |
|
|
27
|
+
| Radar, gauge | `xy.js`, `radar.js` |
|
|
28
|
+
|
|
29
|
+
All files are at `https://cdn.amcharts.com/lib/5/`. Theme files, e.g. `themes/Animated.js`, go after the chart packages.
|
|
30
|
+
|
|
31
|
+
## The rules
|
|
32
|
+
|
|
33
|
+
### 1. Every amCharts object has `"type"`
|
|
34
|
+
|
|
35
|
+
The value is the class name without a namespace: `"XYChart"`, not `"am5xy.XYChart"` (that fails with "Unknown object type `am5xy.XYChart`"). The top level is the chart itself, e.g. `XYChart`, `PieChart`, `SlicedChart`, `MapChart`, `RadarChart` or `Gantt`. Families with no chart object put the series at the top: `Sankey`, `Chord`, `Treemap`, `ForceDirected`, `WordCloud`, `Venn`, or a `Container` that holds one. A config without a top-level `type` builds no chart.
|
|
36
|
+
|
|
37
|
+
### 2. `settings` and `properties`
|
|
38
|
+
|
|
39
|
+
An object has these keys and no others:
|
|
40
|
+
|
|
41
|
+
| Key | Holds |
|
|
42
|
+
|---|---|
|
|
43
|
+
| `type` | the class name |
|
|
44
|
+
| `settings` | what `.new(root, { … })` takes in code |
|
|
45
|
+
| `properties` | the object's parts and lists: `series`, `xAxes`, `yAxes`, `data`, `bullets` (an axis: `bullet`), and templates such as `columns`, `slices`, `mapPolygons`, `nodes` |
|
|
46
|
+
| `children` | elements or `"#name"` refs pushed into the object's `children`, e.g. a `Legend` (add `"index": 0` to put one first) |
|
|
47
|
+
| `refs` | named objects, used elsewhere as `"#name"` |
|
|
48
|
+
| `states` | `[{ "key": "hover", "settings": { … } }]` |
|
|
49
|
+
|
|
50
|
+
Settings placed next to `type` are silently ignored. `{ "type": "PieSeries", "valueField": "value" }` builds a series whose slices have no values.
|
|
51
|
+
|
|
52
|
+
An object inside `settings` with a `type` is built, e.g. `"renderer": { "type": "AxisRendererX" }` or `"tooltip": { "type": "Tooltip" }`. An object inside `settings` without one is a plain value, e.g. `"baseInterval": { "timeUnit": "day", "count": 1 }`. In `properties`, a block without `type` configures the part that already exists. A template is reached through `properties.template`:
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"columns": {
|
|
57
|
+
"properties": {
|
|
58
|
+
"template": {
|
|
59
|
+
"settings": { "cornerRadiusTL": 4, "cornerRadiusTR": 4, "tooltipText": "{valueY}" },
|
|
60
|
+
"states": [{ "key": "hover", "settings": { "fillOpacity": 0.7 } }]
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
That is `series.columns.template.setAll({ … })` and `series.columns.template.states.create("hover", { … })`, placed in the series' `properties`. Arrays in `properties` push into lists: `"series": [ … ]` is `chart.series.push(…)` for each item.
|
|
68
|
+
|
|
69
|
+
### 3. Data goes in `properties.data`
|
|
70
|
+
|
|
71
|
+
Never put data in `settings` or beside `type`: the series gets no data items. `"data"` is either the rows inline or a `"#name"` ref to rows in `refs`. Use a ref when several objects take the same rows. In XY charts, the `CategoryAxis` needs the rows too, as it does in code.
|
|
72
|
+
|
|
73
|
+
- Rows are plain JSON. Dates are timestamps in milliseconds (`1704067200000`), because JSON has no dates and a config has no data processor.
|
|
74
|
+
- The parser does not read inside a row, so strings in rows need no escaping and `Color` objects in rows stay plain objects.
|
|
75
|
+
- A row that must hold a color or a ref needs `"__parse": true`, and so does each object nested in it: `{ "country": "Chile", "bulletSettings": { "fill": { "type": "Color", "value": "#86a965" }, "__parse": true }, "__parse": true }`. The strings in such a row are read too, so escape a leading `#` or `@` there (rule 6).
|
|
76
|
+
- A row with a column named `type`, at any depth (e.g. in hierarchy `children`), needs `"__parse": false` on the top row. Without it, the parser takes the column for a class name and fails with "Unknown object type".
|
|
77
|
+
- Serialized configs also put `"__parse": true` on rows that hold objects or arrays, such as hierarchy `children`. Hand-written rows do not need it.
|
|
78
|
+
|
|
79
|
+
### 4. `refs` and `"#name"`
|
|
80
|
+
|
|
81
|
+
`refs` is an array of groups. Each group is an object of `name: value` pairs. A ref can use refs from earlier groups, so put each in dependency order: data, then axes and templates, then series. Use one ref per group, as serialized configs do. `refs` written as a single object, a form the docs also show, is one group: a series in it cannot use the axes beside it, and the chart fails ("Cannot read properties of undefined"). Refer to a ref anywhere with `"#name"`, plus a path if needed: `"#series-0.dataItems"` (a property), `"#series-0.get('fill')"` (a setting).
|
|
82
|
+
|
|
83
|
+
XY axes live in `refs`. The chart lists them, and each series points at them:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"type": "XYChart",
|
|
88
|
+
"properties": { "xAxes": ["#axis-0"], "yAxes": ["#axis-1"], "series": ["#series-0"] },
|
|
89
|
+
"refs": [
|
|
90
|
+
{ "data-0": [{ "month": "Jan", "sales": 120 }, { "month": "Feb", "sales": 145 }] },
|
|
91
|
+
{ "axis-0": { "type": "CategoryAxis", "settings": { "categoryField": "month", "renderer": { "type": "AxisRendererX" } }, "properties": { "data": "#data-0" } } },
|
|
92
|
+
{ "axis-1": { "type": "ValueAxis", "settings": { "renderer": { "type": "AxisRendererY" } } } },
|
|
93
|
+
{ "series-0": { "type": "ColumnSeries", "settings": { "xAxis": "#axis-0", "yAxis": "#axis-1", "categoryXField": "month", "valueYField": "sales" }, "properties": { "data": "#data-0" } } }
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
A legend lists XY series as `"data": ["#series-0", "#series-1"]`, and pie slices as `"data": "#series-0.dataItems"`.
|
|
99
|
+
|
|
100
|
+
### 5. Colors, percents, layouts
|
|
101
|
+
|
|
102
|
+
| Code | JSON |
|
|
103
|
+
|---|---|
|
|
104
|
+
| `am5.color(0xe05a47)` | `{ "type": "Color", "value": "#e05a47" }` |
|
|
105
|
+
| `am5.percent(50)` | `{ "type": "Percent", "value": 50 }` |
|
|
106
|
+
| `root.verticalLayout` | `"vertical"` (also `"horizontal"`, `"grid"`) |
|
|
107
|
+
| `root.interfaceColors.get("background")` | `"@root.interfaceColors.get('background')"` (5.21.0+) |
|
|
108
|
+
| `chart.get("colors").getIndex(3)` | `"@colors.getIndex(3)"` (5.21.3+, in settings, not in data rows) |
|
|
109
|
+
| `chart.appear(1000, 100)`, `series.appear(1000)` | `"autoAppear": true, "appearDuration": 1000, "appearDelay": 100` in the chart's and series' `settings` (5.21.0+) |
|
|
110
|
+
|
|
111
|
+
A bare hex string is wrong: `"fill": "#e05a47"` is read as a ref and fails with "Could not find ref #e05a47". `"50%"` stays a string, not a percent. As in code, use the theme's colors unless the user asks for specific ones. Serialized configs write layouts as `{ "type": "VerticalLayout" }`, which also works.
|
|
112
|
+
|
|
113
|
+
### 6. Strings that start with `#` or `@`
|
|
114
|
+
|
|
115
|
+
The parser reads every string in `settings`, `properties`, `states` and arrays. A string there that starts with `#` or `@` is a ref. A label text `"#1 product"` fails with "Could not find ref #1 product". Double the first character to mean the text itself: `"##1 product"`, `"@@team"`. Strings in data rows without `"__parse": true` are not read, so they need no escaping.
|
|
116
|
+
|
|
117
|
+
Built-in `@` refs: `@root` (the Root), `@colors` (the theme's palette), `@series` (inside a series' `properties.bullets`), `@axis` (inside an axis's `properties.bullet`), and `@self`, the object being configured, e.g. `"selectedDataItem": "@self.dataItems.0"` on a hierarchy series.
|
|
118
|
+
|
|
119
|
+
### 7. Bullets
|
|
120
|
+
|
|
121
|
+
`properties.bullets` is an array of `Bullet` objects. The parser turns each into the bullet function:
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"bullets": [{
|
|
126
|
+
"type": "Bullet",
|
|
127
|
+
"settings": {
|
|
128
|
+
"sprite": { "type": "Circle", "settings": { "radius": 5, "fill": "@series.get('fill')" } }
|
|
129
|
+
}
|
|
130
|
+
}]
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 8. Maps
|
|
135
|
+
|
|
136
|
+
- `"geoJSON": "am5geodata_worldLow"` (a string) names the geodata. The name is `am5geodata_` plus the path under `geodata/`, with `/` written as `_` (`geodata/region/usa/caLow.js` → `am5geodata_region_usa_caLow`; see `references/map.md`).
|
|
137
|
+
- With script tags, load the geodata's script (`geodata/worldLow.js`) first; it defines a global of that name.
|
|
138
|
+
- With npm, import it and pass it in `resources` (5.21.4+): `JsonParser.new(root).parse(config, { parent: root.container, resources: { am5geodata_worldLow } })`, `element.resources = { am5geodata_worldLow }` on an `<am5-chart>`, or the framework packages' `resources` prop (their releases for 5.21.4). Before 5.21.4, set `window.am5geodata_worldLow = am5geodata_worldLow` after importing it.
|
|
139
|
+
- If the geodata isn't found, the map is blank. Since 5.21.4 the parser logs a warning; before that, no error appears.
|
|
140
|
+
- The projection is a name in `settings`: `"projectionName": "geoNaturalEarth1"` for `am5map.geoNaturalEarth1()`. Next to `type` it is ignored.
|
|
141
|
+
- Heat rules are plain objects, not amCharts objects, so each one needs `"__parse": true`. Without it, `target` and the colors stay unread and the chart throws. The series also needs `"calculateAggregates": true` unless the rule sets `minValue` and `maxValue`. Without either, every country gets the middle color. The `target` is a `Template` in `refs`, which the series also uses as its `mapPolygons` template (see "Countries colored by value" under "Maps").
|
|
142
|
+
- Complete map configs (countries colored by value, a few countries highlighted) are in "Maps" below.
|
|
143
|
+
|
|
144
|
+
### 9. Root settings and locales
|
|
145
|
+
|
|
146
|
+
An optional top-level `"root": { "settings": { … }, "properties": { … } }` applies to the Root before the chart is built. `"properties": { "locale": "am5locales_de_DE" }` names the locale, found the same way as geodata (rule 8):
|
|
147
|
+
- with script tags, load `locales/de_DE.js` first; it defines a global of that name;
|
|
148
|
+
- with npm, import it and pass it in `resources` (5.21.4+), e.g. `resources: { am5locales_de_DE }`. Before 5.21.4, set `window.am5locales_de_DE = am5locales_de_DE` after importing it.
|
|
149
|
+
|
|
150
|
+
Since 5.21.4 a locale that isn't found logs a warning.
|
|
151
|
+
|
|
152
|
+
### 10. What a config cannot hold
|
|
153
|
+
|
|
154
|
+
No functions (adapters, event handlers, bullet functions with logic, heat-rule `customFunction`, a `projection` object, the data processor), no themes, no method calls (`setAll`, `appear`, `am5.color`) and no `Date` objects. Use the declarative forms above instead: `autoAppear`, `projectionName`, `Bullet` objects, `heatRules`, `templateField` with per-row settings, and timestamps. Code that is still needed runs after `parse()` resolves, on the built chart:
|
|
155
|
+
|
|
156
|
+
```js
|
|
157
|
+
parser.parse(config, { parent: root.container }).then(function (chart) {
|
|
158
|
+
chart.series.getIndex(0).slices.template.events.on("click", function (ev) { /* … */ });
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Common mistakes
|
|
163
|
+
|
|
164
|
+
| Wrong | Right |
|
|
165
|
+
|---|---|
|
|
166
|
+
| `{ "chart": { "type": "PieChart" }, "series": [ … ] }`: no top-level `type`. The parser rejects it ("When using the parent setting, the entity must be a Sprite"); Chart Maker says "That configuration has no chart type". | `{ "type": "PieChart", "properties": { "series": [ … ] } }` |
|
|
167
|
+
| `{ "type": "PieSeries", "valueField": "value", "categoryField": "category" }` | `{ "type": "PieSeries", "settings": { "valueField": "value", "categoryField": "category" } }` |
|
|
168
|
+
| `"data": [ … ]` beside `type` or in `settings` | `"properties": { "data": [ … ] }` |
|
|
169
|
+
| A series or axis without `type` | `"type": "ColumnSeries"`, `"type": "ValueAxis"`, and `"type": "AxisRendererY"` on the renderer |
|
|
170
|
+
| `"type": "am5xy.LineSeries"` | `"type": "LineSeries"` |
|
|
171
|
+
| `"fill": "#ff0000"`, `"width": "50%"` | `{ "type": "Color", "value": "#ff0000" }`, `{ "type": "Percent", "value": 50 }` |
|
|
172
|
+
| `"geoJSON": am5geodata_worldLow` (not JSON) or the GeoJSON pasted in | `"geoJSON": "am5geodata_worldLow"`, with the geodata loaded |
|
|
173
|
+
| A CategoryAxis with no data | `"properties": { "data": "#data-0" }` on the axis too |
|
|
174
|
+
| A series in the same `refs` group as the axes it uses | Axes in an earlier group |
|
|
175
|
+
| `"themes": [ … ]` in the config | Themes passed beside the config |
|
|
176
|
+
|
|
177
|
+
## Complete configs
|
|
178
|
+
|
|
179
|
+
Each config below was parsed with amCharts 5.21.3 and checked to build its chart. Copy the structure, then change the data and settings.
|
|
180
|
+
|
|
181
|
+
### XY: column chart with a category axis, legend and cursor
|
|
182
|
+
|
|
183
|
+
Needs `index.js`, `plugins/json.js`, `xy.js`.
|
|
184
|
+
|
|
185
|
+
```json
|
|
186
|
+
{
|
|
187
|
+
"type": "XYChart",
|
|
188
|
+
"settings": {
|
|
189
|
+
"layout": "vertical",
|
|
190
|
+
"cursor": { "type": "XYCursor" },
|
|
191
|
+
"autoAppear": true, "appearDuration": 1000, "appearDelay": 100
|
|
192
|
+
},
|
|
193
|
+
"properties": { "xAxes": ["#axis-0"], "yAxes": ["#axis-1"], "series": ["#series-0", "#series-1"] },
|
|
194
|
+
"children": [{
|
|
195
|
+
"type": "Legend",
|
|
196
|
+
"settings": { "centerX": { "type": "Percent", "value": 50 }, "x": { "type": "Percent", "value": 50 } },
|
|
197
|
+
"properties": { "data": ["#series-0", "#series-1"] }
|
|
198
|
+
}],
|
|
199
|
+
"refs": [
|
|
200
|
+
{ "data-0": [
|
|
201
|
+
{ "quarter": "Q1", "y2024": 120, "y2025": 145 },
|
|
202
|
+
{ "quarter": "Q2", "y2024": 135, "y2025": 160 },
|
|
203
|
+
{ "quarter": "Q3", "y2024": 128, "y2025": 172 },
|
|
204
|
+
{ "quarter": "Q4", "y2024": 150, "y2025": 190 }
|
|
205
|
+
] },
|
|
206
|
+
{ "axis-0": {
|
|
207
|
+
"type": "CategoryAxis",
|
|
208
|
+
"settings": {
|
|
209
|
+
"categoryField": "quarter",
|
|
210
|
+
"renderer": { "type": "AxisRendererX", "settings": { "cellStartLocation": 0.1, "cellEndLocation": 0.9 } }
|
|
211
|
+
},
|
|
212
|
+
"properties": { "data": "#data-0" }
|
|
213
|
+
} },
|
|
214
|
+
{ "axis-1": {
|
|
215
|
+
"type": "ValueAxis",
|
|
216
|
+
"settings": { "min": 0, "renderer": { "type": "AxisRendererY" } }
|
|
217
|
+
} },
|
|
218
|
+
{ "series-0": {
|
|
219
|
+
"type": "ColumnSeries",
|
|
220
|
+
"settings": {
|
|
221
|
+
"name": "2024", "xAxis": "#axis-0", "yAxis": "#axis-1",
|
|
222
|
+
"categoryXField": "quarter", "valueYField": "y2024",
|
|
223
|
+
"tooltip": { "type": "Tooltip", "settings": { "labelText": "{name}: {valueY}" } },
|
|
224
|
+
"autoAppear": true, "appearDuration": 1000
|
|
225
|
+
},
|
|
226
|
+
"properties": {
|
|
227
|
+
"data": "#data-0",
|
|
228
|
+
"columns": { "properties": { "template": { "settings": { "cornerRadiusTL": 4, "cornerRadiusTR": 4 } } } }
|
|
229
|
+
}
|
|
230
|
+
} },
|
|
231
|
+
{ "series-1": {
|
|
232
|
+
"type": "ColumnSeries",
|
|
233
|
+
"settings": {
|
|
234
|
+
"name": "2025", "xAxis": "#axis-0", "yAxis": "#axis-1",
|
|
235
|
+
"categoryXField": "quarter", "valueYField": "y2025",
|
|
236
|
+
"tooltip": { "type": "Tooltip", "settings": { "labelText": "{name}: {valueY}" } },
|
|
237
|
+
"autoAppear": true, "appearDuration": 1000
|
|
238
|
+
},
|
|
239
|
+
"properties": {
|
|
240
|
+
"data": "#data-0",
|
|
241
|
+
"columns": { "properties": { "template": { "settings": { "cornerRadiusTL": 4, "cornerRadiusTR": 4 } } } }
|
|
242
|
+
}
|
|
243
|
+
} }
|
|
244
|
+
]
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
For a line chart over time, use a `DateAxis` with `"baseInterval": { "timeUnit": "day", "count": 1 }`, `LineSeries` with `"valueXField": "date"`, and timestamps in the rows. A `DateAxis` takes no `data`.
|
|
249
|
+
|
|
250
|
+
### Pie with a legend
|
|
251
|
+
|
|
252
|
+
Needs `index.js`, `plugins/json.js`, `percent.js`. For a donut, add `"innerRadius": { "type": "Percent", "value": 50 }` to the chart's `settings`.
|
|
253
|
+
|
|
254
|
+
```json
|
|
255
|
+
{
|
|
256
|
+
"type": "PieChart",
|
|
257
|
+
"settings": { "layout": "vertical" },
|
|
258
|
+
"properties": { "series": ["#series-0"] },
|
|
259
|
+
"children": [{
|
|
260
|
+
"type": "Legend",
|
|
261
|
+
"settings": { "centerX": { "type": "Percent", "value": 50 }, "x": { "type": "Percent", "value": 50 } },
|
|
262
|
+
"properties": { "data": "#series-0.dataItems" }
|
|
263
|
+
}],
|
|
264
|
+
"refs": [
|
|
265
|
+
{ "data-0": [
|
|
266
|
+
{ "category": "Search", "value": 4200 },
|
|
267
|
+
{ "category": "Social", "value": 2600 },
|
|
268
|
+
{ "category": "Email", "value": 1400 },
|
|
269
|
+
{ "category": "Direct", "value": 1100 },
|
|
270
|
+
{ "category": "Referral", "value": 700 }
|
|
271
|
+
] },
|
|
272
|
+
{ "series-0": {
|
|
273
|
+
"type": "PieSeries",
|
|
274
|
+
"settings": {
|
|
275
|
+
"valueField": "value", "categoryField": "category",
|
|
276
|
+
"autoAppear": true, "appearDuration": 1000, "appearDelay": 100
|
|
277
|
+
},
|
|
278
|
+
"properties": { "data": "#data-0" }
|
|
279
|
+
} }
|
|
280
|
+
]
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Map configs are in "Maps" below.
|
|
285
|
+
|
|
286
|
+
### Flow: Sankey
|
|
287
|
+
|
|
288
|
+
Needs `index.js`, `plugins/json.js`, `flow.js`. The Sankey is the top-level object, and its data is the links. Nodes come from the link ends.
|
|
289
|
+
|
|
290
|
+
```json
|
|
291
|
+
{
|
|
292
|
+
"type": "Sankey",
|
|
293
|
+
"settings": {
|
|
294
|
+
"sourceIdField": "from", "targetIdField": "to", "valueField": "value",
|
|
295
|
+
"paddingRight": 70,
|
|
296
|
+
"autoAppear": true, "appearDuration": 1000, "appearDelay": 100
|
|
297
|
+
},
|
|
298
|
+
"properties": {
|
|
299
|
+
"data": [
|
|
300
|
+
{ "from": "Solar", "to": "Electricity", "value": 30 },
|
|
301
|
+
{ "from": "Wind", "to": "Electricity", "value": 25 },
|
|
302
|
+
{ "from": "Gas", "to": "Electricity", "value": 40 },
|
|
303
|
+
{ "from": "Gas", "to": "Heating", "value": 35 },
|
|
304
|
+
{ "from": "Electricity", "to": "Homes", "value": 45 },
|
|
305
|
+
{ "from": "Electricity", "to": "Industry", "value": 50 },
|
|
306
|
+
{ "from": "Heating", "to": "Homes", "value": 35 }
|
|
307
|
+
]
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### Hierarchy: treemap
|
|
313
|
+
|
|
314
|
+
Needs `index.js`, `plugins/json.js`, `hierarchy.js`. The Treemap is the top-level object. `children` is the default `childDataField`. A `ForceDirected`, `Sunburst` or `Pack` takes the same shape.
|
|
315
|
+
|
|
316
|
+
```json
|
|
317
|
+
{
|
|
318
|
+
"type": "Treemap",
|
|
319
|
+
"settings": {
|
|
320
|
+
"valueField": "value", "categoryField": "name",
|
|
321
|
+
"autoAppear": true, "appearDuration": 1000, "appearDelay": 100
|
|
322
|
+
},
|
|
323
|
+
"properties": {
|
|
324
|
+
"data": [{
|
|
325
|
+
"name": "Sales",
|
|
326
|
+
"children": [
|
|
327
|
+
{ "name": "Electronics", "children": [
|
|
328
|
+
{ "name": "Phones", "value": 86 }, { "name": "Laptops", "value": 64 }, { "name": "Audio", "value": 31 }
|
|
329
|
+
] },
|
|
330
|
+
{ "name": "Home", "children": [
|
|
331
|
+
{ "name": "Furniture", "value": 52 }, { "name": "Kitchen", "value": 37 }
|
|
332
|
+
] },
|
|
333
|
+
{ "name": "Sports", "children": [
|
|
334
|
+
{ "name": "Cycling", "value": 41 }, { "name": "Fitness", "value": 28 }
|
|
335
|
+
] }
|
|
336
|
+
]
|
|
337
|
+
}]
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## Maps
|
|
343
|
+
|
|
344
|
+
A map config needs `index.js`, `plugins/json.js`, `map.js` and the geodata, e.g. `geodata/worldLow.js` (rule 8). Rows and `include`/`exclude` match countries by `id`, the ISO 3166-1 alpha-2 code. Each config below was parsed with amCharts 5.21.3, built through `<am5-chart>`, and opened in Chart Maker.
|
|
345
|
+
|
|
346
|
+
### Countries colored by value
|
|
347
|
+
|
|
348
|
+
Countries without a value get the theme's `disabled` color.
|
|
349
|
+
|
|
350
|
+
```json
|
|
351
|
+
{
|
|
352
|
+
"type": "MapChart",
|
|
353
|
+
"settings": {
|
|
354
|
+
"projectionName": "geoNaturalEarth1",
|
|
355
|
+
"autoAppear": true, "appearDuration": 1000, "appearDelay": 100
|
|
356
|
+
},
|
|
357
|
+
"properties": { "series": ["#series-0"] },
|
|
358
|
+
"refs": [
|
|
359
|
+
{ "data-0": [
|
|
360
|
+
{ "id": "CN", "value": 1410 }, { "id": "IN", "value": 1430 },
|
|
361
|
+
{ "id": "US", "value": 335 }, { "id": "ID", "value": 278 },
|
|
362
|
+
{ "id": "BR", "value": 216 }, { "id": "NG", "value": 224 },
|
|
363
|
+
{ "id": "DE", "value": 84 }, { "id": "AU", "value": 27 }
|
|
364
|
+
] },
|
|
365
|
+
{ "template-0": {
|
|
366
|
+
"type": "Template",
|
|
367
|
+
"settings": { "tooltipText": "{name}: {value}", "fill": "@root.interfaceColors.get('disabled')" }
|
|
368
|
+
} },
|
|
369
|
+
{ "series-0": {
|
|
370
|
+
"type": "MapPolygonSeries",
|
|
371
|
+
"settings": {
|
|
372
|
+
"geoJSON": "am5geodata_worldLow",
|
|
373
|
+
"valueField": "value",
|
|
374
|
+
"calculateAggregates": true,
|
|
375
|
+
"heatRules": [{
|
|
376
|
+
"target": "#template-0", "dataField": "value", "key": "fill",
|
|
377
|
+
"min": { "type": "Color", "value": "#9ecae1" },
|
|
378
|
+
"max": { "type": "Color", "value": "#08519c" },
|
|
379
|
+
"__parse": true
|
|
380
|
+
}]
|
|
381
|
+
},
|
|
382
|
+
"properties": {
|
|
383
|
+
"data": "#data-0",
|
|
384
|
+
"mapPolygons": { "properties": { "template": "#template-0" } }
|
|
385
|
+
}
|
|
386
|
+
} }
|
|
387
|
+
]
|
|
388
|
+
}
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
For a map without values, drop `data-0`, `template-0`, `heatRules`, `valueField` and `calculateAggregates`. Then give the series `"properties": { "mapPolygons": { "properties": { "template": { "settings": { "tooltipText": "{name}" } } } } }`.
|
|
392
|
+
|
|
393
|
+
### A few countries highlighted, through their data rows
|
|
394
|
+
|
|
395
|
+
One series. Each highlighted country's row carries the polygon's settings, which the template picks up through `templateField`. A row that holds a color needs `"__parse": true`, and so does the settings object in it (rule 3). In Chart Maker the map stays one series, so this form is the easier one to edit there.
|
|
396
|
+
|
|
397
|
+
```json
|
|
398
|
+
{
|
|
399
|
+
"type": "MapChart",
|
|
400
|
+
"settings": {
|
|
401
|
+
"projectionName": "geoNaturalEarth1",
|
|
402
|
+
"autoAppear": true, "appearDuration": 1000, "appearDelay": 100
|
|
403
|
+
},
|
|
404
|
+
"properties": {
|
|
405
|
+
"series": [{
|
|
406
|
+
"type": "MapPolygonSeries",
|
|
407
|
+
"settings": { "geoJSON": "am5geodata_worldLow", "exclude": ["AQ"] },
|
|
408
|
+
"properties": {
|
|
409
|
+
"mapPolygons": { "properties": { "template": {
|
|
410
|
+
"settings": { "tooltipText": "{name}", "templateField": "polygonSettings" }
|
|
411
|
+
} } },
|
|
412
|
+
"data": [
|
|
413
|
+
{ "id": "CA", "polygonSettings": { "fill": { "type": "Color", "value": "#e8590c" }, "__parse": true }, "__parse": true },
|
|
414
|
+
{ "id": "IN", "polygonSettings": { "fill": { "type": "Color", "value": "#e8590c" }, "__parse": true }, "__parse": true },
|
|
415
|
+
{ "id": "AU", "polygonSettings": { "fill": { "type": "Color", "value": "#e8590c" }, "__parse": true }, "__parse": true }
|
|
416
|
+
]
|
|
417
|
+
}
|
|
418
|
+
}]
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### A few countries highlighted, with a second series on top
|
|
424
|
+
|
|
425
|
+
The world series draws every country. A second series with `include` draws only the highlighted ones, in their own color, over it. Later series draw on top. The second series still holds a data item for every country, but it draws only the ones in `include`.
|
|
426
|
+
|
|
427
|
+
```json
|
|
428
|
+
{
|
|
429
|
+
"type": "MapChart",
|
|
430
|
+
"settings": {
|
|
431
|
+
"projectionName": "geoNaturalEarth1",
|
|
432
|
+
"autoAppear": true, "appearDuration": 1000, "appearDelay": 100
|
|
433
|
+
},
|
|
434
|
+
"properties": {
|
|
435
|
+
"series": [{
|
|
436
|
+
"type": "MapPolygonSeries",
|
|
437
|
+
"settings": { "geoJSON": "am5geodata_worldLow", "exclude": ["AQ"] },
|
|
438
|
+
"properties": {
|
|
439
|
+
"mapPolygons": { "properties": { "template": { "settings": { "tooltipText": "{name}" } } } }
|
|
440
|
+
}
|
|
441
|
+
}, {
|
|
442
|
+
"type": "MapPolygonSeries",
|
|
443
|
+
"settings": { "geoJSON": "am5geodata_worldLow", "include": ["CA", "IN", "AU"] },
|
|
444
|
+
"properties": {
|
|
445
|
+
"mapPolygons": { "properties": { "template": {
|
|
446
|
+
"settings": { "tooltipText": "{name}", "fill": { "type": "Color", "value": "#e8590c" } }
|
|
447
|
+
} } }
|
|
448
|
+
}
|
|
449
|
+
}]
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
In an `<am5-chart>` element, any of these configs goes in the `config` attribute. Load `element.js` after `plugins/json.js`, then `map.js` and the geodata (see "`<am5-chart>` element" below).
|
|
455
|
+
|
|
456
|
+
## Delivering a config
|
|
457
|
+
|
|
458
|
+
### `<am5-chart>` element (5.21.0+)
|
|
459
|
+
|
|
460
|
+
Load the scripts, then put the config in the `config` attribute:
|
|
461
|
+
|
|
462
|
+
```html
|
|
463
|
+
<script src="https://cdn.amcharts.com/lib/5/index.js"></script>
|
|
464
|
+
<script src="https://cdn.amcharts.com/lib/5/plugins/json.js"></script>
|
|
465
|
+
<script src="https://cdn.amcharts.com/lib/5/element.js"></script>
|
|
466
|
+
<script src="https://cdn.amcharts.com/lib/5/percent.js"></script>
|
|
467
|
+
<script src="https://cdn.amcharts.com/lib/5/themes/Animated.js"></script>
|
|
468
|
+
|
|
469
|
+
<am5-chart themes="Animated" style="height: 400px" config='{
|
|
470
|
+
"type": "PieChart",
|
|
471
|
+
"properties": { "series": [{ "type": "PieSeries",
|
|
472
|
+
"settings": { "valueField": "value", "categoryField": "category", "autoAppear": true },
|
|
473
|
+
"properties": { "data": [{ "category": "Search", "value": 4200 }, { "category": "Social", "value": 2600 }] } }] }
|
|
474
|
+
}'></am5-chart>
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
- Load the files each family needs (see "Where a config goes").
|
|
478
|
+
- The attribute is single-quoted, so write a `'` inside the config as `'`, e.g. `get('background')`.
|
|
479
|
+
- For a long config, use `src="chart.json"` or set the element's `config` property from a script: `document.querySelector("am5-chart").config = { … }`.
|
|
480
|
+
- See SKILL.md "Serializing to JSON" for `renderer="svg"`, `whenReady()` and the `ready`/`error` events.
|
|
481
|
+
|
|
482
|
+
### Chart Maker link
|
|
483
|
+
|
|
484
|
+
Chart Maker (live.amcharts.com) opens a config from a link, ready to edit:
|
|
485
|
+
|
|
486
|
+
```js
|
|
487
|
+
const url = "https://live.amcharts.com/open#config=" + encodeURIComponent(JSON.stringify(config))
|
|
488
|
+
+ "&title=" + encodeURIComponent("Traffic sources");
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
- The parameters are in the `#` hash, not a query string. Optional ones: `title`; `theme`, a theme name such as `Kelly` or `Material`; `dark=1` for the dark version (on its own, the Dark theme); `responsive=1` for the Responsive theme.
|
|
492
|
+
- Chart Maker loads chart packages and `am5geodata_*` geodata by itself.
|
|
493
|
+
- For a big config, gzip the JSON, base64url-encode it without `=` padding, and use `#config=gz.` followed by that string. This typically makes it 5–10× smaller. Configs over 2 MB are refused.
|
|
494
|
+
- Build the link in code when you can: a hand-encoded link breaks on a single wrong character.
|
|
495
|
+
|
|
496
|
+
### Framework packages
|
|
497
|
+
|
|
498
|
+
`@amcharts/amcharts5-react`, `-vue`, `-angular`, `-svelte` and `-react-native` each take a config as a prop or input, plus themes beside it. See SKILL.md "Frameworks".
|
|
499
|
+
|
|
500
|
+
- For a map in React, Vue, Angular or Svelte, give the chart its geodata as in rule 8: the `resources` prop (5.21.4+), or a global set before the chart is built.
|
|
501
|
+
- React Native loads the geodata a config names by itself.
|
package/content/map.md
CHANGED