@amcharts/amcharts5-mcp 1.1.8 → 1.1.9

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.
Files changed (2) hide show
  1. package/content/map.md +75 -88
  2. package/package.json +1 -1
package/content/map.md CHANGED
@@ -243,22 +243,20 @@ Two data patterns — polygon IDs or explicit coordinates.
243
243
 
244
244
  **Pattern 1: `sourceId` / `targetId` (country codes)**
245
245
 
246
- IDs use ISO 3166-1 alpha-2 codes matching the geodata. **CRITICAL:** Data MUST be set inside `polygonSeries.events.once("datavalidated", ...)` — the polygon series needs to finish parsing geoJSON before MapSankeySeries can resolve country IDs to centroids. Without this wrapper, `getDataItemById()` returns null and flows silently don't appear (no errors, no bands).
246
+ IDs use ISO 3166-1 alpha-2 codes matching the geodata. Set data directly — `MapSankeySeries` auto-resolves `sourceId`/`targetId` once the referenced `polygonSeries` finishes loading, so data can be set at any time:
247
247
 
248
248
  ```js
249
- polygonSeries.events.once("datavalidated", function() {
250
- sankeySeries.data.setAll([
251
- { sourceId: "BR", targetId: "DE", value: 350 },
252
- { sourceId: "BR", targetId: "US", value: 450 },
253
- { sourceId: "DE", targetId: "FR", value: 150 },
254
- { sourceId: "DE", targetId: "PL", value: 100 }
255
- ]);
256
- });
249
+ sankeySeries.data.setAll([
250
+ { sourceId: "BR", targetId: "DE", value: 350 },
251
+ { sourceId: "BR", targetId: "US", value: 450 },
252
+ { sourceId: "DE", targetId: "FR", value: 150 },
253
+ { sourceId: "DE", targetId: "PL", value: 100 }
254
+ ]);
257
255
  ```
258
256
 
259
- **Pattern 2: Explicit coordinates (no timing needed)**
257
+ **Pattern 2: Explicit coordinates**
260
258
 
261
- When using `sourceLongitude`/`sourceLatitude`/`targetLongitude`/`targetLatitude`, data can be set immediately — no `datavalidated` wrapper required:
259
+ When using `sourceLongitude`/`sourceLatitude`/`targetLongitude`/`targetLatitude`, centroid lookup is skipped entirely:
262
260
  ```js
263
261
  sankeySeries.data.setAll([
264
262
  {
@@ -271,17 +269,15 @@ sankeySeries.data.setAll([
271
269
 
272
270
  **Waypoints** — route flows through intermediate points:
273
271
  ```js
274
- polygonSeries.events.once("datavalidated", function() {
275
- sankeySeries.data.setAll([
276
- {
277
- sourceId: "GB", targetId: "JP", value: 40,
278
- waypoints: [
279
- { longitude: 30, latitude: 65 },
280
- { longitude: 90, latitude: 55 }
281
- ]
282
- }
283
- ]);
284
- });
272
+ sankeySeries.data.setAll([
273
+ {
274
+ sourceId: "GB", targetId: "JP", value: 40,
275
+ waypoints: [
276
+ { longitude: 30, latitude: 65 },
277
+ { longitude: 90, latitude: 55 }
278
+ ]
279
+ }
280
+ ]);
285
281
  ```
286
282
 
287
283
  **WARNING:** Never call `polygonSeries.data.setAll()` with custom objects — this replaces all geoJSON-derived data items, breaking MapSankeySeries centroid resolution. To set per-country properties (like colors), iterate existing data items after `datavalidated` instead:
@@ -405,16 +401,14 @@ Bullets automatically hide on the back side of the globe (orthographic projectio
405
401
  The same country can be both target and source — incoming and outgoing bands share unified stacking at intermediate nodes:
406
402
 
407
403
  ```js
