@amcharts/amcharts5-mcp 1.0.0

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.
@@ -0,0 +1,663 @@
1
+ # Pie & Sliced Charts — Pie, Donut, Funnel, Pyramid
2
+
3
+
4
+ ## Required imports
5
+
6
+ ### ES modules
7
+ ```ts
8
+ import * as am5 from "@amcharts/amcharts5";
9
+ import * as am5percent from "@amcharts/amcharts5/percent";
10
+ import am5themes_Animated from "@amcharts/amcharts5/themes/Animated";
11
+ ```
12
+
13
+ ### CDN
14
+ ```html
15
+ <script src="https://cdn.amcharts.com/lib/5/index.js"></script>
16
+ <script src="https://cdn.amcharts.com/lib/5/percent.js"></script>
17
+ <script src="https://cdn.amcharts.com/lib/5/themes/Animated.js"></script>
18
+ ```
19
+
20
+ ## Pie / Donut chart setup
21
+
22
+ ```js
23
+ const root = am5.Root.new("chartdiv");
24
+ root.setThemes([am5themes_Animated.new(root)]);
25
+
26
+ const chart = root.container.children.push(
27
+ am5percent.PieChart.new(root, {
28
+ layout: root.verticalLayout,
29
+ // Donut: set innerRadius
30
+ // innerRadius: am5.percent(50)
31
+ })
32
+ );
33
+
34
+ const series = chart.series.push(
35
+ am5percent.PieSeries.new(root, {
36
+ name: "Sales",
37
+ valueField: "value",
38
+ categoryField: "category"
39
+ })
40
+ );
41
+
42
+ // Data — LAST
43
+ series.data.setAll([
44
+ { category: "Phones", value: 501 },
45
+ { category: "Tablets", value: 301 },
46
+ { category: "Laptops", value: 201 }
47
+ ]);
48
+
49
+ series.appear(1000);
50
+ chart.appear(1000, 100);
51
+ ```
52
+
53
+ ### PieChart key settings
54
+
55
+ | Setting | Type | Description |
56
+ |---------|------|-------------|
57
+ | `radius` | percent/number | Outer radius (default: `am5.percent(80)`) |
58
+ | `innerRadius` | percent/number | Inner hole for donut (default: 0). Percent is relative to radius |
59
+ | `startAngle` | number | Start angle in degrees (default: -90) |
60
+ | `endAngle` | number | End angle in degrees (default: 270) |
61
+
62
+ **Semi-circle pie:** `startAngle: 180, endAngle: 360` (set on BOTH PieChart AND PieSeries)
63
+
64
+ ### PieSeries key settings
65
+
66
+ | Setting | Type | Description |
67
+ |---------|------|-------------|
68
+ | `valueField` | string | Data field for values (required) |
69
+ | `categoryField` | string | Data field for categories (required) |
70
+ | `alignLabels` | boolean | Align labels in column (default: true). Set false for radial/inside labels |
71
+ | `legendLabelText` | string | Legend label format, e.g. `"{category}"` |
72
+ | `legendValueText` | string | Legend value format, e.g. `"{value}"` |
73
+ | `startAngle` | number | Start angle in degrees (default: inherits from chart). Must match PieChart's startAngle for semi-circle |
74
+ | `endAngle` | number | End angle in degrees (default: inherits from chart). Must match PieChart's endAngle for semi-circle |
75
+
76
+ ### Labels
77
+
78
+ ```js
79
+ // Standard aligned labels (default)
80
+ series.labels.template.setAll({
81
+ text: "{category}: {valuePercentTotal.formatNumber('0.0')}%",
82
+ fontSize: 12
83
+ });
84
+
85
+ // Radial labels
86
+ series.set("alignLabels", false);
87
+ series.labels.template.setAll({
88
+ textType: "radial",
89
+ centerX: am5.percent(100),
90
+ text: "{category}"
91
+ });
92
+
93
+ // Inside labels
94
+ series.labels.template.setAll({
95
+ inside: true,
96
+ radius: 10,
97
+ text: "{valuePercentTotal.formatNumber('0')}%"
98
+ });
99
+
100
+ // Hide labels
101
+ series.labels.template.set("forceHidden", true);
102
+ series.ticks.template.set("forceHidden", true);
103
+ ```
104
+
105
+ ### Slice appearance
106
+
107
+ ```js
108
+ series.slices.template.setAll({
109
+ strokeWidth: 2,
110
+ stroke: am5.color(0xffffff),
111
+ cornerRadius: 5,
112
+ tooltipText: "{category}: {valuePercentTotal.formatNumber('0.0')}% ({value})"
113
+ });
114
+
115
+ // Click to pull out slice
116
+ series.slices.template.set("toggleKey", "active");
117
+ series.slices.template.states.create("active", {
118
+ shiftRadius: 20 // pixels to pull out
119
+ });
120
+ ```
121
+
122
+ ### Custom colors
123
+
124
+ ```js
125
+ // Set colors per slice from data
126
+ series.slices.template.adapters.add("fill", function(fill, target) {
127
+ return chart.get("colors").getIndex(series.slices.indexOf(target));
128
+ });
129
+
130
+ // Or in data:
131
+ // { category: "A", value: 100, sliceSettings: { fill: am5.color(0xff0000) } }
132
+ // series.slices.template.set("templateField", "sliceSettings");
133
+ ```
134
+
135
+ ## Funnel chart setup
136
+
137
+ ```js
138
+ const chart = root.container.children.push(
139
+ am5percent.SlicedChart.new(root, {
140
+ layout: root.horizontalLayout
141
+ })
142
+ );
143
+
144
+ const series = chart.series.push(
145
+ am5percent.FunnelSeries.new(root, {
146
+ name: "Funnel",
147
+ valueField: "value",
148
+ categoryField: "stage",
149
+ orientation: "vertical", // "vertical" or "horizontal"
150
+ bottomRatio: 0, // 0 = trapezoids (classic funnel), 1 = rectangles
151
+ alignLabels: true
152
+ })
153
+ );
154
+
155
+ series.data.setAll([
156
+ { stage: "Prospects", value: 1000 },
157
+ { stage: "Qualified", value: 600 },
158
+ { stage: "Proposals", value: 300 },
159
+ { stage: "Closed", value: 100 }
160
+ ]);
161
+ ```
162
+
163
+ ### FunnelSeries key settings
164
+
165
+ | Setting | Type | Description |
166
+ |---------|------|-------------|
167
+ | `orientation` | `"vertical" \| "horizontal"` | Direction of the funnel (required) |
168
+ | `bottomRatio` | number (0–1) | 0 = trapezoids (classic funnel), 1 = rectangles (default) |
169
+ | `alignLabels` | boolean | Align labels in a column (default: true) |
170
+
171
+ ### Slice links (connectors between funnel slices)
172
+
173
+ ```js
174
+ series.links.template.setAll({
175
+ fillOpacity: 0.5,
176
+ height: 10 // gap between slices
177
+ });
178
+ ```
179
+
180
+ ## Pyramid chart setup
181
+
182
+ ```js
183
+ const series = chart.series.push(
184
+ am5percent.PyramidSeries.new(root, {
185
+ name: "Pyramid",
186
+ valueField: "value",
187
+ categoryField: "level",
188
+ orientation: "vertical",
189
+ valueIs: "area", // "area" (default) or "height"
190
+ topWidth: am5.percent(0), // tip width
191
+ bottomWidth: am5.percent(100) // base width
192
+ })
193
+ );
194
+ ```
195
+
196
+ ### PyramidSeries extra settings
197
+
198
+ | Setting | Type | Description |
199
+ |---------|------|-------------|
200
+ | `valueIs` | `"area" \| "height"` | How value maps to size (area is recommended) |
201
+ | `topWidth` | percent/number | Width of pyramid tip |
202
+ | `bottomWidth` | percent/number | Width of pyramid base |
203
+
204
+ ## Pictorial Stacked chart setup
205
+
206
+ Pictorial charts use an SVG path as a mask to create shaped charts (e.g., human figure, bottle, battery). Uses `SlicedChart` (same as funnel/pyramid) with `PictorialStackedSeries`.
207
+
208
+ ```js
209
+ // Use SlicedChart — same as funnel and pyramid
210
+ const chart = root.container.children.push(
211
+ am5percent.SlicedChart.new(root, {
212
+ layout: root.verticalLayout
213
+ })
214
+ );
215
+
216
+ // SVG path that defines the shape (any SVG path string works)
217
+ const humanShape = "M53.5,476c0,14,6.833,21,20.5,21s20.5-7,20.5-21V287h21v189c0,14,6.834,21,20.5,21c13.667,0,20.5-7,20.5-21V154h10v116c0,7.334,2.5,12.667,7.5,16s10.167,3.333,15.5,0s8-8.667,8-16V145c0-13.334-4.5-23.667-13.5-31s-21.5-11-37.5-11h-82c-15.333,0-27.833,3.333-37.5,10s-14.5,17-14.5,31v133c0,6,2.667,10.333,8,13s10.5,2.667,15.5,0s7.5-7,7.5-13V154h10V476 M61.5,42.5c0,11.667,4.167,21.667,12.5,30S92.333,85,104,85s21.667-4.167,30-12.5S146.5,54,146.5,42c0-11.335-4.167-21.168-12.5-29.5C125.667,4.167,115.667,0,104,0S82.333,4.167,74,12.5S61.5,30.833,61.5,42.5z";
218
+
219
+ const series = chart.series.push(
220
+ am5percent.PictorialStackedSeries.new(root, {
221
+ name: "Survey",
222
+ categoryField: "stage",
223
+ valueField: "value",
224
+ orientation: "vertical", // "vertical" | "horizontal"
225
+ svgPath: humanShape, // SVG path string for the mask shape
226
+ // startLocation: 0, // 0–1, where fill starts
227
+ // endLocation: 1, // 0–1, where fill ends
228
+ })
229
+ );
230
+
231
+ series.data.setAll([
232
+ { stage: "Applied", value: 600 },
233
+ { stage: "Phone Screen", value: 300 },
234
+ { stage: "Interview", value: 150 },
235
+ { stage: "Offer", value: 50 },
236
+ { stage: "Hired", value: 30 }
237
+ ]);
238
+ ```
239
+
240
+ ### Pictorial key settings
241
+
242
+ | Setting | Type | Description |
243
+ |---------|------|-------------|
244
+ | `svgPath` | string | SVG path string defining the mask shape (required) |
245
+ | `orientation` | `"vertical"` \| `"horizontal"` | Fill direction |
246
+ | `startLocation` | number (0–1) | Where the fill starts within the shape |
247
+ | `endLocation` | number (0–1) | Where the fill ends within the shape |
248
+ | `alignLabels` | boolean | Align labels outside the shape |
249
+
250
+ **Getting SVG paths:** Use any vector editor (Adobe Illustrator, Inkscape, Figma) to draw a shape and export as SVG, then extract the `d` attribute from the `<path>` element.
251
+
252
+ **Pictorial fraction chart:** Use `startLocation` and `endLocation` to show a percentage fill of a single shape (e.g., a battery at 75%):
253
+
254
+ ```js
255
+ am5percent.PictorialStackedSeries.new(root, {
256
+ svgPath: batteryPath,
257
+ startLocation: 0,
258
+ endLocation: 0.75, // 75% filled
259
+ // ...
260
+ })
261
+ ```
262
+
263
+ ## Legend (for all percent charts)
264
+
265
+ ```js
266
+ const legend = chart.children.push(am5.Legend.new(root, {
267
+ centerX: am5.percent(50),
268
+ x: am5.percent(50),
269
+ layout: root.horizontalLayout
270
+ }));
271
+ // IMPORTANT: Use series.dataItems, NOT chart.series.values
272
+ legend.data.setAll(series.dataItems);
273
+ ```
274
+
275
+ **Custom legend labels:**
276
+ ```js
277
+ am5percent.PieSeries.new(root, {
278
+ legendLabelText: "[{fill}]{category}[/]",
279
+ legendValueText: "[bold {fill}]{value}[/]",
280
+ // ...
281
+ });
282
+ ```
283
+
284
+ ## Nested / Multi-level pie (concentric rings)
285
+
286
+ ```js
287
+ // Outer ring
288
+ var outerSeries = chart.series.push(am5percent.PieSeries.new(root, {
289
+ valueField: "value",
290
+ categoryField: "category",
291
+ radius: am5.percent(95),
292
+ innerRadius: am5.percent(60)
293
+ }));
294
+
295
+ // Inner ring
296
+ var innerSeries = chart.series.push(am5percent.PieSeries.new(root, {
297
+ valueField: "value",
298
+ categoryField: "category",
299
+ radius: am5.percent(55),
300
+ innerRadius: am5.percent(20)
301
+ }));
302
+
303
+ outerSeries.data.setAll(outerData);
304
+ innerSeries.data.setAll(innerData);
305
+ ```
306
+
307
+ ## Data-driven slice colors (templateField)
308
+
309
+ ```js
310
+ series.slices.template.set("templateField", "sliceSettings");
311
+
312
+ series.data.setAll([
313
+ { category: "Critical", value: 40, sliceSettings: { fill: am5.color(0xff0000) } },
314
+ { category: "Warning", value: 35, sliceSettings: { fill: am5.color(0xffa500) } },
315
+ { category: "OK", value: 25, sliceSettings: { fill: am5.color(0x00cc00) } }
316
+ ]);
317
+ ```
318
+
319
+ ## Events on slices
320
+
321
+ ```js
322
+ series.slices.template.events.on("click", function(ev) {
323
+ var data = ev.target.dataItem.dataContext;
324
+ console.log("Clicked:", data.category, data.value);
325
+ });
326
+
327
+ series.slices.template.events.on("pointerover", function(ev) {
328
+ ev.target.set("scale", 1.05);
329
+ });
330
+ series.slices.template.events.on("pointerout", function(ev) {
331
+ ev.target.set("scale", 1);
332
+ });
333
+ ```
334
+
335
+ ## Disposal
336
+
337
+ ```js
338
+ root.dispose();
339
+ ```
340
+
341
+
342
+ ---
343
+
344
+ # amCharts 5 Pie & Sliced Charts — Working Examples
345
+
346
+ ## Example 1: Basic pie chart with legend
347
+
348
+ ```html
349
+ <!DOCTYPE html>
350
+ <html>
351
+ <head>
352
+ <meta charset="UTF-8">
353
+ <title>Pie Chart</title>
354
+ <script src="https://cdn.amcharts.com/lib/5/index.js"></script>
355
+ <script src="https://cdn.amcharts.com/lib/5/percent.js"></script>
356
+ <script src="https://cdn.amcharts.com/lib/5/themes/Animated.js"></script>
357
+ <style>#chartdiv { width: 100%; height: 500px; }</style>
358
+ </head>
359
+ <body>
360
+ <div id="chartdiv"></div>
361
+ <script>
362
+ var root = am5.Root.new("chartdiv");
363
+ root.setThemes([am5themes_Animated.new(root)]);
364
+
365
+ var chart = root.container.children.push(
366
+ am5percent.PieChart.new(root, { layout: root.verticalLayout })
367
+ );
368
+
369
+ var series = chart.series.push(am5percent.PieSeries.new(root, {
370
+ name: "Market Share",
371
+ valueField: "share",
372
+ categoryField: "browser",
373
+ legendLabelText: "{category}",
374
+ legendValueText: "{valuePercentTotal.formatNumber('0.0')}%"
375
+ }));
376
+
377
+ series.slices.template.setAll({
378
+ strokeWidth: 2,
379
+ stroke: am5.color(0xffffff),
380
+ tooltipText: "{category}: {valuePercentTotal.formatNumber('0.0')}% ({value})"
381
+ });
382
+
383
+ series.labels.template.setAll({
384
+ text: "{category}",
385
+ fontSize: 12
386
+ });
387
+
388
+ // Legend — uses dataItems for percent charts
389
+ var legend = chart.children.push(am5.Legend.new(root, {
390
+ centerX: am5.percent(50),
391
+ x: am5.percent(50),
392
+ layout: root.horizontalLayout
393
+ }));
394
+
395
+ // Data LAST
396
+ series.data.setAll([
397
+ { browser: "Chrome", share: 65 },
398
+ { browser: "Safari", share: 19 },
399
+ { browser: "Firefox", share: 4 },
400
+ { browser: "Edge", share: 5 },
401
+ { browser: "Other", share: 7 }
402
+ ]);
403
+
404
+ // Populate legend AFTER data is set (dataItems are empty before data.setAll)
405
+ legend.data.setAll(series.dataItems);
406
+
407
+ series.appear(1000);
408
+ chart.appear(1000, 100);
409
+ </script>
410
+ </body>
411
+ </html>
412
+ ```
413
+
414
+ ## Example 2: Donut chart with center label
415
+
416
+ ```html
417
+ <!DOCTYPE html>
418
+ <html>
419
+ <head>
420
+ <meta charset="UTF-8">
421
+ <title>Donut Chart</title>
422
+ <script src="https://cdn.amcharts.com/lib/5/index.js"></script>
423
+ <script src="https://cdn.amcharts.com/lib/5/percent.js"></script>
424
+ <script src="https://cdn.amcharts.com/lib/5/themes/Animated.js"></script>
425
+ <style>#chartdiv { width: 100%; height: 500px; }</style>
426
+ </head>
427
+ <body>
428
+ <div id="chartdiv"></div>
429
+ <script>
430
+ var root = am5.Root.new("chartdiv");
431
+ root.setThemes([am5themes_Animated.new(root)]);
432
+
433
+ var chart = root.container.children.push(am5percent.PieChart.new(root, {
434
+ layout: root.verticalLayout,
435
+ innerRadius: am5.percent(50)
436
+ }));
437
+
438
+ var series = chart.series.push(am5percent.PieSeries.new(root, {
439
+ valueField: "value",
440
+ categoryField: "category"
441
+ }));
442
+
443
+ // Hide labels and ticks for clean donut
444
+ series.labels.template.set("forceHidden", true);
445
+ series.ticks.template.set("forceHidden", true);
446
+
447
+ // Center label inside the donut hole
448
+ series.children.push(am5.Label.new(root, {
449
+ text: "Total\n$1.2M",
450
+ fontSize: 20,
451
+ centerX: am5.percent(50),
452
+ centerY: am5.percent(50),
453
+ textAlign: "center",
454
+ populateText: true
455
+ }));
456
+
457
+ series.data.setAll([
458
+ { category: "Q1", value: 300000 },
459
+ { category: "Q2", value: 350000 },
460
+ { category: "Q3", value: 280000 },
461
+ { category: "Q4", value: 270000 }
462
+ ]);
463
+
464
+ var legend = chart.children.push(am5.Legend.new(root, {
465
+ centerX: am5.percent(50),
466
+ x: am5.percent(50)
467
+ }));
468
+ series.events.on("datavalidated", function() {
469
+ legend.data.setAll(series.dataItems);
470
+ });
471
+
472
+ series.appear(1000);
473
+ chart.appear(1000, 100);
474
+ </script>
475
+ </body>
476
+ </html>
477
+ ```
478
+
479
+ ## Example 3: Semi-circle pie
480
+
481
+ ```html
482
+ <!DOCTYPE html>
483
+ <html>
484
+ <head>
485
+ <meta charset="UTF-8">
486
+ <title>Semi-Circle Pie</title>
487
+ <script src="https://cdn.amcharts.com/lib/5/index.js"></script>
488
+ <script src="https://cdn.amcharts.com/lib/5/percent.js"></script>
489
+ <script src="https://cdn.amcharts.com/lib/5/themes/Animated.js"></script>
490
+ <style>#chartdiv { width: 100%; height: 400px; }</style>
491
+ </head>
492
+ <body>
493
+ <div id="chartdiv"></div>
494
+ <script>
495
+ var root = am5.Root.new("chartdiv");
496
+ root.setThemes([am5themes_Animated.new(root)]);
497
+
498
+ var chart = root.container.children.push(am5percent.PieChart.new(root, {
499
+ startAngle: 180,
500
+ endAngle: 360,
501
+ layout: root.verticalLayout,
502
+ innerRadius: am5.percent(50)
503
+ }));
504
+
505
+ var series = chart.series.push(am5percent.PieSeries.new(root, {
506
+ valueField: "value",
507
+ categoryField: "category",
508
+ alignLabels: false,
509
+ startAngle: 180,
510
+ endAngle: 360
511
+ }));
512
+
513
+ series.labels.template.setAll({
514
+ textType: "circular",
515
+ inside: true,
516
+ radius: 10
517
+ });
518
+
519
+ series.data.setAll([
520
+ { category: "Low", value: 30 },
521
+ { category: "Medium", value: 45 },
522
+ { category: "High", value: 25 }
523
+ ]);
524
+
525
+ series.appear(1000);
526
+ chart.appear(1000, 100);
527
+ </script>
528
+ </body>
529
+ </html>
530
+ ```
531
+
532
+ ## Example 4: Funnel chart
533
+
534
+ ```html
535
+ <!DOCTYPE html>
536
+ <html>
537
+ <head>
538
+ <meta charset="UTF-8">
539
+ <title>Funnel Chart</title>
540
+ <script src="https://cdn.amcharts.com/lib/5/index.js"></script>
541
+ <script src="https://cdn.amcharts.com/lib/5/percent.js"></script>
542
+ <script src="https://cdn.amcharts.com/lib/5/themes/Animated.js"></script>
543
+ <style>#chartdiv { width: 100%; height: 500px; }</style>
544
+ </head>
545
+ <body>
546
+ <div id="chartdiv"></div>
547
+ <script>
548
+ var root = am5.Root.new("chartdiv");
549
+ root.setThemes([am5themes_Animated.new(root)]);
550
+
551
+ var chart = root.container.children.push(
552
+ am5percent.SlicedChart.new(root, { layout: root.verticalLayout })
553
+ );
554
+
555
+ var series = chart.series.push(am5percent.FunnelSeries.new(root, {
556
+ name: "Sales Funnel",
557
+ valueField: "value",
558
+ categoryField: "stage",
559
+ orientation: "vertical",
560
+ bottomRatio: 0,
561
+ alignLabels: true
562
+ }));
563
+
564
+ series.slices.template.setAll({
565
+ tooltipText: "{category}: {value} ({valuePercentTotal.formatNumber('0.0')}%)"
566
+ });
567
+
568
+ series.links.template.setAll({
569
+ fillOpacity: 0.3,
570
+ height: 5
571
+ });
572
+
573
+ series.labels.template.setAll({
574
+ text: "{category}: {value}",
575
+ fontSize: 14
576
+ });
577
+
578
+ series.data.setAll([
579
+ { stage: "Website Visits", value: 10000 },
580
+ { stage: "Sign Ups", value: 5200 },
581
+ { stage: "Free Trial", value: 2800 },
582
+ { stage: "Paid Plan", value: 1400 },
583
+ { stage: "Enterprise", value: 300 }
584
+ ]);
585
+
586
+ // Legend
587
+ var legend = chart.children.push(am5.Legend.new(root, {
588
+ centerX: am5.percent(50),
589
+ x: am5.percent(50)
590
+ }));
591
+ series.events.on("datavalidated", function() {
592
+ legend.data.setAll(series.dataItems);
593
+ });
594
+
595
+ series.appear(1000);
596
+ chart.appear(1000, 100);
597
+ </script>
598
+ </body>
599
+ </html>
600
+ ```
601
+
602
+ ## Example 5: Pyramid chart
603
+
604
+ ```html
605
+ <!DOCTYPE html>
606
+ <html>
607
+ <head>
608
+ <meta charset="UTF-8">
609
+ <title>Pyramid Chart</title>
610
+ <script src="https://cdn.amcharts.com/lib/5/index.js"></script>
611
+ <script src="https://cdn.amcharts.com/lib/5/percent.js"></script>
612
+ <script src="https://cdn.amcharts.com/lib/5/themes/Animated.js"></script>
613
+ <style>#chartdiv { width: 100%; height: 500px; }</style>
614
+ </head>
615
+ <body>
616
+ <div id="chartdiv"></div>
617
+ <script>
618
+ var root = am5.Root.new("chartdiv");
619
+ root.setThemes([am5themes_Animated.new(root)]);
620
+
621
+ var chart = root.container.children.push(
622
+ am5percent.SlicedChart.new(root, { layout: root.horizontalLayout })
623
+ );
624
+
625
+ var series = chart.series.push(am5percent.PyramidSeries.new(root, {
626
+ name: "Needs",
627
+ valueField: "value",
628
+ categoryField: "level",
629
+ orientation: "vertical",
630
+ valueIs: "area",
631
+ topWidth: am5.percent(0),
632
+ bottomWidth: am5.percent(100),
633
+ alignLabels: true
634
+ }));
635
+
636
+ series.labels.template.setAll({
637
+ text: "{category}",
638
+ fontSize: 14
639
+ });
640
+
641
+ series.data.setAll([
642
+ { level: "Self-Actualization", value: 10 },
643
+ { level: "Esteem", value: 20 },
644
+ { level: "Love / Belonging", value: 30 },
645
+ { level: "Safety", value: 40 },
646
+ { level: "Physiological", value: 50 }
647
+ ]);
648
+
649
+ var legend = chart.children.push(am5.Legend.new(root, {
650
+ centerY: am5.percent(50),
651
+ y: am5.percent(50),
652
+ layout: root.verticalLayout
653
+ }));
654
+ series.events.on("datavalidated", function() {
655
+ legend.data.setAll(series.dataItems);
656
+ });
657
+
658
+ series.appear(1000);
659
+ chart.appear(1000, 100);
660
+ </script>
661
+ </body>
662
+ </html>
663
+ ```