@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.
@@ -0,0 +1,286 @@
1
+ ---
2
+ title: "Saturn and Its Rings"
3
+ source: "https://www.amcharts.com/demos/saturn-and-its-rings/"
4
+ category: "maps"
5
+ scraped: "2026-10-25"
6
+ ---
7
+
8
+ Saturn drawn with a map chart: the planet is a globe of colored bands spinning under its storms, the rings are map lines raised above it at their real distances, as strong as the rings are dense, and the six largest moons go round at their real relative speeds.
9
+
10
+ More than maps of the Earth: A map chart draws anything you can place by latitude and longitude, and since 5.21.0 by height too: lines and points can float above the globe, and the globe hides what passes behind it. Here that makes a planet with its rings and moons, with no 3D library: bands are polygons, the rings are circles of map lines at their real distances, and the moons are map points.
11
+
12
+ Good for:
13
+ - Space and science pages
14
+ - Anything round a sphere: orbits, satellites, flight paths
15
+ - An eye-catching opener
16
+
17
+ Think twice when:
18
+ - Exact distances: the moons' distances are squeezed to fit
19
+ - Plain data on a planet: a flat map is easier to read
20
+
21
+ Prompt: Create Saturn as a map chart in globe projection as a time-lapse, a Saturn day in 30 seconds: the planet as cream latitude bands with darker belts (map polygons) and a few storms as markers lying flat on its surface that go round once a day, the C, B and A rings and the Cassini Division as circles of map lines round the equator raised to their real distances from the center, each as opaque as the ring is dense, and the six largest moons as map points raised onto faint dashed orbits, each going round in its real period at the same scale, their distances beyond the rings squeezed logarithmically so Titan fits. View it from 18.5 degrees above the ring plane with the planet leaning 20 degrees, on a dark background. Tooltips: the planet's size, each ring's name and span, each moon's name and real distance. 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
+ root.setThemes([
33
+ am5themes_Animated.new(root),
34
+ am5themes_Responsive.new(root)
35
+ ]);
36
+
37
+ // The buttons (the zoom control) in a dark slate that suits the night sky, instead of the default blue
38
+ root.interfaceColors.setAll({
39
+ primaryButton: am5.color(0x2a3042),
40
+ primaryButtonHover: am5.color(0x3a4259),
41
+ primaryButtonDown: am5.color(0x485170),
42
+ primaryButtonActive: am5.color(0x485170),
43
+ primaryButtonStroke: am5.color(0x4a5370),
44
+ primaryButtonText: am5.color(0xe6e8f0),
45
+ primaryButtonDisabled: am5.color(0x1c2030), // the minus button, zoomed out as far as it goes
46
+ primaryButtonTextDisabled: am5.color(0x5c6278)
47
+ });
48
+
49
+ // Saturn as a map: the planet is a globe of colored latitude bands, the rings are map lines raised above it and the
50
+ // moons are map points raised the same way, so the planet hides whatever passes behind it. Heights are in meters of
51
+ // the map's globe, which is the Earth's size: a ring 1.5 planet radii from the center is half a globe radius up
52
+ var GLOBE = 6371008.8; // the map globe's radius, meters
53
+ var SATURN = 60268; // Saturn's radius at the equator, km
54
+ function height(km) { return (km / SATURN - 1) * GLOBE; } // a distance from Saturn's center, as a height
55
+
56
+
57
+ // Create the map chart: the camera 18.5° above the ring plane, and the planet leaning, as Saturn is seen from its
58
+ // own orbit mid-season. The camera stays put: the planet spins under it and the moons go round (below)
59
+ // https://docs.amcharts.com/v5/charts/map-chart/
60
+ var chart = root.container.children.push(am5map.MapChart.new(root, {
61
+ projection: am5map.geoOrthographic(), // a globe
62
+ panX: "rotateX", // a sideways drag turns the planet
63
+ panY: "rotateY", // an up or down drag tilts it
64
+ rotationY: -18.5, // the rings open 18.5° toward the camera
65
+ rotationZ: -20, // and lean on the screen
66
+ homeZoomLevel: 0.42, // zoomed out far enough for the moons around the planet...
67
+ minZoomLevel: 0.42, // zooming out stops there: any further and the moons are specks
68
+ zoomLevel: 0.42,
69
+ autoHome: true // ...from the start
70
+ }));
71
+
72
+ // A time-lapse: a Saturn day (10.7 hours) in 30 seconds, and the moons as fast as they really are, at that scale
73
+ var DAY = 30000; // milliseconds
74
+ var HOUR = DAY / 10.66; // milliseconds for an hour
75
+
76
+
77
+ // ── The planet ──
78
+
79
+ // Create polygon series for the planet: a cream globe with darker and lighter bands across it
80
+ // https://docs.amcharts.com/v5/charts/map-chart/map-polygon-series/
81
+ var planetSeries = chart.series.push(am5map.MapPolygonSeries.new(root, {}));
82
+ planetSeries.mapPolygons.template.setAll({
83
+ strokeOpacity: 0, // no outlines: the bands blend into each other
84
+ tooltipText: "{name}",
85
+ templateField: "polygonSettings" // each band's color comes from its data
86
+ });
87
+
88
+ // The color of a band, from the pale cream of the equator to the tan of the belts
89
+ function tone(t) {
90
+ return am5.Color.interpolate(t, am5.color(0xf3e6c4), am5.color(0xb48a55));
91
+ }
92
+
93
+ var planet = [
94
+ // the whole globe, cream, with the planet's numbers on hover
95
+ { geometry: am5map.getGeoRectangle(90, 180, -90, -180), name: "Saturn\n120,536 km across at the equator", polygonSettings: { fill: tone(0.15) } }
96
+ ];
97
+ // the belts and zones: from latitude, to latitude, how dark (0 the palest, 1 the darkest)
98
+ [
99
+ [8, 22, 0.75], [-8, -24, 0.8], [26, 32, 0.4], [-28, -33, 0.45], [36, 42, 0.55], [-38, -44, 0.5],
100
+ [46, 52, 0.45], [-48, -55, 0.4], [58, 90, 0.6], [-60, -90, 0.6]
101
+ ].forEach(function(band) {
102
+ planet.push({
103
+ geometry: am5map.getGeoRectangle(Math.max(band[0], band[1]), 180, Math.min(band[0], band[1]), -180),
104
+ name: "Saturn\n120,536 km across at the equator",
105
+ polygonSettings: { fill: tone(band[2]) }
106
+ });
107
+ });
108
+ planetSeries.data.setAll(planet);
109
+
110
+ // Create point series for storms: markers that lie flat on the planet's surface (surfaceBullets), so they turn with
111
+ // it and flatten toward its edge. Each goes round once a Saturn day: the bands look the same all the way round, so
112
+ // the storms are what shows the planet spinning
113
+ // https://docs.amcharts.com/v5/charts/map-chart/map-point-series/#surface-bullets
114
+ var stormSeries = chart.series.push(am5map.MapPointSeries.new(root, {
115
+ latitudeField: "latitude",
116
+ longitudeField: "longitude",
117
+ surfaceBullets: true
118
+ }));
119
+ stormSeries.bullets.push(function() {
120
+ return am5.Bullet.new(root, {
121
+ sprite: am5.Circle.new(root, {
122
+ // no radius here: a setting made here would win over the size each storm's data gives
123
+ interactive: false, // the planet underneath has the tooltip
124
+ templateField: "stormSettings" // each storm's size, color and motion come from its data
125
+ })
126
+ });
127
+ });
128
+ // longitude, latitude, size (pixels), how dark
129
+ stormSeries.data.setAll([[150, 40, 9, 0.05], [-60, -17, 6, 0.95], [40, 34, 4, 0.1], [100, 34, 4, 0.1], [-120, 15, 4, 0.2]].map(function(storm) {
130
+ return {
131
+ longitude: storm[0],
132
+ latitude: storm[1],
133
+ stormSettings: {
134
+ radius: storm[2],
135
+ fill: tone(storm[3]),
136
+ // the storm's longitude goes once round the planet a day, for ever (loops: 0); eastward, as Saturn spins
137
+ animations: [{ target: "dataItem", key: "longitude", from: storm[0], to: storm[0] + 360, duration: DAY, loops: 0 }]
138
+ }
139
+ };
140
+ }));
141
+
142
+
143
+ // Add zoom control: plus, minus and home buttons, at the bottom left
144
+ // https://docs.amcharts.com/v5/charts/map-chart/map-pan-zoom/#zoom-control
145
+ var zoomControl = chart.set("zoomControl", am5map.ZoomControl.new(root, {
146
+ x: 0, // at the chart's left edge...
147
+ centerX: 0,
148
+ dx: 10 // ...10px in
149
+ }));
150
+ zoomControl.homeButton.set("visible", true); // the home button is hidden by default
151
+
152
+
153
+ // ── The rings ──
154
+
155
+ // Create line series for the rings: circles round the equator at the rings' real distances, raised above the
156
+ // planet. Each line is as strong as the rings are dense there, so the gaps show
157
+ // https://docs.amcharts.com/v5/charts/map-chart/map-line-series/
158
+ var ringSeries = chart.series.push(am5map.MapLineSeries.new(root, {}));
159
+ ringSeries.mapLines.template.setAll({
160
+ stroke: am5.color(0xe9dcc0), // a pale beige
161
+ strokeWidth: 3,
162
+ altitude: 0, // each point of a line carries its own height (the third number of its coordinates)
163
+ tooltipText: "[bold]{ring}[/]\n{span}",
164
+ templateField: "lineSettings" // each line's strength comes from its data
165
+ });
166
+
167
+ // A circle round the equator at a distance from Saturn's center (km): longitude, latitude and height
168
+ function circle(km) {
169
+ var coordinates = [];
170
+ for (var longitude = -180; longitude <= 180; longitude += 5) {
171
+ coordinates.push([longitude, 0, height(km)]);
172
+ }
173
+ return { type: "LineString", coordinates: coordinates };
174
+ }
175
+
176
+ // The main rings: inner and outer edge (km from Saturn's center) and how dense they are, 0 to 1 (approximate)
177
+ var RINGS = [
178
+ { name: "C ring", from: 74658, to: 91975, density: 0.12 },
179
+ { name: "B ring", from: 91975, to: 117507, density: 0.85 },
180
+ { name: "Cassini Division", from: 117507, to: 122053, density: 0.05 },
181
+ { name: "A ring", from: 122053, to: 136774, density: 0.5 }
182
+ ];
183
+ var rings = [];
184
+ RINGS.forEach(function(ring) {
185
+ var lines = Math.max(2, Math.round((ring.to - ring.from) / 1800)); // a line every 1,800 km or so
186
+ for (var i = 0; i < lines; i++) {
187
+ rings.push({
188
+ geometry: circle(ring.from + (ring.to - ring.from) * (i + 0.5) / lines),
189
+ ring: ring.name,
190
+ span: Math.round(ring.from / 1000) + ",000 to " + Math.round(ring.to / 1000) + ",000 km from Saturn's center",
191
+ lineSettings: { strokeOpacity: 0.15 + 0.75 * ring.density }
192
+ });
193
+ }
194
+ });
195
+ ringSeries.data.setAll(rings);
196
+
197
+
198
+ // ── The moons ──
199
+
200
+ // The six largest moons, with their real distances from Saturn's center (km), orbital periods (hours) and radii (km). On the map they are closer in: the
201
+ // distances beyond the rings are squeezed (logarithmic), so Titan, 20 Saturn radii out, still fits on screen
202
+ var MOONS = [
203
+ { name: "Mimas", distance: 185539, period: 22.6, radius: 198, longitude: 150 },
204
+ { name: "Enceladus", distance: 237948, period: 32.9, radius: 252, longitude: -60 },
205
+ { name: "Tethys", distance: 294619, period: 45.3, radius: 531, longitude: -125 },
206
+ { name: "Dione", distance: 377396, period: 65.7, radius: 561, longitude: 50 },
207
+ { name: "Rhea", distance: 527108, period: 108.4, radius: 764, longitude: 120 },
208
+ { name: "Titan", distance: 1221870, period: 382.7, radius: 2575, longitude: -28 }
209
+ ];
210
+ function shown(km) {
211
+ var r = km / SATURN; // in Saturn radii
212
+ return r <= 2.45 ? r : 2.45 + 0.5 * Math.log(r / 2.45);
213
+ }
214
+
215
+ // Create line series for the moons' orbits: faint circles at the moons' heights
216
+ var orbitSeries = chart.series.push(am5map.MapLineSeries.new(root, {}));
217
+ orbitSeries.mapLines.template.setAll({
218
+ stroke: am5.color(0xffffff),
219
+ strokeOpacity: 0.15,
220
+ strokeDasharray: [2, 3],
221
+ altitude: 0,
222
+ interactive: false // the orbits take no pointer: the moons have the tooltips
223
+ });
224
+ orbitSeries.data.setAll(MOONS.map(function(moon) {
225
+ return { geometry: circle(shown(moon.distance) * SATURN) };
226
+ }));
227
+
228
+ // Create point series for the moons, raised to their orbits (altitudeField)
229
+ // https://docs.amcharts.com/v5/charts/map-chart/map-point-series/
230
+ var moonSeries = chart.series.push(am5map.MapPointSeries.new(root, {
231
+ latitudeField: "latitude",
232
+ longitudeField: "longitude",
233
+ altitudeField: "altitude"
234
+ }));
235
+ moonSeries.bullets.push(function() {
236
+ var circle = am5.Circle.new(root, {
237
+ // no radius here: a setting made here would win over the size each moon's data gives
238
+ fill: am5.color(0xf4f0e8),
239
+ tooltipText: "[bold]{name}[/]\n{across} km across\n{km} km from Saturn's center",
240
+ tooltipY: 0, // the tooltip points at the top of the moon, not its middle
241
+ templateField: "circleSettings" // each moon's size comes from its data
242
+ });
243
+ // pointed at, the moon grows a little
244
+ // https://docs.amcharts.com/v5/concepts/settings/states/
245
+ circle.states.create("hover", { scale: 1.5 });
246
+ return am5.Bullet.new(root, { sprite: circle });
247
+ });
248
+ moonSeries.data.setAll(MOONS.map(function(moon, i) {
249
+ return {
250
+ name: moon.name,
251
+ km: moon.distance.toLocaleString("en-US"),
252
+ across: (moon.radius * 2).toLocaleString("en-US"),
253
+ longitude: moon.longitude,
254
+ latitude: 0,
255
+ altitude: height(shown(moon.distance) * SATURN),
256
+ circleSettings: {
257
+ radius: Math.max(2, 8 * Math.sqrt(moon.radius / 2575)), // by the square root of the moon's size: Titan 8px, Mimas 2px
258
+ // once round its orbit in its own period (hours, at the time-lapse's scale), for ever
259
+ animations: [{ target: "dataItem", key: "longitude", from: moon.longitude, to: moon.longitude + 360, duration: Math.round(moon.period * HOUR), loops: 0 }]
260
+ }
261
+ };
262
+ }));
263
+ ```
264
+
265
+ ## HTML
266
+
267
+ ```html
268
+ <div id="chartdiv"></div>
269
+ ```
270
+
271
+ ## CSS
272
+
273
+ ```css
274
+ #chartdiv {
275
+ width: 100%;
276
+ height: 500px;
277
+ font-size: 0.875rem;
278
+ }
279
+ ```
280
+
281
+ ## Required resources
282
+
283
+ - https://cdn.amcharts.com/lib/5/index.js
284
+ - https://cdn.amcharts.com/lib/5/map.js
285
+ - https://cdn.amcharts.com/lib/5/themes/Animated.js
286
+ - https://cdn.amcharts.com/lib/5/themes/Responsive.js
@@ -0,0 +1,326 @@
1
+ ---
2
+ title: "Radial Ridgeline Chart"
3
+ source: "https://www.amcharts.com/demos/radial-ridgeline-chart/"
4
+ category: "radar-polar"
5
+ scraped: "2026-10-25"
6
+ ---
7
+
8
+ A year of a solar array's output as twelve rings, each a month's average day: midnight at the bottom, noon at the top. The latest month is in color and the eleven before it in gray, so it shows at a glance how this month compares with the rest of the year.
9
+
10
+ When a radial ridgeline works: A ridgeline stacks many curves of the same kind, each lifted off a baseline of its own, so they can overlap without hiding each other's shape. Bent into rings, it suits anything that runs round a clock: each hour sits at the same angle on every ring, so a year of daily patterns shows in one view, and one ring in color stands out against the rest.
11
+
12
+ Good for:
13
+ - Daily patterns: energy, traffic, visits by hour
14
+ - Many similar curves where the shape matters
15
+ - Spotting the days that break a pattern
16
+
17
+ Think twice when:
18
+ - Exact values: a line chart is easier to read
19
+ - A few series: plain lines are clearer
20
+ - Data with no daily or yearly cycle
21
+
22
+ Prompt: Create a radial ridgeline of a year of sample solar output from a 10 kW array: twelve rings, one per month from November 2025 to October 2026, each the month's average day in 15-minute steps. Use a radar chart with the 24 hours round a date axis over one day, midnight at the bottom and noon at the top, and one smoothed line per month on a ring of its own, the oldest innermost, lifted off its ring by the output so summer noons swell out over the next rings. Draw the eleven earlier months as thin gray lines and the latest month in the theme's first color; the line under the pointer turns blue. Label each ring with its month at midnight, on a small background so the line passes behind it. A cursor (a spoke only) shows only the tooltip of the line nearest the pointer: the month and the average output at that time in kW. Use the amCharts 5 library with its Responsive theme.
23
+
24
+ ## JavaScript
25
+
26
+ ```javascript
27
+ // Create root element
28
+ // https://docs.amcharts.com/v5/getting-started/#root-element
29
+ var root = am5.Root.new("chartdiv");
30
+
31
+ // Set themes
32
+ // https://docs.amcharts.com/v5/concepts/themes/
33
+ var responsive = am5themes_Responsive.new(root); // kept in a variable: a rule of its own is added below
34
+ root.setThemes([
35
+ am5themes_Animated.new(root),
36
+ responsive
37
+ ]);
38
+
39
+
40
+ // ── Sample data: a year of output from a 10 kW solar array at 48° north (Munich, Paris), every 15 minutes ──
41
+
42
+ var CAPACITY = 10; // the array's top output, kW
43
+ var STEPS = 96; // fifteen-minute steps a day
44
+
45
+ // A seeded random number generator (mulberry32): the same clouds on every visit
46
+ function makeRandom(seed) {
47
+ return function() {
48
+ seed = seed + 0x6D2B79F5 | 0;
49
+ var t = Math.imul(seed ^ seed >>> 15, 1 | seed);
50
+ t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
51
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
52
+ };
53
+ }
54
+
55
+ // One day's output, kW, every 15 minutes: the sun's path on that date, dented by the day's clouds and by the month's
56
+ // weather (makeYear)
57
+ function makeDay(date, random, weather) {
58
+ // the day's length and how high the sun gets at noon follow the date
59
+ var dayOfYear = (date - new Date(date.getFullYear(), 0, 0)) / 864e5;
60
+ var declination = 23.44 * Math.sin(2 * Math.PI * (284 + dayOfYear) / 365) * Math.PI / 180;
61
+ var latitude = 48 * Math.PI / 180;
62
+ var halfDay = Math.acos(-Math.tan(latitude) * Math.tan(declination)) * 12 / Math.PI; // hours from sunrise to noon
63
+ var noon = 12.4; // the sun is highest a little after 12:00 on the clock
64
+ var rise = noon - halfDay;
65
+ var set = noon + halfDay;
66
+ // the share of the capacity a clear noon gives: all of it in June, about a third in December
67
+ var peak = Math.min(1, Math.sin(Math.PI / 2 - latitude + declination) / Math.sin(62 * Math.PI / 180));
68
+
69
+ // the sky: half the days clear, a third broken, the rest grey
70
+ var r = random();
71
+ var sky = r < 0.5 ? 0.92 + 0.08 * random() : r < 0.82 ? 0.7 + 0.2 * random() : 0.2 + 0.3 * random();
72
+ // passing clouds, each a dent in the curve: light ones on a clear day, deeper on the others
73
+ var clouds = [];
74
+ var count = sky > 0.9 ? 1 + Math.floor(random() * 2) : 2 + Math.floor(random() * 4);
75
+ for (var i = 0; i < count; i++) {
76
+ clouds.push({
77
+ hour: rise + 1.2 + random() * (set - rise - 2.4), // when it passes
78
+ width: 0.25 + random() * 0.6, // how long it takes, hours
79
+ depth: sky > 0.9 ? 0.15 + random() * 0.3 : 0.3 + random() * 0.5 // the share of light it takes away
80
+ });
81
+ }
82
+ // the month's recurring clouds (morning fog, afternoon storms...), a little earlier or later and stronger or weaker
83
+ // from day to day, so they still show in the month's average
84
+ weather.clouds.forEach(function(cloud) {
85
+ clouds.push({
86
+ hour: cloud.hour + (random() - 0.5) * 0.8,
87
+ width: cloud.width,
88
+ depth: Math.min(0.9, cloud.depth * (0.5 + random()))
89
+ });
90
+ });
91
+
92
+ var output = [];
93
+ for (var step = 0; step < STEPS; step++) {
94
+ var hour = step * 24 / STEPS;
95
+ // a clear day's curve: zero at night, rising to the noon peak
96
+ var clear = hour > rise && hour < set ? Math.pow(Math.sin(Math.PI * (hour - rise) / (set - rise)), 1.25) * peak : 0;
97
+ var light = sky * weather.sky; // the day's sky in the month's light
98
+ clouds.forEach(function(cloud) {
99
+ light *= 1 - cloud.depth * Math.exp(-Math.pow((hour - cloud.hour) / cloud.width, 2));
100
+ });
101
+ output.push(CAPACITY * clear * light);
102
+ }
103
+ return output;
104
+ }
105
+
106
+ // The average day of each of the twelve months to October 2026, oldest first: for every 15-minute step, the output of
107
+ // all the month's days added up and divided by their number
108
+ var FIRST_MONTH = new Date(2025, 10, 1); // November 2025
109
+ function makeYear() {
110
+ var random = makeRandom(7);
111
+ var months = [];
112
+ for (var m = 0; m < 12; m++) {
113
+ var start = new Date(FIRST_MONTH.getFullYear(), FIRST_MONTH.getMonth() + m, 1);
114
+ var count = new Date(start.getFullYear(), start.getMonth() + 1, 0).getDate(); // the month's last day
115
+ // the month's own weather: two to four cloud times that come back most days, and how bright the month is overall
116
+ var weather = { sky: 0.75 + 0.25 * random(), clouds: [] };
117
+ var times = 2 + Math.floor(random() * 3);
118
+ for (var c = 0; c < times; c++) {
119
+ weather.clouds.push({ hour: 7 + random() * 11, width: 0.4 + random() * 0.8, depth: 0.25 + random() * 0.35 });
120
+ }
121
+ var sum = [];
122
+ for (var day = 1; day <= count; day++) {
123
+ makeDay(new Date(start.getFullYear(), start.getMonth(), day), random, weather).forEach(function(kW, step) {
124
+ sum[step] = (sum[step] || 0) + kW;
125
+ });
126
+ }
127
+ months.push({ date: start, output: sum.map(function(kW) { return kW / count; }) });
128
+ }
129
+ return months;
130
+ }
131
+ var months = makeYear();
132
+
133
+
134
+ // ── The chart: one ring a month ──
135
+
136
+ // Create chart
137
+ // https://docs.amcharts.com/v5/charts/radar-chart/
138
+ var chart = root.container.children.push(am5radar.RadarChart.new(root, {
139
+ panX: false, // no dragging...
140
+ panY: false,
141
+ wheelX: "none", // ...or zooming with the wheel
142
+ wheelY: "none",
143
+ startAngle: 90, // midnight at the bottom...
144
+ endAngle: 450, // ...and the full circle round, so noon is at the top
145
+ radius: am5.percent(92), // most of the space, leaving just room for the hour labels
146
+ innerRadius: am5.percent(20), // the first months get room to swell, clear of the middle
147
+ maxTooltipDistance: 1 // only the tooltip of the line nearest the pointer, not one for every month
148
+ }));
149
+
150
+ // Create axes
151
+ // https://docs.amcharts.com/v5/charts/radar-chart/radar-axes/
152
+ // The hours of the day round the circle: a date axis over one day. Every ring takes its times on that same day,
153
+ // so 13:00 is at the same angle on every ring
154
+ var DAY = new Date(2026, 0, 1).getTime(); // any day without a clock change
155
+ var xRenderer = am5radar.AxisRendererCircular.new(root, {
156
+ minGridDistance: 40 // labels at least 40px apart round the rim
157
+ });
158
+ xRenderer.labels.template.setAll({
159
+ multiLocation: 0, // each hour at its spoke, not between two
160
+ textType: "regular", // upright, not turned along the circle
161
+ radius: 16, // out from the rim, clear of the highest noon
162
+ maxPosition: 0.99 // the day's end is its start: one 00:00, not two on top of each other
163
+ });
164
+ xRenderer.grid.template.setAll({
165
+ strokeOpacity: 0.08 // faint spokes, so they don't cut through the lines
166
+ });
167
+ var xAxis = chart.xAxes.push(am5xy.DateAxis.new(root, {
168
+ baseInterval: { timeUnit: "minute", count: 15 }, // the data comes every 15 minutes
169
+ gridIntervals: [{ timeUnit: "hour", count: 3 }], // a spoke every three hours
170
+ min: DAY,
171
+ max: DAY + 864e5, // midnight to midnight
172
+ strictMinMax: true,
173
+ markUnitChange: false, // midnight shows 00:00 like every other hour, not the date of a new day
174
+ renderer: xRenderer
175
+ }));
176
+
177
+ // The rings go out from the middle, one value unit a month. The values place the lines but mean nothing to a reader,
178
+ // so the axis shows no numbers or grid: only each ring's month (below)
179
+ var yRenderer = am5radar.AxisRendererRadial.new(root, {
180
+ axisAngle: 90 // the axis runs down to midnight, where every ring lies flat on its own value
181
+ });
182
+ yRenderer.labels.template.set("forceHidden", true);
183
+ yRenderer.grid.template.set("forceHidden", true);
184
+ var yAxis = chart.yAxes.push(am5xy.ValueAxis.new(root, {
185
+ min: 0, // the first month's ring is one unit out from the hole
186
+ strictMinMax: true, // the rim is the highest noon, not rounded up to a round number
187
+ renderer: yRenderer
188
+ }));
189
+
190
+ // Create series
191
+ // https://docs.amcharts.com/v5/charts/radar-chart/radar-series/
192
+ // One line a month, the oldest nearest the middle and the latest at the rim. A month's output lifts its line off its
193
+ // own ring, so a summer noon swells out over the rings after it: a radial ridgeline. The latest month takes the
194
+ // theme's first color; the eleven before it are gray lines, for comparison
195
+ var gray = root.interfaceColors.get("alternativeBackground");
196
+ var ridgeHeight = 10; // a noon at full capacity swells out over this many rings
197
+ var lines = [];
198
+ var monthLabels = [];
199
+ months.forEach(function(month, index) {
200
+ var latest = index === months.length - 1;
201
+ var settings = {
202
+ name: root.dateFormatter.format(month.date, "MMMM yyyy"), // for the tooltip
203
+ xAxis: xAxis,
204
+ yAxis: yAxis,
205
+ valueXField: "time",
206
+ valueYField: "value",
207
+ tooltip: am5.Tooltip.new(root, {
208
+ labelText: "[bold]{name}[/]\nAverage at {valueX.formatDate('HH:mm')}: {power} kW"
209
+ })
210
+ };
211
+ // gray for the earlier months; the latest is given no color, so it takes the theme's first
212
+ if (!latest) {
213
+ settings.stroke = gray;
214
+ settings.fill = gray;
215
+ }
216
+ var series = chart.series.push(am5radar.SmoothedRadarLineSeries.new(root, settings));
217
+ series.strokes.template.setAll({
218
+ strokeWidth: latest ? 2.5 : 1.5, // the latest month stands out (a 1px line is too thin to point at)
219
+ strokeOpacity: latest ? 1 : 0.45, // the gray lines are quieter
220
+ interactive: true // the line takes the pointer, for its hover state
221
+ });
222
+ // the line under the pointer turns blue and thicker, which also makes it easier to stay on
223
+ series.strokes.template.states.create("hover", {
224
+ stroke: am5.color(0x2d7ff9),
225
+ strokeWidth: 3.5,
226
+ strokeOpacity: 1
227
+ });
228
+ lines.push(series);
229
+
230
+ // The month's name on its ring at midnight, on the radial axis at the bottom, with a backing in the chart's
231
+ // background color so the ring passes behind it
232
+ // https://docs.amcharts.com/v5/charts/xy-chart/axes/axis-ranges/
233
+ var range = yAxis.createAxisRange(yAxis.makeDataItem({ value: index + 1 }));
234
+ range.get("label").setAll({
235
+ forceHidden: false, // the axis' own labels are hidden; this one shows
236
+ text: root.dateFormatter.format(month.date, "MMM"),
237
+ fontSize: "0.75em",
238
+ fontWeight: latest ? "700" : "400",
239
+ centerX: am5.p50,
240
+ centerY: am5.p50,
241
+ paddingTop: 1,
242
+ paddingBottom: 1,
243
+ paddingLeft: 3,
244
+ paddingRight: 3,
245
+ background: am5.RoundedRectangle.new(root, {
246
+ fill: root.interfaceColors.get("background"),
247
+ fillOpacity: 1
248
+ })
249
+ });
250
+ range.get("grid").set("forceHidden", true);
251
+ monthLabels.push(range.get("label"));
252
+ });
253
+
254
+ // On a narrow chart (a phone) the rings are too close for every month's name: only every third month keeps its label
255
+ // (January, April, July and October). The rule is undone on a wider chart
256
+ responsive.addRule({
257
+ relevant: function(width) { return width < 600; }, // the chart is under 600px wide
258
+ applying: function() {
259
+ monthLabels.forEach(function(label, index) {
260
+ label.set("forceHidden", (index + 1) % 3 !== 0);
261
+ });
262
+ },
263
+ removing: function() {
264
+ monthLabels.forEach(function(label) {
265
+ label.set("forceHidden", false);
266
+ });
267
+ }
268
+ });
269
+
270
+ // Add cursor
271
+ // https://docs.amcharts.com/v5/charts/xy-chart/cursor/
272
+ // A spoke follows the pointer, and the tooltip of the month nearest to it shows
273
+ var cursor = chart.set("cursor", am5radar.RadarCursor.new(root, {}));
274
+ cursor.lineY.set("visible", false); // no circle round the middle: the hovered line marks the month
275
+
276
+
277
+ // ── Drawing the year ──
278
+
279
+ // Each line's points: the month's ring plus its average output scaled to the ridge height. The times are on the
280
+ // axis's day
281
+ function lineData(index, month) {
282
+ return month.output.map(function(kW, step) {
283
+ return {
284
+ time: DAY + step * 9e5, // 15 minutes apart
285
+ value: Math.round((index + 1 + ridgeHeight * kW / CAPACITY) * 100) / 100, // two decimals are plenty to draw
286
+ power: Math.round(kW * 10) / 10 // for the tooltip
287
+ };
288
+ });
289
+ }
290
+
291
+ function drawLines() {
292
+ lines.forEach(function(series, index) {
293
+ series.data.setAll(lineData(index, months[index]));
294
+ });
295
+ }
296
+
297
+ drawLines();
298
+
299
+ // Make stuff animate on load
300
+ // https://docs.amcharts.com/v5/concepts/animations/
301
+ chart.appear(1000, 100);
302
+ ```
303
+
304
+ ## HTML
305
+
306
+ ```html
307
+ <div id="chartdiv"></div>
308
+ ```
309
+
310
+ ## CSS
311
+
312
+ ```css
313
+ #chartdiv {
314
+ width: 100%;
315
+ height: 500px;
316
+ font-size: 0.875rem;
317
+ }
318
+ ```
319
+
320
+ ## Required resources
321
+
322
+ - https://cdn.amcharts.com/lib/5/index.js
323
+ - https://cdn.amcharts.com/lib/5/xy.js
324
+ - https://cdn.amcharts.com/lib/5/radar.js
325
+ - https://cdn.amcharts.com/lib/5/themes/Animated.js
326
+ - https://cdn.amcharts.com/lib/5/themes/Responsive.js
@@ -55,7 +55,7 @@ root.numberFormatter.set("numberFormat", "#,###.00");
55
55
 
56
56
  // Create a main stock panel (chart)
57
57
  // -------------------------------------------------------------------------------
58
- // https://docs.amcharts.com/v5/charts/stock/
58
+ // https://docs.amcharts.com/v5/charts/stock/#panels
59
59
  var mainPanel = stockChart.panels.push(am5stock.StockPanel.new(root, {
60
60
  wheelY: "zoomX", // the mouse wheel zooms in on the dates
61
61
  panX: true, // drag the plot sideways to pan...
@@ -58,7 +58,7 @@ root.numberFormatter.set("numberFormat", "#,###.00"); // thousands separators, a
58
58
 
59
59
  // Create a main stock panel (chart)
60
60
  // -------------------------------------------------------------------------------
61
- // https://docs.amcharts.com/v5/charts/stock/
61
+ // https://docs.amcharts.com/v5/charts/stock/#panels
62
62
  var mainPanel = stockChart.panels.push(
63
63
  am5stock.StockPanel.new(root, {
64
64
  wheelY: "zoomX", // the mouse wheel zooms in on the time
@@ -55,7 +55,7 @@ root.numberFormatter.set("numberFormat", "#,###.00"); // thousands separators an
55
55
 
56
56
  // Create a main stock panel (chart)
57
57
  // -------------------------------------------------------------------------------
58
- // https://docs.amcharts.com/v5/charts/stock/
58
+ // https://docs.amcharts.com/v5/charts/stock/#panels
59
59
  var mainPanel = stockChart.panels.push(am5stock.StockPanel.new(root, {
60
60
  wheelY: "zoomX", // the mouse wheel zooms in on the dates
61
61
  panX: true, // a drag pans through the dates
@@ -123,7 +123,7 @@ var valueLegend = mainPanel.plotContainer.children.push(am5stock.StockLegend.new
123
123
 
124
124
  // Create a volume panel (chart)
125
125
  // -------------------------------------------------------------------------------
126
- // https://docs.amcharts.com/v5/charts/stock/
126
+ // https://docs.amcharts.com/v5/charts/stock/#panels
127
127
  // the main trick: the volume gets a panel of its own; the stock chart zooms both panels together
128
128
  var volumePanel = stockChart.panels.push(am5stock.StockPanel.new(root, {
129
129
  panX: true, // a drag pans through the dates...
@@ -55,7 +55,7 @@ root.numberFormatter.set("numberFormat", "#,###.00"); // thousands separators an
55
55
 
56
56
  // Create a main stock panel (chart)
57
57
  // -------------------------------------------------------------------------------
58
- // https://docs.amcharts.com/v5/charts/stock/
58
+ // https://docs.amcharts.com/v5/charts/stock/#panels
59
59
  var mainPanel = stockChart.panels.push(am5stock.StockPanel.new(root, {
60
60
  wheelY: "zoomX", // the mouse wheel zooms in on the dates
61
61
  panX: true, // a drag pans through the dates...
@@ -55,7 +55,7 @@ root.numberFormatter.set("numberFormat", "#,###.00"); // thousands separators an
55
55
 
56
56
  // Create a main stock panel (chart)
57
57
  // -------------------------------------------------------------------------------
58
- // https://docs.amcharts.com/v5/charts/stock/
58
+ // https://docs.amcharts.com/v5/charts/stock/#panels
59
59
  var mainPanel = stockChart.panels.push(am5stock.StockPanel.new(root, {
60
60
  wheelY: "zoomX", // the mouse wheel zooms in on the dates
61
61
  panX: true, // a drag pans through the dates...