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
chart.xAxis().title("Retail Channel");
34
chart.yAxis().title("Sales");
35
36
// enable legend
37
chart.legend(true);
38
39
// enable the accessibility support for series
40
series2013.a11y(true);
41
series2014.a11y(true);
42
43
// set the titleFormat for the chart
44
chart.a11y().titleFormat(function(e){
45
var chart = this.chart;
46
return "Data Plot Y Sum is " + chart.getStat("dataPlotYSum") + "\n" +
47
"First Series Y minimum is " + chart.getSeries(0).getStat("seriesYMin") + "\n" +
48
"First Series Y maximum is " + chart.getSeries(0).getStat("seriesYMax");
49
});
50
51
// set the titleFormat for the series
52
series2014.a11y().titleFormat(function(e){
53
var series = this.series;
54
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");
55
});
56
57
// draw
58
chart.container("container");
59
chart.draw();
60
});