HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function() {
2
3
// This sample uses 3rd party proj4 component
4
// that makes it possible to set coordinates
5
// for the points and labels on the map and
6
// required for custom projections and grid labels formatting.
7
// See https://docs.anychart.com/7.14.3/Maps/Map_Projections
8
9
// create data set
10
var data = anychart.data.set([
11
{points: [-37.85, 144.79, -33.79, 150.64], from: "Melbourne", to: "Sydney", passengers: "8 322 300"},
12
{points: [-27.40, 152.44, -37.85, 144.79], from: "Brisbane", to: "Melbourne", passengers: "3 317 100"},
13
{points: [-27.98, 153.04, -33.79, 150.64], from: "Gold Coast", to: "Sydney", passengers: "2 596 400", curvature: -0.5},
14
{points: [-37.85, 144.79, -31.93, 115.96], from: "Melbourne", to: "Perth", passengers: "2 160 700", curvature: -0.5},
15
{points: [-34.98, 138.42, -33.79, 150.64], from: "Adelaide", to: "Sydney", passengers: "1 813 000"},
16
{points: [-31.93, 115.96, -33.79, 150.64], from: "Perth", to: "Sydney", passengers: "1 798 900"},
17
{points: [-37.85, 144.79, -42.88, 147.31], from: "Melbourne", to: "Hobart", passengers: "1 400 200"}
18
]);
19
20
// create data set for the marker series
21
var data_marker = anychart.data.set([
22
{lat: -37.85, long: 144.79, name: "Melbourne", label:{position:"left", anchor:"rightBottom"}},
23
{lat: -33.79, long: 150.64, name: "Sydney", label:{position:"bottom", anchor:"lefttop"}, type:"star5", fill: "gold", stroke: "#CC9900", hoverFill: "gold", hoverStroke: "#CC9900", selectFill: "gold", selectStroke: "#CC9900"},
24
{lat: -27.40, long: 152.44, name: "Brisbane", label:{position: "top", anchor:"rightBottom"}},
25
{lat: -27.98, long: 153.04, name: "Gold Coast", label:{position:"right", anchor:"leftBottom"}},
26
{lat: -34.98, long: 138.42, name: "Adelaide", label:{position:"bottomLeft", anchor:"rightTop"}},
27
{lat: -31.93, long: 115.96, name: "Perth", label:{position:"top", anchor:"bottomRight"}},
28
{lat: -42.88, long: 147.31, name: "Hobart", label:{position:"bottom", anchor:"top"}}
29
]);
30
31
32
// create map chart
33
var map = anychart.map();
34
// create marker series
35
var series_marker = map.marker(data_marker);
36
// create connector series
37
var series_connector = map.connector(data);
38
39
// set geodata
40
map.geoData(anychart.maps.australia);
41
42
// markers of connector series
43
series_connector.markers(false);
44
45
// tooltip formatter
46
series_connector.tooltip().format("From: {%from} \nTo: {%to} \nPassengers (in 2013): {%passengers}");
47
48
// set the start and end sizes
49
series_connector.startSize(15);
50
series_connector.endSize(0);
51
52
// connector series colors
53
series_connector.fill("#339999");
54
series_connector.stroke("#336666");
55
series_connector.hoverFill("#669999");
56
series_connector.hoverStroke("#336666");
57
series_connector.selectFill("#006666");
58
series_connector.selectStroke("#336666")
59
60
// adjust marker series tooltips
61
series_marker.tooltip().titleFormat("{%name}");
62
series_marker.labels().fontColor("#000");
63
64
series_marker.fill("#336666");
65
series_marker.hoverFill("#336666");
66
series_marker.selectFill("#336666");
67
series_marker.stroke("#336666");
68
series_marker.hoverStroke("#336666");
69
series_marker.selectStroke("#336666");
70
series_marker.size(5);
71
72
series_marker.zIndex(1000);
73
74
// name of the chart
75
map.title("10 most popular flights through Australia");
76
// set container id for the chart
77
map.container('container');
78
// initiate chart drawing
79
map.draw();
80
});