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
// create data
4
var data = [
5
["Strength", 8],
6
["Dexterity", 14],
7
["Concentration", 14],
8
["Intelligence", 15],
9
["Wisdom", 12],
10
["Charisma", 8]
11
];
12
13
// create a chart
14
var chart = anychart.polar();
15
16
// create a polyline series and set the data
17
var series = chart.polyline(data);
18
19
// set the type of the x-scale
20
chart.xScale("ordinal");
21
22
// enable sorting points by x
23
chart.sortPointsByX(true);
24
25
// set the chart title
26
chart.title("Axis Labels: Interlace Colors");
27
28
// set the container id and display chart
29
chart.container("container").draw();
30
31
// wait until chart display
32
chart.listen('chartDraw', function () {
33
// get the number of labels
34
var count = chart.xAxis().labels().getLabelsCount();
35
// loop through labels
36
for (var i = 0; i < count; i++) {
37
// choose color
38
var color = i % 2 ? '#CD4A2D' : '#4C4C4C';
39
// color the label
40
var label = chart.xAxis().labels().getLabel(i);
41
if (label) {
42
label.fontColor(color);
43
label.draw();
44
}
45
}
46
});
47
});