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
// the data for this sample is stored at
3
// https://cdn.anychart.com/samples/maps-connectors/trip-through-the-uk/data.js
4
// Creates map chart
5
var map = anychart.connector();
6
7
map.unboundRegions().enabled(true).fill('#E1E1E1').stroke('#D2D2D2');
8
9
// Sets settings for map chart
10
map.geoData('anychart.maps.united_kingdom');
11
map.interactivity().selectionMode('none');
12
13
// Sets title for map chart and customizes it
14
map
15
.title()
16
.enabled(true)
17
.useHtml(true)
18
.text(
19
'Journey Route: the United Kingdom Roundtrip<br/>' +
20
'<span style="color:#212121; font-size: 13px;">Example shows sample of usage a multistage connector.<br/>' +
21
'All data are fictitious.</span>'
22
);
23
24
// The data used in this sample can be obtained from the CDN
25
// https://cdn.anychart.com/samples/maps-connectors/trip-through-the-uk/data.js
26
createSeries(map, 'Rent a Car', getCarData(), '#64b5f6'); // eslint-disable-line no-undef
27
createSeries(map, 'Ferry', getShipData(), '#1976d2'); // eslint-disable-line no-undef
28
createSeries(map, 'Airplane', getAirData(), '#ef6c00'); // eslint-disable-line no-undef
29
30
// Turns on the legend for the sample
31
map.legend(true);
32
33
// The data used in this sample can be obtained from the CDN
34
// https://cdn.anychart.com/samples/maps-connectors/trip-through-the-uk/data.js
35
// Creates marker series for airport names
36
var citiesSeries = map
37
.marker(getCitiesData()) // eslint-disable-line no-undef
38
.type('circle')
39
.size(4)
40
.fill('#64b5f6')
41
.stroke('2 #E1E1E1')
42
.tooltip(false);
43
44
citiesSeries.hovered().size(4).fill('#64b5f6').stroke('2 #E1E1E1');
45
46
// Customizes labels for the airport names series
47
citiesSeries
48
.labels()
49
.enabled(true)
50
.position('center-bottom')
51
.fontColor('#263238')
52
.offsetY(0)
53
.offsetX(5)
54
.anchor('left-center')
55
.format('{%name}');
56
57
// exclude cities from the legend
58
citiesSeries.legendItem(false);
59
60
// create zoom controls
61
var zoomController = anychart.ui.zoom();
62
zoomController.render(map);
63
64
// Sets container id for the chart
65
map.container('container');
66
67
// Initiates chart drawing
68
map.draw();
69
});
70
71
// Helper function to create several series
72
function createSeries(map, name, data, color) {
73
// Creates connector series and customizes them
74
var connectorSeries = map
75
.connector(data)
76
.startSize(0)
77
.endSize(0)
78
.stroke('2 ' + color)
79
.name(name)
80
.curvature(0);
81
connectorSeries.legendItem({
82
iconType: 'circle',
83
fill: color,
84
iconStroke: '2 #E1E1E1'
85
});
86
connectorSeries.hovered().stroke('1.5 #212121');
87
88
// Customizes tooltips for the destination series
89
connectorSeries
90
.tooltip()
91
.padding([8, 13, 10, 13])
92
.fontSize(12)
93
.fontColor('#fff')
94
.format('{%full}')
95
.titleFormat(
96
'{%number}. <span style="font-size: 13px; color: #E1E1E1">{%short}</span>'
97
)
98
.title({ useHtml: true });
99
}