HTMLcopy
x
1
<script src="https://cdn.anychart.com/releases/8.10.0/js/anychart-core.min.js"></script>
2
<script src="https://cdn.anychart.com/releases/8.10.0/js/anychart-map.min.js"></script>
3
4
<script src="https://cdn.anychart.com/geodata/latest/custom/world/world.js"></script>
5
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.15/proj4.js"></script>
6
7
<script src="https://cdn.anychart.com/releases/8.10.0/js/anychart-data-adapter.min.js"></script>
8
9
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
60
1
anychart.onDocumentReady(function () {
2
anychart.data.loadJsonFile('https://gist.githubusercontent.com/shacheeswadia/a20ba5b62cef306ccc1a8e8857e5316a/raw/0337b16fa8dc4de97263bc0a4ededf935a529c35/migration-data.json', function (data) {
3
4
// сreate a connector map chart instance
5
var map = anychart.connector();
6
7
// include the world map geodata
8
map.geoData('anychart.maps.world');
9
10
// darken all regions
11
map
12
.unboundRegions()
13
.enabled(true)
14
.fill('#E1E1E1')
15
.stroke('#D2D2D2');
16
17
// set the map chart title
18
map
19
.title('Migrations to the USA from the top 15 countries');
20
21
// display all labels even if there is an overlap
22
map.
23
overlapMode("allow-overlap");
24
25
// a helper function to create the series
26
// that will form the connector lines
27
var createSeries = function (data) {
28
29
// create and customize the connector series
30
var connectorSeries = map
31
.connector(data);
32
33
connectorSeries
34
.markers()
35
.position('100%')
36
.size(10);
37
38
// set the labels for the source countries
39
connectorSeries
40
.labels()
41
.enabled(true)
42
.format(function () {
43
return this.getData('from');
44
});
45
46
};
47
48
// create a dataset from the data
49
var dataSet = anychart.data.set(data).mapAs();
50
51
createSeries(dataSet);
52
53
// set the container
54
map.container('container');
55
56
// draw the map
57
map.draw();
58
59
});
60
});