@amcharts/amcharts5 5.16.2 → 5.17.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/.internal/charts/map/MapChartDefaultTheme.d.ts.map +1 -1
- package/.internal/charts/map/MapChartDefaultTheme.js +3 -0
- package/.internal/charts/map/MapChartDefaultTheme.js.map +1 -1
- package/.internal/charts/map/MapSankeyNodes.d.ts +155 -0
- package/.internal/charts/map/MapSankeyNodes.d.ts.map +1 -0
- package/.internal/charts/map/MapSankeyNodes.js +151 -0
- package/.internal/charts/map/MapSankeyNodes.js.map +1 -0
- package/.internal/charts/map/MapSankeySeries.d.ts +383 -0
- package/.internal/charts/map/MapSankeySeries.d.ts.map +1 -0
- package/.internal/charts/map/MapSankeySeries.js +794 -0
- package/.internal/charts/map/MapSankeySeries.js.map +1 -0
- package/.internal/core/Classes.d.ts +6 -0
- package/.internal/core/Classes.d.ts.map +1 -1
- package/.internal/core/Classes.js.map +1 -1
- package/.internal/core/Registry.js +1 -1
- package/.internal/core/Registry.js.map +1 -1
- package/.internal/core/util/Entity.d.ts.map +1 -1
- package/.internal/core/util/Entity.js +6 -0
- package/.internal/core/util/Entity.js.map +1 -1
- package/.internal/core/util/Math.d.ts +132 -49
- package/.internal/core/util/Math.d.ts.map +1 -1
- package/.internal/core/util/Math.js +151 -50
- package/.internal/core/util/Math.js.map +1 -1
- package/.internal/core/util/Object.d.ts +24 -1
- package/.internal/core/util/Object.d.ts.map +1 -1
- package/.internal/core/util/Object.js +24 -1
- package/.internal/core/util/Object.js.map +1 -1
- package/.internal/core/util/Utils.d.ts +69 -3
- package/.internal/core/util/Utils.d.ts.map +1 -1
- package/.internal/core/util/Utils.js +72 -18
- package/.internal/core/util/Utils.js.map +1 -1
- package/.internal/plugins/json/Classes-script.d.ts +6 -0
- package/.internal/plugins/json/Classes-script.d.ts.map +1 -1
- package/.internal/plugins/json/Classes-script.js +3 -0
- package/.internal/plugins/json/Classes-script.js.map +1 -1
- package/.internal/plugins/json/Classes.d.ts +6 -0
- package/.internal/plugins/json/Classes.d.ts.map +1 -1
- package/.internal/plugins/json/Classes.js +3 -0
- package/.internal/plugins/json/Classes.js.map +1 -1
- package/CHANGELOG.md +17 -8
- package/examples/javascript/flow-arc-horizontal/package.json +1 -1
- package/examples/javascript/flow-arc-vertical/package.json +1 -1
- package/examples/javascript/flow-chord/package.json +1 -1
- package/examples/javascript/flow-chord-directed/package.json +1 -1
- package/examples/javascript/flow-chord-non-ribbon/package.json +1 -1
- package/examples/javascript/flow-sankey/package.json +1 -1
- package/examples/javascript/gantt/package.json +1 -1
- package/examples/javascript/gantt-multilevel/package.json +1 -1
- package/examples/javascript/gantt-simple/package.json +1 -1
- package/examples/javascript/gauge/package.json +1 -1
- package/examples/javascript/gauge-bands/package.json +1 -1
- package/examples/javascript/hierarchy-force-directed/package.json +1 -1
- package/examples/javascript/hierarchy-pack/package.json +1 -1
- package/examples/javascript/hierarchy-partition/package.json +1 -1
- package/examples/javascript/hierarchy-sunburst/package.json +1 -1
- package/examples/javascript/hierarchy-tree/package.json +1 -1
- package/examples/javascript/hierarchy-treemap/package.json +1 -1
- package/examples/javascript/hierarchy-voronoi-treemap/package.json +1 -1
- package/examples/javascript/jest/package.json +1 -1
- package/examples/javascript/json-pie/package.json +1 -1
- package/examples/javascript/json-xy/package.json +1 -1
- package/examples/javascript/map-animating-along-lines/package.json +1 -1
- package/examples/javascript/map-clustered-points/package.json +1 -1
- package/examples/javascript/map-day-and-night/package.json +1 -1
- package/examples/javascript/map-globe-rotate-to-country/package.json +1 -1
- package/examples/javascript/map-globe-with-projected-circles/package.json +1 -1
- package/examples/javascript/map-sankey/README.md +6 -0
- package/examples/javascript/map-sankey/index.css +11 -0
- package/examples/javascript/map-sankey/index.html +13 -0
- package/examples/javascript/map-sankey/index.js +368 -0
- package/examples/javascript/map-sankey/package.json +17 -0
- package/examples/javascript/map-sankey/webpack.config.js +38 -0
- package/examples/javascript/map-sankey-waypoints/README.md +6 -0
- package/examples/javascript/map-sankey-waypoints/index.css +11 -0
- package/examples/javascript/map-sankey-waypoints/index.html +13 -0
- package/examples/javascript/map-sankey-waypoints/index.js +394 -0
- package/examples/javascript/map-sankey-waypoints/package.json +17 -0
- package/examples/javascript/map-sankey-waypoints/webpack.config.js +38 -0
- package/examples/javascript/map-with-bubbles/package.json +1 -1
- package/examples/javascript/map-zoom-to-country/package.json +1 -1
- package/examples/javascript/misc-40-charts/package.json +1 -1
- package/examples/javascript/misc-microchart-grid/package.json +1 -1
- package/examples/javascript/pie-chart/package.json +1 -1
- package/examples/javascript/pie-donut-chart/package.json +1 -1
- package/examples/javascript/pie-variable-radius/package.json +1 -1
- package/examples/javascript/radar-column-iwatch-style/package.json +1 -1
- package/examples/javascript/radar-heat-map/package.json +1 -1
- package/examples/javascript/radar-line/package.json +1 -1
- package/examples/javascript/radar-time-line/package.json +1 -1
- package/examples/javascript/sliced-funnel/package.json +1 -1
- package/examples/javascript/sliced-pictorial-stacked/package.json +1 -1
- package/examples/javascript/sliced-pyramid/package.json +1 -1
- package/examples/javascript/stock-chart/package.json +1 -1
- package/examples/javascript/stock-chart-comparing-stocks/package.json +1 -1
- package/examples/javascript/stock-chart-data-granularity/package.json +1 -1
- package/examples/javascript/stock-chart-data-grouping/package.json +1 -1
- package/examples/javascript/stock-chart-intraday/package.json +1 -1
- package/examples/javascript/stock-chart-live/package.json +1 -1
- package/examples/javascript/stock-chart-volume-separate-panel/package.json +1 -1
- package/examples/javascript/timeline-horizontal-serpentine-chart/package.json +1 -1
- package/examples/javascript/timeline-linear-process-diagram/package.json +1 -1
- package/examples/javascript/timeline-serpentine-chart/package.json +1 -1
- package/examples/javascript/timeline-spiral-chart/package.json +1 -1
- package/examples/javascript/venn-diagram/package.json +1 -1
- package/examples/javascript/wordcloud-with-data/package.json +1 -1
- package/examples/javascript/wordcloud-with-text/package.json +1 -1
- package/examples/javascript/xy-100-percent-stacked-column/package.json +1 -1
- package/examples/javascript/xy-animated-bullet-at-the-end-of-the-series/package.json +1 -1
- package/examples/javascript/xy-bubble/package.json +1 -1
- package/examples/javascript/xy-candlestick/package.json +1 -1
- package/examples/javascript/xy-clustered-column/package.json +1 -1
- package/examples/javascript/xy-column/package.json +1 -1
- package/examples/javascript/xy-comparing-series-google-analytics-style/package.json +1 -1
- package/examples/javascript/xy-data-grouping/package.json +1 -1
- package/examples/javascript/xy-draggable-range/package.json +1 -1
- package/examples/javascript/xy-drawing-series-with-mouse-or-touch/package.json +1 -1
- package/examples/javascript/xy-dumbbell plot/package.json +1 -1
- package/examples/javascript/xy-evenly-spaced-date-axis/package.json +1 -1
- package/examples/javascript/xy-line/package.json +1 -1
- package/examples/javascript/xy-line-highlight-on-legend-hover/package.json +1 -1
- package/examples/javascript/xy-live-data/package.json +1 -1
- package/examples/javascript/xy-multiple-synced-value-axes/package.json +1 -1
- package/examples/javascript/xy-ohlc/package.json +1 -1
- package/examples/javascript/xy-real-time-data-sorting/package.json +1 -1
- package/examples/javascript/xy-smoothed-line/package.json +1 -1
- package/examples/javascript/xy-stacked-and-clustered-column/package.json +1 -1
- package/examples/javascript/xy-stacked-column/package.json +1 -1
- package/examples/javascript/xy-stacked-step/package.json +1 -1
- package/examples/javascript/xy-stock/package.json +1 -1
- package/examples/javascript/xy-stock-comparing/package.json +1 -1
- package/examples/typescript/flow-arc-horizontal/package.json +1 -1
- package/examples/typescript/flow-arc-vertical/package.json +1 -1
- package/examples/typescript/flow-chord/package.json +1 -1
- package/examples/typescript/flow-chord-directed/package.json +1 -1
- package/examples/typescript/flow-chord-non-ribbon/package.json +1 -1
- package/examples/typescript/flow-sankey/package.json +1 -1
- package/examples/typescript/gantt/package.json +1 -1
- package/examples/typescript/gantt-multilevel/package.json +1 -1
- package/examples/typescript/gantt-simple/package.json +1 -1
- package/examples/typescript/gauge/package.json +1 -1
- package/examples/typescript/gauge-bands/package.json +1 -1
- package/examples/typescript/hierarchy-force-directed/package.json +1 -1
- package/examples/typescript/hierarchy-pack/package.json +1 -1
- package/examples/typescript/hierarchy-partition/package.json +1 -1
- package/examples/typescript/hierarchy-sunburst/package.json +1 -1
- package/examples/typescript/hierarchy-tree/package.json +1 -1
- package/examples/typescript/hierarchy-treemap/package.json +1 -1
- package/examples/typescript/hierarchy-voronoi-treemap/package.json +1 -1
- package/examples/typescript/jest/package.json +1 -1
- package/examples/typescript/json-pie/package.json +1 -1
- package/examples/typescript/json-xy/package.json +1 -1
- package/examples/typescript/map-animating-along-lines/package.json +1 -1
- package/examples/typescript/map-clustered-points/package.json +1 -1
- package/examples/typescript/map-day-and-night/package.json +1 -1
- package/examples/typescript/map-globe-rotate-to-country/package.json +1 -1
- package/examples/typescript/map-globe-with-projected-circles/package.json +1 -1
- package/examples/typescript/map-sankey/README.md +6 -0
- package/examples/typescript/map-sankey/index.css +11 -0
- package/examples/typescript/map-sankey/index.html +13 -0
- package/examples/typescript/map-sankey/index.ts +368 -0
- package/examples/typescript/map-sankey/package.json +19 -0
- package/examples/typescript/map-sankey/tsconfig.json +12 -0
- package/examples/typescript/map-sankey/webpack.config.js +45 -0
- package/examples/typescript/map-sankey-waypoints/README.md +6 -0
- package/examples/typescript/map-sankey-waypoints/index.css +11 -0
- package/examples/typescript/map-sankey-waypoints/index.html +13 -0
- package/examples/typescript/map-sankey-waypoints/index.ts +394 -0
- package/examples/typescript/map-sankey-waypoints/package.json +19 -0
- package/examples/typescript/map-sankey-waypoints/tsconfig.json +12 -0
- package/examples/typescript/map-sankey-waypoints/webpack.config.js +45 -0
- package/examples/typescript/map-with-bubbles/package.json +1 -1
- package/examples/typescript/map-zoom-to-country/package.json +1 -1
- package/examples/typescript/misc-40-charts/package.json +1 -1
- package/examples/typescript/misc-microchart-grid/package.json +1 -1
- package/examples/typescript/pie-chart/package.json +1 -1
- package/examples/typescript/pie-donut-chart/package.json +1 -1
- package/examples/typescript/pie-variable-radius/package.json +1 -1
- package/examples/typescript/radar-column-iwatch-style/package.json +1 -1
- package/examples/typescript/radar-heat-map/package.json +1 -1
- package/examples/typescript/radar-line/package.json +1 -1
- package/examples/typescript/radar-time-line/package.json +1 -1
- package/examples/typescript/sliced-funnel/package.json +1 -1
- package/examples/typescript/sliced-pictorial-stacked/package.json +1 -1
- package/examples/typescript/sliced-pyramid/package.json +1 -1
- package/examples/typescript/stock-chart/package.json +1 -1
- package/examples/typescript/stock-chart-comparing-stocks/package.json +1 -1
- package/examples/typescript/stock-chart-data-granularity/package.json +1 -1
- package/examples/typescript/stock-chart-data-grouping/package.json +1 -1
- package/examples/typescript/stock-chart-intraday/package.json +1 -1
- package/examples/typescript/stock-chart-live/package.json +1 -1
- package/examples/typescript/stock-chart-volume-separate-panel/package.json +1 -1
- package/examples/typescript/timeline-horizontal-serpentine-chart/package.json +1 -1
- package/examples/typescript/timeline-linear-process-diagram/package.json +1 -1
- package/examples/typescript/timeline-serpentine-chart/package.json +1 -1
- package/examples/typescript/timeline-spiral-chart/package.json +1 -1
- package/examples/typescript/venn-diagram/package.json +1 -1
- package/examples/typescript/wordcloud-with-data/package.json +1 -1
- package/examples/typescript/wordcloud-with-text/package.json +1 -1
- package/examples/typescript/xy-100-percent-stacked-column/package.json +1 -1
- package/examples/typescript/xy-animated-bullet-at-the-end-of-the-series/package.json +1 -1
- package/examples/typescript/xy-bubble/package.json +1 -1
- package/examples/typescript/xy-candlestick/package.json +1 -1
- package/examples/typescript/xy-clustered-column/package.json +1 -1
- package/examples/typescript/xy-column/package.json +1 -1
- package/examples/typescript/xy-comparing-series-google-analytics-style/package.json +1 -1
- package/examples/typescript/xy-data-grouping/package.json +1 -1
- package/examples/typescript/xy-draggable-range/package.json +1 -1
- package/examples/typescript/xy-drawing-series-with-mouse-or-touch/package.json +1 -1
- package/examples/typescript/xy-dumbbell plot/package.json +1 -1
- package/examples/typescript/xy-evenly-spaced-date-axis/package.json +1 -1
- package/examples/typescript/xy-line/package.json +1 -1
- package/examples/typescript/xy-line-highlight-on-legend-hover/package.json +1 -1
- package/examples/typescript/xy-live-data/package.json +1 -1
- package/examples/typescript/xy-multiple-synced-value-axes/package.json +1 -1
- package/examples/typescript/xy-ohlc/package.json +1 -1
- package/examples/typescript/xy-real-time-data-sorting/package.json +1 -1
- package/examples/typescript/xy-smoothed-line/package.json +1 -1
- package/examples/typescript/xy-stacked-and-clustered-column/package.json +1 -1
- package/examples/typescript/xy-stacked-column/package.json +1 -1
- package/examples/typescript/xy-stacked-step/package.json +1 -1
- package/examples/typescript/xy-stock/package.json +1 -1
- package/examples/typescript/xy-stock-comparing/package.json +1 -1
- package/map.d.ts +2 -0
- package/map.d.ts.map +1 -1
- package/map.js +2 -0
- package/map.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import * as am5 from "@amcharts/amcharts5";
|
|
2
|
+
import * as am5map from "@amcharts/amcharts5/map";
|
|
3
|
+
import am5geodata_worldLow from "@amcharts/amcharts5-geodata/worldLow";
|
|
4
|
+
import am5themes_Animated from "@amcharts/amcharts5/themes/Animated";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
// Create root element
|
|
8
|
+
// https://www.amcharts.com/docs/v5/getting-started/#Root_element
|
|
9
|
+
const root = am5.Root.new("chartdiv");
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
// Set themes
|
|
13
|
+
// https://www.amcharts.com/docs/v5/concepts/themes/
|
|
14
|
+
const coffeeTheme = am5.Theme.new(root);
|
|
15
|
+
coffeeTheme.rule("InterfaceColors").setAll({
|
|
16
|
+
primaryButton: am5.color(0x8b5e3c),
|
|
17
|
+
primaryButtonHover: am5.color(0x5c3a1e),
|
|
18
|
+
primaryButtonDown: am5.color(0x3c1e0e),
|
|
19
|
+
primaryButtonActive: am5.color(0xc4956a),
|
|
20
|
+
primaryButtonText: am5.color(0xf5ece0),
|
|
21
|
+
secondaryButton: am5.color(0xe8d5b7),
|
|
22
|
+
secondaryButtonHover: am5.color(0xd4c4a8),
|
|
23
|
+
secondaryButtonDown: am5.color(0xc4956a),
|
|
24
|
+
secondaryButtonText: am5.color(0x3c1e0e),
|
|
25
|
+
background: am5.color(0xe8d5b7),
|
|
26
|
+
text: am5.color(0x3c1e0e)
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
root.setThemes([am5themes_Animated.new(root), coffeeTheme]);
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// Grainy paper background
|
|
33
|
+
root.container.set("background", am5.Rectangle.new(root, {
|
|
34
|
+
fill: am5.color(0xf0e6d6),
|
|
35
|
+
fillPattern: am5.GrainPattern.new(root, {
|
|
36
|
+
density: 0.4,
|
|
37
|
+
maxOpacity: 0.07,
|
|
38
|
+
colors: [am5.color(0x000000)]
|
|
39
|
+
})
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
// Coffee palette
|
|
44
|
+
const espresso = am5.color(0x3c1e0e);
|
|
45
|
+
const darkRoast = am5.color(0x5c3a1e);
|
|
46
|
+
const mediumRoast = am5.color(0x8b5e3c);
|
|
47
|
+
const lightRoast = am5.color(0xc4956a);
|
|
48
|
+
const crema = am5.color(0xe8d5b7);
|
|
49
|
+
const cream = am5.color(0xf5ece0);
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// Create the map chart
|
|
53
|
+
// https://www.amcharts.com/docs/v5/charts/map-chart/
|
|
54
|
+
const chart = root.container.children.push(am5map.MapChart.new(root, {
|
|
55
|
+
panX: "rotateX",
|
|
56
|
+
panY: "rotateY",
|
|
57
|
+
projection: am5map.geoOrthographic(),
|
|
58
|
+
rotationX: -15,
|
|
59
|
+
rotationY: -20,
|
|
60
|
+
minZoomLevel: 0.5,
|
|
61
|
+
zoomLevel: 0.9
|
|
62
|
+
}));
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
// Create series for background fill
|
|
66
|
+
// https://www.amcharts.com/docs/v5/charts/map-chart/map-polygon-series/#Background_polygon
|
|
67
|
+
const bgSeries = chart.series.push(am5map.MapPolygonSeries.new(root, {}));
|
|
68
|
+
bgSeries.mapPolygons.template.setAll({
|
|
69
|
+
fill: am5.color(0xede4d4),
|
|
70
|
+
fillOpacity: 1,
|
|
71
|
+
strokeOpacity: 0
|
|
72
|
+
});
|
|
73
|
+
bgSeries.data.push({ geometry: am5map.getGeoRectangle(90, 180, -90, -180) });
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
// Create graticule series
|
|
77
|
+
// https://www.amcharts.com/docs/v5/charts/map-chart/graticule-series/
|
|
78
|
+
const graticuleSeries = chart.series.push(am5map.GraticuleSeries.new(root, {}));
|
|
79
|
+
graticuleSeries.mapLines.template.setAll({
|
|
80
|
+
stroke: mediumRoast,
|
|
81
|
+
strokeOpacity: 0.15,
|
|
82
|
+
strokeWidth: 0.5
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
// Create main polygon series for countries
|
|
87
|
+
// https://www.amcharts.com/docs/v5/charts/map-chart/map-polygon-series/
|
|
88
|
+
const polygonSeries = chart.series.push(am5map.MapPolygonSeries.new(root, {
|
|
89
|
+
geoJSON: am5geodata_worldLow
|
|
90
|
+
}));
|
|
91
|
+
polygonSeries.mapPolygons.template.setAll({
|
|
92
|
+
fill: cream,
|
|
93
|
+
stroke: lightRoast,
|
|
94
|
+
strokeWidth: 0.5,
|
|
95
|
+
strokeOpacity: 0.5
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Highlight producer, hub, and consumer countries
|
|
99
|
+
const producerIds = ["BR", "VN", "CO", "ET", "ID", "HN"];
|
|
100
|
+
const hubIds = ["DE", "BE", "IT", "US"];
|
|
101
|
+
const consumerIds = ["FR", "PL", "SE", "RU", "GB", "NL", "GR", "AT", "CA", "JP"];
|
|
102
|
+
|
|
103
|
+
polygonSeries.events.on("datavalidated", () => {
|
|
104
|
+
am5.array.each(polygonSeries.dataItems, (di) => {
|
|
105
|
+
const id = di.get("id");
|
|
106
|
+
if (id && producerIds.includes(id)) {
|
|
107
|
+
di.get("mapPolygon").setAll({ fill: am5.color(0x8fae7e) });
|
|
108
|
+
} else if (id && hubIds.includes(id)) {
|
|
109
|
+
di.get("mapPolygon").setAll({ fill: am5.color(0xc4a878) });
|
|
110
|
+
} else if (id && consumerIds.includes(id)) {
|
|
111
|
+
di.get("mapPolygon").setAll({ fill: am5.color(0xddc8a0) });
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
// Create Map Sankey series
|
|
118
|
+
// https://www.amcharts.com/docs/v5/charts/map-chart/map-sankey-series/
|
|
119
|
+
const sankeySeries = chart.series.push(am5map.MapSankeySeries.new(root, {
|
|
120
|
+
polygonSeries: polygonSeries,
|
|
121
|
+
maxWidth: 2,
|
|
122
|
+
controlPointDistance: 0.4,
|
|
123
|
+
resolution: 60,
|
|
124
|
+
nodePadding: 0.3
|
|
125
|
+
}));
|
|
126
|
+
|
|
127
|
+
sankeySeries.mapPolygons.template.setAll({
|
|
128
|
+
fill: mediumRoast,
|
|
129
|
+
fillOpacity: 0.65,
|
|
130
|
+
strokeOpacity: 0,
|
|
131
|
+
tooltipText: "{sourceNode.name} > {targetNode.name}\n{value}k tonnes"
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
sankeySeries.nodes.mapPolygons.template.setAll({
|
|
135
|
+
fill: espresso,
|
|
136
|
+
stroke: crema,
|
|
137
|
+
strokeWidth: 1.5,
|
|
138
|
+
fillOpacity: 0.95,
|
|
139
|
+
strokeOpacity: 1,
|
|
140
|
+
tooltipText: "{name}\n{sum}k tonnes"
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
// Add animated coffee bean bullets
|
|
145
|
+
sankeySeries.bullets.push(() => {
|
|
146
|
+
return am5.Bullet.new(root, {
|
|
147
|
+
locationX: 0,
|
|
148
|
+
autoRotate: true,
|
|
149
|
+
sprite: am5.Graphics.new(root, {
|
|
150
|
+
svgPath: "M-4,-2.5 C-4,-5 -1.5,-6.5 1,-6.5 C3.5,-6.5 5,-4.5 5,-2 C5,1 3,3.5 0.5,5 C-0.5,5.7 -1.5,5.7 -2.5,5 C-5,3.5 -6,1 -4,-2.5 Z M-1,-5 C-1,-1 -1,2 -0.5,4.5",
|
|
151
|
+
fill: espresso,
|
|
152
|
+
stroke: darkRoast,
|
|
153
|
+
strokeWidth: 0.5,
|
|
154
|
+
centerX: am5.p50,
|
|
155
|
+
centerY: am5.p50,
|
|
156
|
+
scale: 0.35,
|
|
157
|
+
visible: false
|
|
158
|
+
})
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Set data after polygonSeries loads (sourceId/targetId need centroid lookup)
|
|
163
|
+
// Producers > Processing Hubs > Consumer Markets
|
|
164
|
+
polygonSeries.events.once("datavalidated", () => {
|
|
165
|
+
sankeySeries.data.setAll([
|
|
166
|
+
// Producers > Hubs
|
|
167
|
+
{ sourceId: "BR", targetId: "DE", value: 350 },
|
|
168
|
+
{ sourceId: "BR", targetId: "US", value: 450 },
|
|
169
|
+
{ sourceId: "BR", targetId: "IT", value: 200 },
|
|
170
|
+
{ sourceId: "VN", targetId: "DE", value: 200 },
|
|
171
|
+
{ sourceId: "VN", targetId: "BE", value: 150 },
|
|
172
|
+
{ sourceId: "CO", targetId: "US", value: 250 },
|
|
173
|
+
{ sourceId: "CO", targetId: "DE", value: 80 },
|
|
174
|
+
{ sourceId: "ET", targetId: "DE", value: 60 },
|
|
175
|
+
{ sourceId: "ET", targetId: "BE", value: 40 },
|
|
176
|
+
{ sourceId: "ID", targetId: "US", value: 80 },
|
|
177
|
+
{ sourceId: "HN", targetId: "DE", value: 60 },
|
|
178
|
+
{ sourceId: "HN", targetId: "BE", value: 40 },
|
|
179
|
+
|
|
180
|
+
// Hubs > Consumer Markets
|
|
181
|
+
{ sourceId: "DE", targetId: "FR", value: 150 },
|
|
182
|
+
{ sourceId: "DE", targetId: "PL", value: 100 },
|
|
183
|
+
{ sourceId: "DE", targetId: "SE", value: 80 },
|
|
184
|
+
{ sourceId: "DE", targetId: "RU", value: 120 },
|
|
185
|
+
{ sourceId: "BE", targetId: "GB", value: 100 },
|
|
186
|
+
{ sourceId: "BE", targetId: "NL", value: 80 },
|
|
187
|
+
{ sourceId: "IT", targetId: "GR", value: 50 },
|
|
188
|
+
{ sourceId: "IT", targetId: "AT", value: 40 },
|
|
189
|
+
{ sourceId: "US", targetId: "CA", value: 120 },
|
|
190
|
+
{ sourceId: "US", targetId: "JP", value: 80 }
|
|
191
|
+
]);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
// Set country names on auto-created nodes and animate bullets
|
|
196
|
+
const countryNames = {
|
|
197
|
+
BR: "Brazil", VN: "Vietnam", CO: "Colombia", ET: "Ethiopia",
|
|
198
|
+
ID: "Indonesia", HN: "Honduras", DE: "Germany", BE: "Belgium",
|
|
199
|
+
IT: "Italy", US: "United States", FR: "France", PL: "Poland",
|
|
200
|
+
SE: "Sweden", RU: "Russia", GB: "United Kingdom", NL: "Netherlands",
|
|
201
|
+
GR: "Greece", AT: "Austria", CA: "Canada", JP: "Japan"
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
sankeySeries.events.on("datavalidated", () => {
|
|
205
|
+
am5.array.each(sankeySeries.nodes.dataItems, (di) => {
|
|
206
|
+
const id = di.get("id");
|
|
207
|
+
if (id && countryNames[id]) {
|
|
208
|
+
di.set("name", countryNames[id]);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// Defer bullet animation to next frame — bullets are not yet
|
|
213
|
+
// instantiated when datavalidated fires inside polygonSeries handler
|
|
214
|
+
setTimeout(() => {
|
|
215
|
+
am5.array.each(sankeySeries.dataItems, (dataItem) => {
|
|
216
|
+
const bullets = dataItem.bullets;
|
|
217
|
+
if (bullets) {
|
|
218
|
+
am5.array.each(bullets, (bullet) => {
|
|
219
|
+
var randomDur = 3000 + Math.random() * 3000;
|
|
220
|
+
var delay = Math.random() * randomDur;
|
|
221
|
+
setTimeout(() => {
|
|
222
|
+
const sprite = bullet.get("sprite");
|
|
223
|
+
if (sprite) sprite.set("visible", true);
|
|
224
|
+
bullet.animate({
|
|
225
|
+
key: "locationX",
|
|
226
|
+
from: 0,
|
|
227
|
+
to: 1,
|
|
228
|
+
duration: randomDur,
|
|
229
|
+
easing: am5.ease.linear,
|
|
230
|
+
loops: Infinity
|
|
231
|
+
});
|
|
232
|
+
}, delay);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}, 100);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
// Add title and subtitle
|
|
241
|
+
const titleCont = chart.children.push(am5.Container.new(root, {
|
|
242
|
+
layout: root.verticalLayout,
|
|
243
|
+
x: am5.p50,
|
|
244
|
+
centerX: am5.p50,
|
|
245
|
+
y: am5.p100,
|
|
246
|
+
centerY: am5.p100,
|
|
247
|
+
position: "absolute",
|
|
248
|
+
paddingBottom: 16
|
|
249
|
+
}));
|
|
250
|
+
|
|
251
|
+
titleCont.children.push(am5.Label.new(root, {
|
|
252
|
+
text: "Global Coffee Supply Chain",
|
|
253
|
+
fontSize: 18,
|
|
254
|
+
fontWeight: "600",
|
|
255
|
+
fill: espresso,
|
|
256
|
+
x: am5.p50,
|
|
257
|
+
centerX: am5.p50
|
|
258
|
+
}));
|
|
259
|
+
|
|
260
|
+
titleCont.children.push(am5.Label.new(root, {
|
|
261
|
+
text: "(Thousands of tonnes)",
|
|
262
|
+
fontSize: 11,
|
|
263
|
+
fill: mediumRoast,
|
|
264
|
+
x: am5.p50,
|
|
265
|
+
centerX: am5.p50
|
|
266
|
+
}));
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
// Add Globe / Map projection toggle
|
|
270
|
+
const switchCont = chart.children.push(am5.Container.new(root, {
|
|
271
|
+
layout: root.horizontalLayout,
|
|
272
|
+
x: 20,
|
|
273
|
+
y: 40
|
|
274
|
+
}));
|
|
275
|
+
|
|
276
|
+
switchCont.children.push(am5.Label.new(root, {
|
|
277
|
+
centerY: am5.p50,
|
|
278
|
+
text: "Globe",
|
|
279
|
+
fill: espresso,
|
|
280
|
+
fontSize: 13
|
|
281
|
+
}));
|
|
282
|
+
|
|
283
|
+
const switchButton = switchCont.children.push(am5.Button.new(root, {
|
|
284
|
+
themeTags: ["switch"],
|
|
285
|
+
centerY: am5.p50,
|
|
286
|
+
icon: am5.Circle.new(root, {
|
|
287
|
+
themeTags: ["icon"]
|
|
288
|
+
})
|
|
289
|
+
}));
|
|
290
|
+
|
|
291
|
+
const easing = am5.ease.inOut(am5.ease.cubic);
|
|
292
|
+
const duration = 1500;
|
|
293
|
+
const fadeDuration = 300;
|
|
294
|
+
|
|
295
|
+
function zoomToGlobe() {
|
|
296
|
+
chart.set("projection", am5map.geoOrthographic());
|
|
297
|
+
chart.set("panX", "rotateX");
|
|
298
|
+
chart.set("panY", "rotateY");
|
|
299
|
+
chart.animate({ key: "rotationX", to: -15, duration, easing });
|
|
300
|
+
chart.animate({ key: "rotationY", to: -20, duration, easing });
|
|
301
|
+
bgSeries.mapPolygons.template.set("fillOpacity", 1);
|
|
302
|
+
chart.set("minZoomLevel", 0.9);
|
|
303
|
+
chart.animate({ key: "zoomLevel", to: 0.9, duration, easing });
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function zoomToMap() {
|
|
307
|
+
chart.set("projection", am5map.geoMercator());
|
|
308
|
+
chart.set("panX", "translateX");
|
|
309
|
+
chart.set("panY", "translateY");
|
|
310
|
+
chart.animate({ key: "rotationX", to: 0, duration, easing });
|
|
311
|
+
chart.animate({ key: "rotationY", to: 0, duration, easing });
|
|
312
|
+
bgSeries.mapPolygons.template.set("fillOpacity", 0);
|
|
313
|
+
chart.set("minZoomLevel", 1);
|
|
314
|
+
chart.animate({ key: "zoomLevel", to: 1.7, duration, easing });
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
switchButton.on("active", () => {
|
|
318
|
+
chart.goHome(duration);
|
|
319
|
+
// Fade out before projection switch
|
|
320
|
+
setTimeout(() => {
|
|
321
|
+
chart.seriesContainer.animate({ key: "opacity", to: 0, duration: fadeDuration });
|
|
322
|
+
}, duration - fadeDuration);
|
|
323
|
+
setTimeout(() => {
|
|
324
|
+
if (switchButton.get("active")) {
|
|
325
|
+
zoomToMap();
|
|
326
|
+
} else {
|
|
327
|
+
zoomToGlobe();
|
|
328
|
+
}
|
|
329
|
+
// Fade in after projection switch
|
|
330
|
+
chart.seriesContainer.animate({ key: "opacity", to: 1, duration: fadeDuration });
|
|
331
|
+
}, duration);
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
switchCont.children.push(am5.Label.new(root, {
|
|
335
|
+
centerY: am5.p50,
|
|
336
|
+
text: "Map",
|
|
337
|
+
fill: espresso,
|
|
338
|
+
fontSize: 13
|
|
339
|
+
}));
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
// Add zoom controls
|
|
343
|
+
// https://www.amcharts.com/docs/v5/charts/map-chart/map-zoom/
|
|
344
|
+
const zoomControl = chart.set("zoomControl", am5map.ZoomControl.new(root, {}));
|
|
345
|
+
zoomControl.homeButton.set("visible", true);
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
// Auto-rotate globe until user interaction
|
|
349
|
+
let rotationAnimation = chart.animate({
|
|
350
|
+
key: "rotationX",
|
|
351
|
+
from: -15,
|
|
352
|
+
to: -15 + 360,
|
|
353
|
+
duration: 120000,
|
|
354
|
+
loops: Infinity,
|
|
355
|
+
easing: am5.ease.linear
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
chart.chartContainer.events.on("pointerdown", () => {
|
|
359
|
+
if (rotationAnimation) {
|
|
360
|
+
rotationAnimation.stop();
|
|
361
|
+
rotationAnimation = null;
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
// Make stuff animate on load
|
|
367
|
+
// https://www.amcharts.com/docs/v5/concepts/animations/#Initial_animation
|
|
368
|
+
chart.appear(1000, 100);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"private": true,
|
|
3
|
+
"name": "amcharts5-example-map-sankey",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"devDependencies": {
|
|
6
|
+
"@amcharts/amcharts5": "^5.17.0",
|
|
7
|
+
"@amcharts/amcharts5-geodata": "^5.1.5",
|
|
8
|
+
"source-map-loader": "^4.0.1",
|
|
9
|
+
"webpack": "^5.1.3",
|
|
10
|
+
"webpack-cli": "^5.1.1",
|
|
11
|
+
"webpack-dev-server": "^4.15.0"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "webpack",
|
|
15
|
+
"start": "webpack serve --mode development"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var $path = require("path");
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
mode: "production",
|
|
5
|
+
|
|
6
|
+
devtool: "source-map",
|
|
7
|
+
|
|
8
|
+
stats: "errors-warnings",
|
|
9
|
+
|
|
10
|
+
target: ["web", "es5"],
|
|
11
|
+
|
|
12
|
+
entry: {
|
|
13
|
+
index: "./index.js",
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
devServer: {
|
|
17
|
+
publicPath: "/dist/",
|
|
18
|
+
liveReload: true,
|
|
19
|
+
overlay: true,
|
|
20
|
+
noInfo: true,
|
|
21
|
+
open: true
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
output: {
|
|
25
|
+
path: $path.join(__dirname, "dist"),
|
|
26
|
+
publicPath: "dist/",
|
|
27
|
+
filename: "[name].js",
|
|
28
|
+
chunkFilename: "[name].js"
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
module: {
|
|
32
|
+
rules: [{
|
|
33
|
+
test: /.js$/,
|
|
34
|
+
use: ["source-map-loader"],
|
|
35
|
+
enforce: "pre"
|
|
36
|
+
}]
|
|
37
|
+
}
|
|
38
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
body {
|
|
2
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
|
3
|
+
padding: 0;
|
|
4
|
+
margin: 0;
|
|
5
|
+
background-color: #ffffff;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
#chartdiv {
|
|
9
|
+
width: 100%;
|
|
10
|
+
height: 80vh;
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<title>amCharts 5 Example - map-sankey-waypoints</title>
|
|
6
|
+
<link rel="stylesheet" href="index.css" />
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<style>body { margin: 0; padding: 0; background: #0a0e12; overflow: hidden; }</style>
|
|
10
|
+
<div id="chartdiv" style="width: 100%; height: 100vh; background: #0a0e12;"></div>
|
|
11
|
+
<script src="dist/index.js"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|