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
var chart = anychart.area();
4
5
chart.title("Limit the number of symbols in the Axes Labels");
6
7
chart.area([
8
["January" , 10000],
9
["February" , 12000],
10
["March" , 10000],
11
["April" , 11000],
12
["May" , 19000]
13
]);
14
15
var yScale = chart.yScale();
16
yScale.minimum(8000);
17
yScale.maximum(20000);
18
var yTicks = chart.yScale().ticks();
19
yTicks.interval(2000);
20
21
// set function to format the y-axis labels
22
var yLabels = chart.yAxis(0).labels();
23
yLabels.format("${%value}{groupsSeparator: }");
24
// set y axis title
25
var yAxis = chart.yAxis(0);
26
yAxis.title("Revenue in US Dollars");
27
28
// adjust additional axis
29
var yAxsi1 = chart.yAxis(1);
30
yAxsi1.orientation("right");
31
yAxsi1.title("Revenue in Euros");
32
33
// formats labels of additional axis
34
var yLabels1 = chart.yAxis(1).labels();
35
yLabels1.format(function() {
36
var value = this.value;
37
// scale USD to EUR
38
value = Math.round(value*0.7094716);
39
return "\u20ac" + value;
40
});
41
42
var xAxis = chart.xAxis();
43
xAxis.title("Month");
44
45
// limits length of the x-axis labels to 3 or less
46
chart.xAxis().labels().format(function() {
47
var value = this.value;
48
value = value.substr(0, 3);
49
return value
50
});
51
52
chart.container("container");
53
chart.draw();
54
});