@amcharts/amcharts5-mcp 1.9.3 → 1.9.4

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 CHANGED
@@ -70,6 +70,8 @@ claude mcp add --transport http amcharts5 https://mcp.amcharts.com/mcp
70
70
 
71
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.
72
72
 
73
+ **Figma Make and the Figma agent** (paid Figma plans) — in the chat, open **Add context** → **Connectors** → **Manage** → **Create**. Name it `amCharts`, set the URL to `https://mcp.amcharts.com/mcp` with no authentication, and set its tools to **Always run**. Then name amCharts in the prompt (Make picks Recharts otherwise), e.g. "Build a sales dashboard with amCharts: a world map colored by revenue and a line chart of monthly sales". Make installs `@amcharts/amcharts5` and looks up the code through the server. A pasted amcharts.com demo or docs link works as context too.
74
+
73
75
  **Cline** (VS Code extension) — open the **MCP Servers** panel → **Remote Servers**, paste `https://mcp.amcharts.com/mcp`, or add to its MCP settings JSON:
74
76
 
75
77
  ```json
@@ -211,11 +213,11 @@ npm start
211
213
  | `list_chart_types` | List all available chart types and their keywords |
212
214
  | `search_docs` | Search the skill reference docs by keyword (`scope: "all"` adds the full docs, API reference and examples) |
213
215
  | `search_all` | Search across **everything** — skill docs, full documentation, and code examples |
214
- | `get_doc` | Get a full documentation page (e.g. "charts/xy-chart/axes", "concepts/events") |
216
+ | `get_doc` | Get a full documentation page by its path (e.g. "charts/xy-chart/axes", "concepts/events") or its docs.amcharts.com address |
215
217
  | `get_section` | Get a specific section from a reference file by heading (a `###` subsection heading returns just that subsection) |
216
218
  | `get_quick_start` | Get a minimal working template for any chart type |
217
219
  | `list_examples` | Browse all 350+ examples, optionally filtered by category |
218
- | `get_example` | Get the full code for a specific example |
220
+ | `get_example` | Get the full code for a specific example, by its path or its amcharts.com demo address |
219
221
  | `get_api_reference` | Get the API reference for a class, interface or function — settings with their defaults, events, inheritance and the import line |
