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
var formatterFunction = function () {
3
// Get statistic.
4
return 'Series Y sum: ' + this.series.getStat('seriesYSum') + '\n' +
5
'Series Y minimum: ' + this.series.getStat('seriesYMin') + '\n' +
6
'Series Y maximum: ' + this.series.getStat('seriesYMax');
7
};
8
9
var chart = anychart.column();
10
11
var series1 = chart.column([
12
{x: 1, value: 1},
13
{x: 2, value: 2},
14
{x: 3, value: 3},
15
{x: 4, value: 2},
16
{x: 5, value: 1},
17
{x: 6, value: 2},
18
{x: 7, value: 1}
19
]);
20
21
var series2 = chart.column([
22
{x: 1, value: 4},
23
{x: 2, value: 1},
24
{x: 3, value: 6},
25
{x: 4, value: 7},
26
{x: 5, value: 2},
27
{x: 6, value: 5},
28
{x: 7, value: 8}
29
]);
30
31
// Also, you can get statistic using string tokens.
32
// For example,
33
// firstTooltip.format('Series Y sum: {%seriesYSum}' + '\n'
34
// + 'Series Y minimum: {%seriesYMin}' + '\n'
35
// + 'Series Y maximum: {%seriesYMax}');
36
37
var tooltip1 = series1.tooltip();
38
tooltip1.format(formatterFunction);
39
40
var tooltip2 = series2.tooltip();
41
tooltip2.format(formatterFunction);
42
43
chart.title('Get the statistics and use the tooltip');
44
chart.container('container');
45
chart.draw();
46
});