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/Maps/Map_Projections
8
9
// create data set
10
var data = [
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 = [
22
{lat: -37.85, long: 144.79, name: "Melbourne", label:{position:"left", anchor:"right-bottom"}},
23
{lat: -33.79, long: 150.64, name: "Sydney", label:{position:"center-bottom", anchor:"left-top"}, 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: "center-top", anchor:"right-bottom"}},
25
{lat: -27.98, long: 153.04, name: "Gold Coast", label:{position:"right", anchor:"left-bottom"}},
26
{lat: -34.98, long: 138.42, name: "Adelaide", label:{position:"left-bottom", anchor:"right-top"}},
27
{lat: -31.93, long: 115.96, name: "Perth", label:{position:"center-top", anchor:"right-bottom"}},
28
{lat: -42.88, long: 147.31, name: "Hobart", label:{position:"center-bottom", anchor:"center-top"}}
29
];
30
31
32
// create map chart
33
var map = anychart.map();
34
35
// create connector series
36
var series_connector = map.connector(data);
37
38
// create marker series
39
var series_marker = map.marker(data_marker);
40
41
// set geodata
42
map.geoData(anychart.maps.australia);
43
44
// markers of connector series
45
series_connector.markers(false);
46
47
// tooltip formatter
48
series_connector.tooltip().format("From: {%from} \nTo: {%to} \nPassengers (in 2013): {%passengers}");
49
50
// set the start and end sizes
51
series_connector.startSize(15);
52
series_connector.endSize(0);
53
54
// connector series colors
55
series_connector.fill("#339999");
56
series_connector.stroke("#336666");
57
series_connector.hovered().fill("#669999");
58
series_connector.hovered().stroke("#336666");
59
series_connector.selected().fill("#006666");
60
series_connector.selected().stroke("#336666")
61
62
// adjust marker series tooltips
63
series_marker.tooltip().titleFormat("{%name}");
64
series_marker.labels().fontColor("#000");
65
66
series_marker.fill("#336666");
67
series_marker.hovered().fill("#336666");
68
series_marker.selected().fill("#336666");
69
series_marker.stroke("#336666");
70
series_marker.hovered().stroke("#336666");
71
series_marker.selected().stroke("#336666");
72
series_marker.size(5);
73
74
series_marker.zIndex(1000);
75
76
// name of the chart
77
map.title("10 most popular flights through Australia");
78
// set container id for the chart
79
map.container('container');
80
// initiate chart drawing
81
map.draw();
82
});