@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.
- package/.gitmodules +3 -0
- package/README.md +82 -0
- package/amcharts5-skill/README.md +50 -0
- package/amcharts5-skill/amcharts5-skill/SKILL.md +667 -0
- package/amcharts5-skill/amcharts5-skill/references/flow.md +523 -0
- package/amcharts5-skill/amcharts5-skill/references/gantt.md +410 -0
- package/amcharts5-skill/amcharts5-skill/references/hierarchy.md +568 -0
- package/amcharts5-skill/amcharts5-skill/references/map.md +574 -0
- package/amcharts5-skill/amcharts5-skill/references/pie.md +663 -0
- package/amcharts5-skill/amcharts5-skill/references/radar.md +584 -0
- package/amcharts5-skill/amcharts5-skill/references/stock.md +664 -0
- package/amcharts5-skill/amcharts5-skill/references/timeline.md +449 -0
- package/amcharts5-skill/amcharts5-skill/references/ui-elements.md +393 -0
- package/amcharts5-skill/amcharts5-skill/references/venn.md +368 -0
- package/amcharts5-skill/amcharts5-skill/references/wordcloud.md +339 -0
- package/amcharts5-skill/amcharts5-skill/references/xy.md +1150 -0
- package/amcharts5-skill/cursorrules +820 -0
- package/package.json +27 -0
- package/src/index.js +329 -0
- package/test.js +153 -0
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
# UI Elements — Buttons, Sliders, Steppers, and More
|
|
2
|
+
|
|
3
|
+
Docs: https://www.amcharts.com/docs/v5/concepts/common-elements/
|
|
4
|
+
|
|
5
|
+
amCharts 5 provides built-in interactive UI widgets in the core package. **Prefer these over HTML elements** when building interactive controls, unless the user instructs otherwise.
|
|
6
|
+
|
|
7
|
+
## Imports
|
|
8
|
+
|
|
9
|
+
All UI elements are in the core package (`am5`) except ColorPicker.
|
|
10
|
+
|
|
11
|
+
### CDN / script tags
|
|
12
|
+
```html
|
|
13
|
+
<script src="https://cdn.amcharts.com/lib/5/index.js"></script>
|
|
14
|
+
<!-- ColorPicker only: -->
|
|
15
|
+
<script src="https://cdn.amcharts.com/lib/5/plugins/colorPicker.js"></script>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### ES modules
|
|
19
|
+
```ts
|
|
20
|
+
import * as am5 from "@amcharts/amcharts5";
|
|
21
|
+
// ColorPicker only:
|
|
22
|
+
import * as am5plugins_colorPicker from "@amcharts/amcharts5/plugins/colorPicker";
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Button
|
|
28
|
+
|
|
29
|
+
A clickable button with label, icon, and background. Supports hover, down, and active states.
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
var button = container.children.push(am5.Button.new(root, {
|
|
33
|
+
label: am5.Label.new(root, {
|
|
34
|
+
text: "Click me",
|
|
35
|
+
fontSize: 14,
|
|
36
|
+
paddingTop: 5,
|
|
37
|
+
paddingRight: 10,
|
|
38
|
+
paddingBottom: 5,
|
|
39
|
+
paddingLeft: 10
|
|
40
|
+
})
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
button.events.on("click", function(ev) {
|
|
44
|
+
console.log("Button clicked!");
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Button with icon
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
var button = container.children.push(am5.Button.new(root, {
|
|
52
|
+
icon: am5.Graphics.new(root, {
|
|
53
|
+
fill: am5.color(0xffffff),
|
|
54
|
+
svgPath: "M11,5 L9,5 L9,9 L5,9 L5,11 L9,11 L9,15 L11,15 L11,11 L15,11 L15,9 L11,9 Z"
|
|
55
|
+
}),
|
|
56
|
+
label: am5.Label.new(root, { text: "Add" })
|
|
57
|
+
}));
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Button background styling
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
button.get("background").setAll({
|
|
64
|
+
fill: am5.color(0x297373),
|
|
65
|
+
fillOpacity: 0.9,
|
|
66
|
+
cornerRadiusTL: 5,
|
|
67
|
+
cornerRadiusTR: 5,
|
|
68
|
+
cornerRadiusBR: 5,
|
|
69
|
+
cornerRadiusBL: 5
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
button.get("background").states.create("hover", {
|
|
73
|
+
fill: am5.color(0x3a9a9a)
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
button.get("background").states.create("down", {
|
|
77
|
+
fill: am5.color(0x1a5555)
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Togglable button
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
var button = container.children.push(am5.Button.new(root, {
|
|
85
|
+
togglable: true,
|
|
86
|
+
label: am5.Label.new(root, { text: "Toggle" })
|
|
87
|
+
}));
|
|
88
|
+
|
|
89
|
+
// Check active state
|
|
90
|
+
button.events.on("click", function(ev) {
|
|
91
|
+
var isActive = ev.target.isActive();
|
|
92
|
+
console.log("Active:", isActive);
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Slider
|
|
99
|
+
|
|
100
|
+
A single-value slider control. Values range from 0 to 1 (relative positions).
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
var slider = container.children.push(am5.Slider.new(root, {
|
|
104
|
+
orientation: "horizontal", // or "vertical"
|
|
105
|
+
start: 0.5, // initial position (0-1)
|
|
106
|
+
width: am5.percent(80),
|
|
107
|
+
centerX: am5.percent(50),
|
|
108
|
+
x: am5.percent(50)
|
|
109
|
+
}));
|
|
110
|
+
|
|
111
|
+
slider.events.on("rangechanged", function(ev) {
|
|
112
|
+
// ev.start = current position (0-1)
|
|
113
|
+
var value = ev.start;
|
|
114
|
+
console.log("Slider value:", value);
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Converting slider 0-1 to a custom range
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
// Map 0-1 to 0-100
|
|
122
|
+
slider.events.on("rangechanged", function(ev) {
|
|
123
|
+
var mappedValue = Math.round(ev.start * 100);
|
|
124
|
+
label.set("text", mappedValue + "%");
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// Map 0-1 to 20-200
|
|
128
|
+
slider.events.on("rangechanged", function(ev) {
|
|
129
|
+
var min = 20, max = 200;
|
|
130
|
+
var mappedValue = min + ev.start * (max - min);
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Styling the slider
|
|
135
|
+
|
|
136
|
+
```js
|
|
137
|
+
// Style the thumb (draggable part)
|
|
138
|
+
slider.thumb.setAll({
|
|
139
|
+
fill: am5.color(0x297373),
|
|
140
|
+
width: 20,
|
|
141
|
+
height: 20
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Style the start grip
|
|
145
|
+
slider.startGrip.setAll({
|
|
146
|
+
visible: false // hide if not needed
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Scrollbar
|
|
153
|
+
|
|
154
|
+
A two-grip range selector for selecting a range within data.
|
|
155
|
+
|
|
156
|
+
```js
|
|
157
|
+
// Standalone scrollbar
|
|
158
|
+
var scrollbar = container.children.push(am5.Scrollbar.new(root, {
|
|
159
|
+
orientation: "horizontal",
|
|
160
|
+
start: 0.2, // initial range start
|
|
161
|
+
end: 0.8 // initial range end
|
|
162
|
+
}));
|
|
163
|
+
|
|
164
|
+
scrollbar.events.on("rangechanged", function(ev) {
|
|
165
|
+
console.log("Range:", ev.start, "-", ev.end);
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### On XY charts
|
|
170
|
+
|
|
171
|
+
```js
|
|
172
|
+
// Add scrollbar to chart
|
|
173
|
+
chart.set("scrollbarX", am5.Scrollbar.new(root, {
|
|
174
|
+
orientation: "horizontal"
|
|
175
|
+
}));
|
|
176
|
+
|
|
177
|
+
// Scrollbar with miniature chart preview
|
|
178
|
+
chart.set("scrollbarX", am5xy.XYChartScrollbar.new(root, {
|
|
179
|
+
orientation: "horizontal",
|
|
180
|
+
height: 50
|
|
181
|
+
}));
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Styling
|
|
185
|
+
|
|
186
|
+
```js
|
|
187
|
+
var scrollbar = chart.get("scrollbarX");
|
|
188
|
+
scrollbar.thumb.setAll({ fill: am5.color(0x550000), fillOpacity: 0.1 });
|
|
189
|
+
scrollbar.startGrip.set("scale", 0.7);
|
|
190
|
+
scrollbar.endGrip.set("scale", 0.7);
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## NumericStepper
|
|
196
|
+
|
|
197
|
+
An interactive number input with increment/decrement buttons.
|
|
198
|
+
|
|
199
|
+
```js
|
|
200
|
+
var stepper = container.children.push(am5.NumericStepper.new(root, {
|
|
201
|
+
value: 10
|
|
202
|
+
}));
|
|
203
|
+
|
|
204
|
+
// Read value
|
|
205
|
+
var val = stepper.get("value");
|
|
206
|
+
|
|
207
|
+
// Set value programmatically
|
|
208
|
+
stepper.set("value", 25);
|
|
209
|
+
|
|
210
|
+
// Listen for changes
|
|
211
|
+
stepper.on("value", function(value) {
|
|
212
|
+
console.log("New value:", value);
|
|
213
|
+
});
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## ProgressPie
|
|
219
|
+
|
|
220
|
+
A circular progress indicator shaped as a pie/donut.
|
|
221
|
+
|
|
222
|
+
```js
|
|
223
|
+
var progress = container.children.push(am5.ProgressPie.new(root, {
|
|
224
|
+
radius: am5.percent(80),
|
|
225
|
+
innerRadius: am5.percent(60),
|
|
226
|
+
value: 65,
|
|
227
|
+
numberFormat: "#'%'"
|
|
228
|
+
}));
|
|
229
|
+
|
|
230
|
+
// Animate value change
|
|
231
|
+
progress.animate({
|
|
232
|
+
key: "value",
|
|
233
|
+
to: 100,
|
|
234
|
+
duration: 2000
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// Customize appearance
|
|
238
|
+
progress.slice.setAll({ fill: am5.color(0x297373) });
|
|
239
|
+
progress.backgroundSlice.setAll({ fill: am5.color(0xdddddd) });
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## SpriteResizer
|
|
245
|
+
|
|
246
|
+
Adds drag-to-resize handles to any sprite.
|
|
247
|
+
|
|
248
|
+
```js
|
|
249
|
+
var targetSprite = container.children.push(am5.Graphics.new(root, {
|
|
250
|
+
fill: am5.color(0x297373),
|
|
251
|
+
draw: function(display) {
|
|
252
|
+
display.drawRect(0, 0, 200, 100);
|
|
253
|
+
}
|
|
254
|
+
}));
|
|
255
|
+
|
|
256
|
+
var resizer = container.children.push(am5.SpriteResizer.new(root, {
|
|
257
|
+
sprite: targetSprite
|
|
258
|
+
}));
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## EditableLabel
|
|
264
|
+
|
|
265
|
+
A label that becomes an editable text field when clicked.
|
|
266
|
+
|
|
267
|
+
```js
|
|
268
|
+
var label = container.children.push(am5.EditableLabel.new(root, {
|
|
269
|
+
text: "Click to edit",
|
|
270
|
+
editOn: "click", // "click" | "dblclick" | "rightclick" | "none"
|
|
271
|
+
multiLine: false,
|
|
272
|
+
fontSize: 16,
|
|
273
|
+
fill: am5.color(0x000000)
|
|
274
|
+
}));
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## Modal
|
|
280
|
+
|
|
281
|
+
An HTML overlay dialog.
|
|
282
|
+
|
|
283
|
+
```js
|
|
284
|
+
var modal = am5.Modal.new(root, {
|
|
285
|
+
content: "<h2>Notice</h2><p>Chart data is loading...</p>"
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
modal.open();
|
|
289
|
+
|
|
290
|
+
modal.events.on("closed", function() {
|
|
291
|
+
console.log("Modal closed");
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// Close programmatically
|
|
295
|
+
modal.close();
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## ColorPicker
|
|
301
|
+
|
|
302
|
+
**Requires** `plugins/colorPicker.js` loaded before use.
|
|
303
|
+
|
|
304
|
+
```js
|
|
305
|
+
var picker = container.children.push(
|
|
306
|
+
am5plugins_colorPicker.ColorPicker.new(root, {
|
|
307
|
+
color: am5.color(0xff0000),
|
|
308
|
+
colorOpacity: 1
|
|
309
|
+
})
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
picker.events.on("colorchanged", function(ev) {
|
|
313
|
+
console.log("New color:", ev.color);
|
|
314
|
+
console.log("Opacity:", ev.colorOpacity);
|
|
315
|
+
});
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
## Layout examples
|
|
321
|
+
|
|
322
|
+
### Vertical layout — chart with controls below
|
|
323
|
+
|
|
324
|
+
```js
|
|
325
|
+
var outerContainer = root.container.children.push(am5.Container.new(root, {
|
|
326
|
+
width: am5.percent(100),
|
|
327
|
+
height: am5.percent(100),
|
|
328
|
+
layout: root.verticalLayout
|
|
329
|
+
}));
|
|
330
|
+
|
|
331
|
+
// Chart takes most space
|
|
332
|
+
var chart = outerContainer.children.push(am5xy.XYChart.new(root, {
|
|
333
|
+
width: am5.percent(100),
|
|
334
|
+
height: am5.percent(80)
|
|
335
|
+
}));
|
|
336
|
+
|
|
337
|
+
// Controls row below
|
|
338
|
+
var controlsRow = outerContainer.children.push(am5.Container.new(root, {
|
|
339
|
+
width: am5.percent(100),
|
|
340
|
+
height: am5.percent(20),
|
|
341
|
+
layout: root.horizontalLayout,
|
|
342
|
+
paddingTop: 10
|
|
343
|
+
}));
|
|
344
|
+
|
|
345
|
+
controlsRow.children.push(am5.Slider.new(root, {
|
|
346
|
+
orientation: "horizontal",
|
|
347
|
+
width: am5.percent(60)
|
|
348
|
+
}));
|
|
349
|
+
|
|
350
|
+
controlsRow.children.push(am5.Button.new(root, {
|
|
351
|
+
label: am5.Label.new(root, { text: "Reset" })
|
|
352
|
+
}));
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Grid layout — dashboard with multiple charts
|
|
356
|
+
|
|
357
|
+
```js
|
|
358
|
+
var grid = root.container.children.push(am5.Container.new(root, {
|
|
359
|
+
width: am5.percent(100),
|
|
360
|
+
height: am5.percent(100),
|
|
361
|
+
layout: am5.GridLayout.new(root, { maxColumns: 2, fixedWidthGrid: true })
|
|
362
|
+
}));
|
|
363
|
+
|
|
364
|
+
// Each child fills one grid cell
|
|
365
|
+
var chart1Container = grid.children.push(am5.Container.new(root, {
|
|
366
|
+
width: am5.percent(100),
|
|
367
|
+
height: 300
|
|
368
|
+
}));
|
|
369
|
+
var chart2Container = grid.children.push(am5.Container.new(root, {
|
|
370
|
+
width: am5.percent(100),
|
|
371
|
+
height: 300
|
|
372
|
+
}));
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Horizontal layout — legend + chart side by side
|
|
376
|
+
|
|
377
|
+
```js
|
|
378
|
+
var row = root.container.children.push(am5.Container.new(root, {
|
|
379
|
+
width: am5.percent(100),
|
|
380
|
+
height: am5.percent(100),
|
|
381
|
+
layout: root.horizontalLayout
|
|
382
|
+
}));
|
|
383
|
+
|
|
384
|
+
var legend = row.children.push(am5.Legend.new(root, {
|
|
385
|
+
width: 200,
|
|
386
|
+
layout: root.verticalLayout
|
|
387
|
+
}));
|
|
388
|
+
|
|
389
|
+
var chart = row.children.push(am5xy.XYChart.new(root, {
|
|
390
|
+
width: am5.percent(100),
|
|
391
|
+
height: am5.percent(100)
|
|
392
|
+
}));
|
|
393
|
+
```
|