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
// data
4
var data = anychart.data.set([
5
["John", 10000, 12000],
6
["Jake", 12000, 15000],
7
["Peter", 18000, 16000],
8
["James", 11000, 13000],
9
["Mary", 9000, 19000]
10
]);
11
12
// map data for the each series
13
var Sales2013 = data.mapAs({x: [0], value: [1]});
14
var Sales2014 = data.mapAs({x: [0], value: [2]});
15
16
// chart type
17
var chart = anychart.column();
18
19
// set data
20
var series2013 = chart.column(Sales2013);
21
// set series name
22
series2013.name("Sales in 2013");
23
24
// set series data
25
var series2014 = chart.column(Sales2014);
26
// set series name
27
series2014.name("Sales in 2014");
28
29
// chart title
30
chart.title("Making chart and series titles accessible");
31
32
// set axes titles
33
var xAxis = chart.xAxis();
34
xAxis.title("Retail Channel");
35
var yAxis = chart.yAxis();
36
yAxis.title("Sales");
37
38
// enable legend
39
chart.legend(true);
40
41
// enable the accessibility support for series
42
series2013.a11y(true);
43
series2014.a11y(true);
44
45
// set the titleFormat for the chart
46
chart.a11y().titleFormat(function(e){
47
var chart = this.chart;
48
return "Data Plot Y Sum is " + chart.getStat("dataPlotYSum") + "\n" +
49
"First Series Y minimum is " + chart.getSeries(0).getStat("seriesYMin") + "\n" +
50
"First Series Y maximum is " + chart.getSeries(0).getStat("seriesYMax");
51
});
52
53
// set the titleFormat for the series
54
series2014.a11y().titleFormat(function(e){
55
var series = this.series;
56
return "This series named " + series.name() + " has its maximum value in $" + series.getStat("seriesYMax") + ", the average in $" + series.getStat("average") + " and minimum value in $" + series.getStat("seriesYMin");
57
});
58
59
// draw
60
chart.container("container");
61
chart.draw();
62
});