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
// create data set on our data
3
var dataSet = anychart.data.set([
4
['GDP', 1, 0.11982978723404256, 0.6180425531914894],
5
[
6
'GDP Real Growth Rate',
7
0.3666666666666667,
8
0.5583333333333333,
9
0.7583333333333333
10
],
11
[
12
'Infant Mortality',
13
0.06578947368421052,
14
0.15576923076923077,
15
0.24473684210526317
16
],
17
[
18
'Life Expectancy',
19
0.9576093653727663,
20
0.8268638324091188,
21
0.8905730129390017
22
],
23
['Population', 0.22638827767366515, 0.10979008847837246, 1],
24
['Area', 0.5390698290165805, 1, 0.5487479259581779],
25
[
26
'Density',
27
0.02995156531259858,
28
0.00783120233080335,
29
0.1299664111937944
30
],
31
[
32
'Population Growth Rate',
33
0.3087248322147651,
34
-0.12416107382550336,
35
0.19463087248322147
36
]
37
]);
38
39
// map data for the first series, take x from the zero column and value from the first column of data set
40
var data1 = dataSet.mapAs({ x: 0, value: 1 });
41
// map data for the second series, take x from the zero column and value from the second column of data set
42
var data2 = dataSet.mapAs({ x: 0, value: 2 });
43
// map data for the third series, take x from the zero column and value from the third column of data set
44
var data3 = dataSet.mapAs({ x: 0, value: 3 });
45
46
// create radar chart
47
var chart = anychart.radar();
48
49
// set chart title text settings
50
chart
51
.title('Comparison Chart')
52
// set chart legend
53
.legend(true);
54
55
// set chart padding settings
56
chart.padding().bottom(70);
57
58
// set chart yScale settings
59
chart.yScale().minimum(-0.2).maximum(1).ticks({ interval: 0.2 });
60
61
// create chart label with description
62
chart
63
.label()
64
.text(
65
'This chart compares countries by using specific indicators.\n' +
66
'For each indicator, the value 1 is assigned to the country that has the highest value.\n' +
67
'Other countries have their value computed as a proportion of the country with the highest value.'
68
)
69
.anchor('center-bottom')
70
.position('center-bottom')
71
.fontWeight('normal')
72
.fontSize(11)
73
.fontFamily('tahoma')
74
.fontColor('rgb(35,35,35)')
75
.offsetY(15);
76
77
// create first series with mapped data
78
chart.line(data1).name('USA').markers(true);
79
// create second series with mapped data
80
chart.line(data2).name('Russia').markers(true);
81
// create third series with mapped data
82
chart.line(data3).name('China').markers(true);
83
84
// set tooltip format
85
chart.tooltip().format('Value: {%Value}{decimalsCount: 2}');
86
87
// set container id for the chart
88
chart.container('container');
89
// initiate chart drawing
90
chart.draw();
91
});