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
var tooltipChart = null;
2
anychart.onDocumentReady(function () {
3
var data = anychart.data.set([
4
['2000', 10048, 2600, 3200, 2159, 2089],
5
['2001', 10938, 2367, 1989, 2383, 4199],
6
['2002', 9989, 2156, 2399, 2867, 2567],
7
['2003', 10226, 2398, 2225, 3010, 2593],
8
['2004', 11004, 2851, 3007, 2805, 2341],
9
['2005', 10934, 3400, 2105, 2563, 2866],
10
['2006', 11275, 2878, 2933, 3561, 1903],
11
['2007', 11945, 2959, 3855, 3109, 2022],
12
['2008', 12245, 4001, 2156, 3928, 2160],
13
['2009', 12056, 1995, 2057, 4902, 3102],
14
['2010', 11734, 2584, 3166, 3101, 2883],
15
['2011', 12337, 3106, 2845, 2933, 3453],
16
['2012', 12761, 3296, 2655, 3144, 3666],
17
['2013', 13390, 2611, 4194, 3206, 3379],
18
['2014', 13818, 3000, 2599, 4107, 4112],
19
['2015', 13188, 3199, 2564, 3118, 4307]
20
]);
21
22
var dataMapping = data.mapAs({x: 0, value: 1});
23
24
chart = anychart.column(dataMapping);
25
26
var tooltip = chart.tooltip();
27
tooltip.useHtml(true);
28
tooltip.separator(false);
29
30
tooltip.onDomReady(function() {
31
this.contentElement.style.width = '200px';
32
this.contentElement.style.height = '150px';
33
tooltipChart.container(this.contentElement);
34
tooltipChart.draw();
35
});
36
tooltip.onBeforeTitleChange(function() {
37
return true;
38
});
39
tooltip.onBeforeContentChange(function() {
40
return false;
41
});
42
43
// Get information about the changed title.
44
// Hover on the point to check title.
45
tooltip.onTitleChanged(function() {
46
chart.title('Tooltip title has been changed to "' + this.titleElement.innerText + '"');
47
});
48
49
chart.listen('pointMouseOver', function(e) {
50
var index = e.pointIndex;
51
var dataRow = data.row(index);
52
tooltipChart = tooltipChart || createChart();
53
tooltipChart.data([
54
{x: 'John', value: dataRow[2]},
55
{x: 'James', value: dataRow[3]},
56
{x: 'Peter', value: dataRow[4]},
57
{x: 'Mary', value: dataRow[5]}
58
]);
59
});
60
61
chart.container('container');
62
chart.draw();
63
});
64
65
function createChart() {
66
var chart = anychart.bar();
67
chart.title().fontSize(12);
68
chart.xAxis().stroke(null).ticks(false);
69
chart.xAxis().labels().fontSize(10);
70
chart.yAxis().labels().fontSize(10);
71
chart.padding([0, 12, 0, 0]);
72
return chart;
73
};