HTMLcopy
1
<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
x
1
anychart.onDocumentReady(function () {
2
// Creates map chart
3
var map = anychart.connector();
4
5
// Sets settings for map chart
6
map.padding([10, 10, 10, 10]);
7
map.unboundRegions().enabled(true).fill('#E1E1E1').stroke('#D2D2D2');
8
9
map.geoData('anychart.maps.canada');
10
map.interactivity().selectionMode('none');
11
12
// Sets title for map chart and customizes it
13
map
14
.title()
15
.enabled(true)
16
.useHtml(true)
17
.padding([0, 0, 20, 0])
18
.text(
19
'Air Canada<br/>Popular Domestic Destinations<br/>' +
20
'<span style="color:#212121; font-size: 13px;">According to www.aircanada.com/en/flights/</span>'
21
);
22
23
// Sets credits data
24
map
25
.credits()
26
.enabled(true)
27
.url('https://www.aircanada.com/en/flights/')
28
.text('Data source: https://www.aircanada.com/en/flights/')
29
.logoSrc('https://www.aircanada.com/shared/images/flags/ca.png');
30
31
// The data used in this sample can be obtained from the CDN
32
// https://cdn.anychart.com/samples/maps-connectors/air-canada-popular-destinations/data.js
33
// Creates connector series for destinations and customizes them
34
var connectorSeries = map
35
.connector(getDestinationData()) // eslint-disable-line no-undef
36
.startSize(1.5)
37
.endSize(1.5)
38
.fill('#455a64')
39
.stroke(null)
40
.curvature(0.75);
41
42
connectorSeries.hovered().fill('#1976d2').stroke(null);
43
44
connectorSeries
45
.markers()
46
.position('70%')
47
.size(15)
48
.fill('#1976d2')
49
.stroke('#E1E1E1');
50
51
connectorSeries
52
.hovered()
53
.markers()
54
.position('70%')
55
.size(15)
56
.fill('#455a64')
57
.stroke('2 #455a64');
58
59
// Customizes tooltips for the destination series
60
connectorSeries.tooltip().title(false);
61
connectorSeries
62
.tooltip()
63
.useHtml(true)
64
.padding([8, 13, 10, 13])
65
.fontSize(13)
66
.format(function () {
67
return (
68
'<span style="font-size: 12px; color: #E1E1E1">From: </span>' +
69
this.getData('from') +
70
'<br/>' +
71
'<span style="font-size: 12px; color: #E1E1E1">To: </span>' +
72
this.getData('to')
73
);
74
});
75
76
// The data used in this sample can be obtained from the CDN
77
// https://cdn.anychart.com/samples/maps-connectors/air-canada-popular-destinations/data.js
78
// Creates marker series for airport names
79
var airportSeries = map
80
.marker(getAirportData()) // eslint-disable-line no-undef
81
.type('circle')
82
.size(5)
83
.fill('#1976d2')
84
.stroke('2 #E1E1E1')
85
.tooltip(false);
86
87
airportSeries.hovered().size(5).fill('#1976d2').stroke('2 #E1E1E1');
88
89
// Customizes labels for the airport names series
90
airportSeries
91
.labels()
92
.enabled(true)
93
.position('center-bottom')
94
.anchor('left-top')
95
.format(function () {
96
return this.getData('name');
97
});
98
99
// create zoom controls
100
var zoomController = anychart.ui.zoom();
101
zoomController.render(map);
102
103
// Sets container id for the chart
104
map.container('container');
105
106
// Initiates chart drawing
107
map.draw();
108
});