408
- polygonSeries.events.once("datavalidated", function() {
409
- sankeySeries.data.setAll([
410
- // Level 1: Producers > Hubs
411
- { sourceId: "BR", targetId: "DE", value: 350 },
412
- { sourceId: "VN", targetId: "DE", value: 200 },
413
- // Level 2: Hubs > Consumers
414
- { sourceId: "DE", targetId: "FR", value: 150 },
415
- { sourceId: "DE", targetId: "PL", value: 100 }
416
- ]);
417
- });
404
+ sankeySeries.data.setAll([
405
+ // Level 1: Producers > Hubs
406
+ { sourceId: "BR", targetId: "DE", value: 350 },
407
+ { sourceId: "VN", targetId: "DE", value: 200 },
408
+ // Level 2: Hubs > Consumers
409
+ { sourceId: "DE", targetId: "FR", value: 150 },
410
+ { sourceId: "DE", targetId: "PL", value: 100 }
411
+ ]);
418
412
  ```
419
413
 
420
414
  ### Animating bullets along lines (positionOnLine)
@@ -1222,36 +1216,34 @@ Demonstrates: `MapSankeySeries` with `sourceId`/`targetId` data (country codes),
1222
1216
  });
1223
1217
  });
1224
1218
 
1225
- // Set data after polygonSeries loads (sourceId/targetId need centroid lookup)
1226
- // CRITICAL: data MUST be set inside datavalidated handler
1227
- polygonSeries.events.once("datavalidated", function() {
1228
- sankeySeries.data.setAll([
1229
- // Producers > Hubs
1230
- { sourceId: "BR", targetId: "DE", value: 350 },
1231
- { sourceId: "BR", targetId: "US", value: 450 },
1232
- { sourceId: "BR", targetId: "IT", value: 200 },
1233
- { sourceId: "VN", targetId: "DE", value: 200 },
1234
- { sourceId: "VN", targetId: "BE", value: 150 },
1235
- { sourceId: "CO", targetId: "US", value: 250 },
1236
- { sourceId: "CO", targetId: "DE", value: 80 },
1237
- { sourceId: "ET", targetId: "DE", value: 60 },
1238
- { sourceId: "ET", targetId: "BE", value: 40 },
1239
- { sourceId: "ID", targetId: "US", value: 80 },
1240
- { sourceId: "HN", targetId: "DE", value: 60 },
1241
- { sourceId: "HN", targetId: "BE", value: 40 },
1242
- // Hubs > Consumer Markets
1243
- { sourceId: "DE", targetId: "FR", value: 150 },
1244
- { sourceId: "DE", targetId: "PL", value: 100 },
1245
- { sourceId: "DE", targetId: "SE", value: 80 },
1246
- { sourceId: "DE", targetId: "RU", value: 120 },
1247
- { sourceId: "BE", targetId: "GB", value: 100 },
1248
- { sourceId: "BE", targetId: "NL", value: 80 },
1249
- { sourceId: "IT", targetId: "GR", value: 50 },
1250
- { sourceId: "IT", targetId: "AT", value: 40 },
1251
- { sourceId: "US", targetId: "CA", value: 120 },
1252
- { sourceId: "US", targetId: "JP", value: 80 }
1253
- ]);
1254
- });
1219
+ // Set data directly — MapSankeySeries auto-resolves sourceId/targetId
1220
+ // once polygonSeries finishes loading.
1221
+ sankeySeries.data.setAll([
1222
+ // Producers > Hubs
1223
+ { sourceId: "BR", targetId: "DE", value: 350 },
1224
+ { sourceId: "BR", targetId: "US", value: 450 },
1225
+ { sourceId: "BR", targetId: "IT", value: 200 },
1226
+ { sourceId: "VN", targetId: "DE", value: 200 },
1227
+ { sourceId: "VN", targetId: "BE", value: 150 },
1228
+ { sourceId: "CO", targetId: "US", value: 250 },
1229
+ { sourceId: "CO", targetId: "DE", value: 80 },
1230
+ { sourceId: "ET", targetId: "DE", value: 60 },
1231
+ { sourceId: "ET", targetId: "BE", value: 40 },
1232
+ { sourceId: "ID", targetId: "US", value: 80 },
1233
+ { sourceId: "HN", targetId: "DE", value: 60 },
1234
+ { sourceId: "HN", targetId: "BE", value: 40 },
1235
+ // Hubs > Consumer Markets
1236
+ { sourceId: "DE", targetId: "FR", value: 150 },
1237
+ { sourceId: "DE", targetId: "PL", value: 100 },
1238
+ { sourceId: "DE", targetId: "SE", value: 80 },
1239
+ { sourceId: "DE", targetId: "RU", value: 120 },
1240
+ { sourceId: "BE", targetId: "GB", value: 100 },
1241
+ { sourceId: "BE", targetId: "NL", value: 80 },
1242
+ { sourceId: "IT", targetId: "GR", value: 50 },
1243
+ { sourceId: "IT", targetId: "AT", value: 40 },
1244
+ { sourceId: "US", targetId: "CA", value: 120 },
1245
+ { sourceId: "US", targetId: "JP", value: 80 }
1246
+ ]);
1255
1247
 
1256
1248
  // Set country names on auto-created nodes and animate bullets
1257
1249
  var countryNames = {
@@ -1270,31 +1262,27 @@ Demonstrates: `MapSankeySeries` with `sourceId`/`targetId` data (country codes),
1270
1262
  }
1271
1263
  });
1272
1264
 
1273
- // Defer bullet animation — bullets are not yet instantiated
1274
- // when datavalidated fires inside polygonSeries handler
1275
- setTimeout(function() {
1276
- am5.array.each(sankeySeries.dataItems, function(dataItem) {
1277
- var bullets = dataItem.bullets;
1278
- if (bullets) {
1279
- am5.array.each(bullets, function(bullet) {
1280
- var randomDur = 3000 + Math.random() * 3000;
1281
- var delay = Math.random() * randomDur;
1282
- setTimeout(function() {
1283
- var sprite = bullet.get("sprite");
1284
- if (sprite) sprite.set("visible", true);
1285
- bullet.animate({
1286
- key: "locationX",
1287
- from: 0,
1288
- to: 1,
1289
- duration: randomDur,
1290
- easing: am5.ease.linear,
1291
- loops: Infinity
1292
- });
1293
- }, delay);
1294
- });
1295
- }
1296
- });
1297
- }, 100);
1265
+ am5.array.each(sankeySeries.dataItems, function(dataItem) {
1266
+ var bullets = dataItem.bullets;
1267
+ if (bullets) {
1268
+ am5.array.each(bullets, function(bullet) {
1269
+ var randomDur = 3000 + Math.random() * 3000;
1270
+ var delay = Math.random() * randomDur;
1271
+ setTimeout(function() {
1272
+ var sprite = bullet.get("sprite");
1273
+ if (sprite) sprite.set("visible", true);
1274
+ bullet.animate({
1275
+ key: "locationX",
1276
+ from: 0,
1277
+ to: 1,
1278
+ duration: randomDur,
1279
+ easing: am5.ease.linear,
1280
+ loops: Infinity
1281
+ });
1282
+ }, delay);
1283
+ });
1284
+ }
1285
+ });
1298
1286
  });
1299
1287
 
1300
1288
  // Title
@@ -1606,7 +1594,6 @@ Demonstrates: `MapSankeySeries` with explicit `sourceLongitude`/`sourceLatitude`
1606
1594
  var wpPortugal = { longitude: -10, latitude: 39 };
1607
1595
  var viaAtlantic = [wpHormuz, wpAden, wpSuez, wpSicily, wpPortugal];
1608
1596
 
1609
- // No datavalidated wrapper needed — explicit coordinates resolve immediately
1610
1597
  sankeySeries.data.setAll([
1611
1598
  // Ras Tanura (Saudi Arabia)
1612
1599
  flow(rasTanura, "Ras Tanura", ningbo, "Ningbo", 1100, viaChina),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amcharts/amcharts5-mcp",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
4
4
  "mcpName": "io.github.amcharts/amcharts5",
5
5
  "description": "On-demand access to amCharts 5 docs, code examples, and API reference",
6
6
  "type": "module",