220
222
  | `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 |
221
223
 
@@ -230,6 +232,7 @@ Once connected, your AI assistant can:
230
232
  - **"How do I integrate with React?"** → AI calls `get_doc("getting-started/integrations/react")`, which covers the `@amcharts/amcharts5-react` package
231
233
  - **"What chart types are available?"** → AI calls `list_chart_types()`
232
234
  - **"Map the current US congressional districts"** → AI calls `list_geodata("congressional whole country")`
235
+ - **A pasted amcharts.com link**, e.g. "make one like https://www.amcharts.com/demos/sankey-diagram/" → whichever tool the AI tries with it (a search, `get_doc`, `get_example`) points to the call that returns that demo's code or that docs page or section
233
236
 
234
237
  ## Content
235
238
 
@@ -43,7 +43,7 @@ am5.Picture.new(root, {
43
43
 
44
44
  ## Images as bullets
45
45
 
46
- Since image is as good as element as any, we can also use it as [bullet in series](https://docs.amcharts.com/v5/concepts/common-elements/bullets/) or [axes ranges](https://docs.amcharts.com/v5/charts/xy-chart/axes/axis-ranges/):
46
+ Since image is as good as element as any, we can also use it as [bullet in series](https://docs.amcharts.com/v5/concepts/common-elements/bullets/) or [axes ranges](https://docs.amcharts.com/v5/charts/xy-chart/axes/axis-ranges/#bullet):
47
47
 
48
48
  series.bullets.push(function() {
49
49
  return am5.Bullet.new(root, {
@@ -0,0 +1,328 @@
1
+ ---
2
+ title: "Flame Chart"
3
+ source: "https://www.amcharts.com/demos/flame-chart/"
4
+ category: "column-bar"
5
+ scraped: "2026-10-25"
6
+ ---
7
+
8
+ A page's main thread for 1.6 seconds as it loads and starts up, the way the browser's performance tools draw it: each task on top, the calls it made stacked below it, colored by what they do. The part of a task past 50 ms is striped red.
9
+
10
+ Reading a flame chart: A flame chart puts time across and the call stack down: every bar is a function or a browser activity, as long as it ran, sitting under the one that called it. Wide bars are where the time goes; tall stacks are deep calls; a gap between tasks is the page at rest. It is the main view of a browser's performance tools, and works for any nested, timed work: server traces, build steps, render passes.
11
+
12
+ Good for:
13
+ - Profiles and traces: where the time goes
14
+ - Nested work over time: requests, jobs, builds
15
+ - Spotting long tasks and deep call stacks
16
+
17
+ Think twice when:
18
+ - Totals per function: a sorted bar chart is clearer
19
+ - Thousands of tiny frames: aggregate first
20
+
21
+ Prompt: Create a flame chart of a web page's main thread like Chrome DevTools' performance panel, with generated data: 1.6 seconds of page load and start-up, time in milliseconds along the top, call stack depth down (0 at the top, no labels). Each frame is a floating bar from its start to its end on its depth's row, with its name inside, cut to the bar's width. One column series per category (Task in faint gray, Loading, Scripting, Rendering, Painting in theme colors) with a legend; tasks over 50 ms get red stripes over the part past 50 ms, the limit a parameter of the function that finds them. Tooltips: name, total time, and self time (the total less the calls one row down inside it), category. On phones hide the legend. Zoom with the wheel, pan by dragging, and a scrollbar under the plot. Use the amCharts 5 library with its Responsive theme.
22
+
23
+ ## JavaScript
24
+
25
+ ```javascript
26
+ // Create root element
27
+ // https://docs.amcharts.com/v5/getting-started/#root-element
28
+ var root = am5.Root.new("chartdiv");
29
+
30
+ // Set themes
31
+ // https://docs.amcharts.com/v5/concepts/themes/
32
+ var responsive = am5themes_Responsive.new(root); // kept in a variable: a rule of its own is added below
33
+ root.setThemes([
34
+ am5themes_Animated.new(root),
35
+ responsive
36
+ ]);
37
+
38
+
39
+ // ── Sample data: 1.6 seconds of a web page's main thread as it loads and starts up, like a recording in the
40
+ // browser's performance tools. Each frame is a function or a browser activity: when it started, when it ended, how
41
+ // deep in the call stack (0 is the task at the top) and its category ──
42
+
43
+ // A seeded random number generator (mulberry32): the same recording on every visit
44
+ function makeRandom(seed) {
45
+ return function() {
46
+ seed = seed + 0x6D2B79F5 | 0;
47
+ var t = Math.imul(seed ^ seed >>> 15, 1 | seed);
48
+ t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
49
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
50
+ };
51
+ }
52
+ var random = makeRandom(1600);
53
+ function pick(list) { return list[Math.floor(random() * list.length)]; }
54
+
55
+ var FUNCTIONS = ["bootstrap", "initApp", "render", "renderList", "renderRow", "createElement", "appendChild",
56
+ "setState", "reconcile", "commitRoot", "updateDOM", "fetchData", "parseJSON", "formatDate", "sortRows",
57
+ "filterItems", "mapItems", "measureText", "hydrate", "dispatch", "reduce", "notify", "emit", "(anonymous)"];
58
+
59
+ var frames = [];
60
+ // A frame and, inside it, its calls: they take part of its time, the rest is its own (self) time (worked out below)
61
+ function frame(name, category, start, end, depth, nest) {
62
+ var item = { name: name, category: category, start: start, end: end, depth: String(depth) };
63
+ frames.push(item);
64
+ var length = end - start;
65
+ if (nest && depth < 11 && length > 2) {
66
+ // its calls fill most of its time (70 to 95%), back to back with small gaps: its own work. A long frame makes
67
+ // more calls, so the stack narrows as it goes down, like icicles
68
+ var calls = length > 40 ? 2 + Math.floor(random() * 3) : 1 + Math.floor(random() * 2);
69
+ var busy = length * (0.7 + 0.25 * random());
70
+ var weights = [], total = 0;
71
+ for (var i = 0; i < calls; i++) { weights.push(0.3 + random()); total += weights[i]; }
72
+ var gap = (length - busy) / (calls + 1);
73
+ var at = start + gap;
74
+ weights.forEach(function(weight) {
75
+ var share = busy * weight / total;
76
+ frame(pick(FUNCTIONS), "Scripting", at, at + share, depth + 1, random() < 0.95 - depth * 0.05); // deeper calls nest a little less often
77
+ at += share + gap;
78
+ });
79
+ }
80
+ return item;
81
+ }
82
+
83
+ // One task of the main thread: a gray "Task" bar on top and the work it did below it, back to back
84
+ function task(start, work) {
85
+ var at = start;
86
+ var parts = [];
87
+ work.forEach(function(part) {
88
+ parts.push({ part: part, start: at });
89
+ at += part[2];
90
+ });
91
+ frame("Task", "Task", start, at, 0, false);
92
+ parts.forEach(function(p) {
93
+ frame(p.part[0], p.part[1], p.start, p.start + p.part[2], 1, p.part[1] === "Scripting");
94
+ });
95
+ return at;
96
+ }
97
+
98
+ var t = 4;
99
+ t = task(t, [["Parse HTML", "Loading", 9]]) + 3;
100
+ t = task(t, [["Evaluate Script", "Scripting", 34], ["Parse HTML", "Loading", 4]]) + 6;
101
+ t = task(t, [["Recalculate Style", "Rendering", 7], ["Layout", "Rendering", 11]]) + 4;
102
+ t = task(t, [["Paint", "Painting", 5], ["Commit", "Painting", 2]]) + 40;
103
+ t = task(t, [["Evaluate Script", "Scripting", 128], ["Minor GC", "Scripting", 3]]) + 5; // the app bundle: a long task
104
+ t = task(t, [["Recalculate Style", "Rendering", 14], ["Layout", "Rendering", 31]]) + 3;
105
+ t = task(t, [["Paint", "Painting", 9], ["Commit", "Painting", 3]]) + 60;
106
+ t = task(t, [["XHR Load", "Loading", 3], ["Function Call", "Scripting", 46]]) + 4;
107
+ t = task(t, [["Function Call", "Scripting", 212], ["Minor GC", "Scripting", 4]]) + 2; // rendering the list: the longest
108
+ t = task(t, [["Recalculate Style", "Rendering", 22], ["Layout", "Rendering", 64]]) + 3; // and its layout
109
+ t = task(t, [["Paint", "Painting", 18], ["Commit", "Painting", 4]]) + 90;
110
+ for (var i = 0; i < 8; i++) {
111
+ // then quieter: animation frames and timers
112
+ t = task(t, [[i % 3 === 2 ? "Timer Fired" : "Animation Frame Fired", "Scripting", 6 + 10 * random()],
113
+ ["Recalculate Style", "Rendering", 1.5 + 2 * random()], ["Paint", "Painting", 1.5 + 2 * random()]]) + 30 + 50 * random();
114
+ }
115
+ t = task(t, [["Event: click", "Scripting", 74], ["Layout", "Rendering", 9]]) + 6;
116
+ t = task(t, [["Paint", "Painting", 6], ["Commit", "Painting", 2]]) + 20;
117
+ var END = Math.ceil(t / 50) * 50;
118
+
119
+ // Each frame's total time, and its own (self) time: the total less what the calls one row down inside it took.
120
+ // Rounded for the tooltips
121
+ frames.forEach(function(f) {
122
+ var calls = frames.filter(function(c) {
123
+ return c.depth === String(+f.depth + 1) && c.start >= f.start && c.end <= f.end;
124
+ });
125
+ var called = calls.reduce(function(sum, c) { return sum + c.end - c.start; }, 0);
126
+ f.duration = Math.round((f.end - f.start) * 10) / 10;
127
+ f.self = Math.round((f.end - f.start - called) * 10) / 10;
128
+ });
129
+
130
+ // A task over 50 ms blocks the page long enough for a user to notice: the part past 50 ms is a long task. The limit
131
+ // is a parameter, so it can be changed
132
+ function findLongTasks(limit) {
133
+ return frames.filter(function(f) { return f.depth === "0" && f.end - f.start > limit; }).map(function(f) {
134
+ return { name: "Long task", start: f.start + limit, end: f.end, depth: "0", over: Math.round(f.end - f.start - limit), limit: limit };
135
+ });
136
+ }
137
+
138
+
139
+ // Create chart
140
+ // https://docs.amcharts.com/v5/charts/xy-chart/
141
+ var chart = root.container.children.push(am5xy.XYChart.new(root, {
142
+ panX: true, // a drag pans along the time line...
143
+ panY: false,
144
+ wheelX: "panX", // ...and so does a sideways wheel
145
+ wheelY: "zoomX", // the wheel zooms in on the time
146
+ paddingRight: 30, // room for the last time label, which is centered on the plot's edge
147
+ layout: root.verticalLayout
148
+ }));
149
+
150
+ // Add legend: the categories
151
+ // https://docs.amcharts.com/v5/charts/xy-chart/legend-xy-series/
152
+ var legend = chart.children.unshift(am5.Legend.new(root, {
153
+ centerX: am5.p50,
154
+ x: am5.p50,
155
+ marginBottom: 10
156
+ }));
157
+
158
+ // Create axes
159
+ // https://docs.amcharts.com/v5/charts/xy-chart/axes/
160
+ // The time, in milliseconds, along the top, as in the browser's tools
161
+ var xRenderer = am5xy.AxisRendererX.new(root, {
162
+ opposite: true, // on top
163
+ minGridDistance: 70
164
+ });
165
+ xRenderer.grid.template.set("strokeOpacity", 0.06);
166
+ var xAxis = chart.xAxes.push(am5xy.ValueAxis.new(root, {
167
+ min: 0,
168
+ max: END,
169
+ strictMinMax: true,
170
+ numberFormat: "#,###' ms'",
171
+ renderer: xRenderer
172
+ }));
173
+
174
+ // The depth of the call stack, from the task at the top down: one row each, with no labels
175
+ var yRenderer = am5xy.AxisRendererY.new(root, {
176
+ inversed: true, // depth 0 at the top
177
+ cellStartLocation: 0.04, // the bars fill their rows, with a hairline between
178
+ cellEndLocation: 0.96,
179
+ minGridDistance: 1
180
+ });
181
+ yRenderer.labels.template.set("forceHidden", true);
182
+ yRenderer.grid.template.set("forceHidden", true);
183
+ var yAxis = chart.yAxes.push(am5xy.CategoryAxis.new(root, {
184
+ categoryField: "depth",
185
+ renderer: yRenderer
186
+ }));
187
+ // as many rows as the deepest stack needs
188
+ var deepest = Math.max.apply(null, frames.map(function(f) { return +f.depth; }));
189
+ var depths = [];
190
+ for (var d = 0; d <= deepest; d++) { depths.push({ depth: String(d) }); }
191
+ yAxis.data.setAll(depths);
192
+
193
+ // Create series
194
+ // https://docs.amcharts.com/v5/charts/xy-chart/series/
195
+ // One series per category, so the legend can show and hide each. A frame is a floating bar from its start to its end,
196
+ // on its row of the call stack, with its name inside it as far as it fits
197
+ function makeSeries(name, settings) {
198
+ var series = chart.series.push(am5xy.ColumnSeries.new(root, Object.assign({
199
+ name: name,
200
+ xAxis: xAxis,
201
+ yAxis: yAxis,
202
+ openValueXField: "start",
203
+ valueXField: "end",
204
+ categoryYField: "depth",
205
+ clustered: false // every series shares the rows
206
+ }, settings))); // plus the series' own settings, if any (the tasks' gray)
207
+ series.columns.template.setAll({
208
+ strokeOpacity: 0,
209
+ tooltipText: "[bold]{name}[/]\n{duration} ms, {self} ms self\n" + name,
210
+ tooltipY: 0
211
+ });
212
+
213
+ // the name inside the bar, cut short to the bar's width (a narrow bar shows none)
214
+ series.bullets.push(function() {
215
+ return am5.Bullet.new(root, {
216
+ locationX: 0, // at the bar's start
217
+ sprite: am5.Label.new(root, {
218
+ text: "{name}",
219
+ populateText: true,
220
+ centerY: am5.p50,
221
+ dx: 3,
222
+ fontSize: "0.75em",
223
+ oversizedBehavior: "truncate",
224
+ maxWidth: 0,
225
+ forceHidden: true, // shown once its bar's width is known (below)
226
+ interactive: false // the bar has the tooltip
227
+ })
228
+ });
229
+ });
230
+ series.columns.template.onPrivate("width", function(width, column) {
231
+ var bullet = column.dataItem && column.dataItem.bullets && column.dataItem.bullets[0];
232
+ if (bullet) {
233
+ var label = bullet.get("sprite");
234
+ label.set("maxWidth", Math.max(0, width - 6));
235
+ label.set("forceHidden", width < 40); // too narrow for more than an ellipsis
236
+ }
237
+ });
238
+ legend.data.push(series);
239
+ return series;
240
+ }
241
+
242
+ // The tasks: gray, the interface's contrast color faint, so they read as the frame for what runs in them
243
+ var gray = root.interfaceColors.get("alternativeBackground");
244
+ var taskSeries = makeSeries("Task", { fill: gray, stroke: gray });
245
+ taskSeries.columns.template.set("fillOpacity", 0.18);
246
+ taskSeries.data.setAll(frames.filter(function(f) { return f.category === "Task"; }));
247
+
248
+ // The work, in the theme's colors
249
+ ["Loading", "Scripting", "Rendering", "Painting"].forEach(function(category) {
250
+ makeSeries(category).data.setAll(frames.filter(function(f) { return f.category === category; }));
251
+ });
252
+
253
+ // Long tasks: red stripes over the part of a task past 50 ms, as the browser's tools mark them
254
+ var red = root.interfaceColors.get("negative");
255
+ var longSeries = chart.series.push(am5xy.ColumnSeries.new(root, {
256
+ name: "Long task (over 50 ms)",
257
+ xAxis: xAxis,
258
+ yAxis: yAxis,
259
+ openValueXField: "start",
260
+ valueXField: "end",
261
+ categoryYField: "depth",
262
+ clustered: false,
263
+ fill: red,
264
+ stroke: red
265
+ }));
266
+ longSeries.columns.template.setAll({
267
+ strokeOpacity: 0,
268
+ fillOpacity: 0,
269
+ fillPattern: am5.LinePattern.new(root, {
270
+ color: red,
271
+ rotation: 45,
272
+ strokeWidth: 3,
273
+ gap: 6,
274
+ // the stripes on the chart's background, which covers the task's gray: the legend's swatch looks the same
275
+ fill: root.interfaceColors.get("background"),
276
+ fillOpacity: 1
277
+ }),
278
+ tooltipText: "[bold]Long task[/]\n{over} ms over the {limit} ms budget"
279
+ });
280
+ longSeries.data.setAll(findLongTasks(50));
281
+ legend.data.push(longSeries);
282
+
283
+ // On a narrow chart (a phone) the legend would take most of the height: it is hidden there. The rule is
284
+ // undone on a wider chart
285
+ responsive.addRule({
286
+ relevant: am5themes_Responsive.widthM, // the chart is 600px wide or less
287
+ applying: function() {
288
+ legend.set("forceHidden", true);
289
+ },
290
+ removing: function() {
291
+ legend.set("forceHidden", false);
292
+ }
293
+ });
294
+
295
+ // Add scrollbar under the plot
296
+ // https://docs.amcharts.com/v5/charts/xy-chart/scrollbars/
297
+ chart.set("scrollbarX", am5.Scrollbar.new(root, {
298
+ orientation: "horizontal",
299
+ opposite: true // under the plot (the time axis is on top)
300
+ }));
301
+
302
+ // Make stuff animate on load
303
+ // https://docs.amcharts.com/v5/concepts/animations/
304
+ chart.appear(1000, 100);
305
+ ```
306
+
307
+ ## HTML
308
+
309
+ ```html
310
+ <div id="chartdiv"></div>
311
+ ```
312
+
313
+ ## CSS
314
+
315
+ ```css
316
+ #chartdiv {
317
+ width: 100%;
318
+ height: 500px;
319
+ font-size: 0.875rem;
320
+ }
321
+ ```
322
+
323
+ ## Required resources
324
+
325
+ - https://cdn.amcharts.com/lib/5/index.js
326
+ - https://cdn.amcharts.com/lib/5/xy.js
327
+ - https://cdn.amcharts.com/lib/5/themes/Animated.js
328
+ - https://cdn.amcharts.com/lib/5/themes/Responsive.js