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
// set stage
4
var stage = anychart.graphics.create("container");
5
6
// set data
7
var data_1 = anychart.data.set([
8
["Green", 10000, 30],
9
["Red", 15000, 80],
10
["Herbal", 16000, 50],
11
["Black", 19000, 35],
12
["Berry", 9000, 49]
13
]);
14
15
// set data
16
var seriesData_1 = data_1.mapAs({x: 0, value: 1});
17
var seriesData_2 = data_1.mapAs({x: 0, value: 2});
18
19
var data = [
20
{id: 'AU.WA', value: 86},
21
{id: 'AU.NT', value: 64}
22
];
23
24
var map = anychart.map();
25
map.geoData(anychart.maps.australia);
26
map.choropleth(data);
27
28
// Get selected state.
29
var state = map.selected();
30
31
state.labels({enabled: true, fontColor: 'white'});
32
33
map.getSeries(0).select([0]);
34
35
// chart size and position
36
map.bounds(0, 0, "60%", "100%");
37
38
// draw
39
map.container(stage);
40
map.draw();
41
42
//chart 2
43
44
// set data
45
var data_WA = [
46
["Chocolate", 30120],
47
["Cookies", 5054],
48
["Marshmallows", 10220],
49
["Sweets", 5340],
50
["Macaroons", 13421]
51
];
52
53
var data_NT = [
54
["Chocolate", 3120],
55
["Cookies", 5054],
56
["Marshmallows", 10220],
57
["Sweets", 2340],
58
["Macaroons", 3421]
59
];
60
61
// set event type
62
map.listen("pointClick", function (e) {
63
if (e.iterator.get('id') == 'AU.WA') {
64
var chart_2 = anychart.pie(data_WA);
65
}
66
else if (e.iterator.get('id') == 'AU.NT') {
67
var chart_2 = anychart.pie(data_NT);
68
}
69
else {
70
}
71
});
72
73
var chart_2 = anychart.pie(data_WA);
74
75
var labels_2 = chart_2.labels();
76
labels_2.fontColor("White");
77
78
// chart size and position
79
chart_2.bounds("60%", 0, "35%", "100%");
80
81
// draw
82
chart_2.container(stage);
83
chart_2.draw();
84
85
});