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 stage = anychart.graphics.create("container");
3
4
var dataSet = anychart.data.set([
5
["John", 10000, 13000, 15000],
6
["Jake", 12000, 10000, 18000],
7
["Peter", 18000, 19000, 16000],
8
["James", 11000, 10000, 14000],
9
["Mary", 9000, 16000, 19000]
10
]);
11
12
var data1 = dataSet.mapAs({x: 0, value: 1});
13
var data2 = dataSet.mapAs({x: 0, value: 2});
14
var data3 = dataSet.mapAs({x: 0, value: 3});
15
16
// chart type
17
var chart = anychart.bar();
18
series1 = chart.bar(data1);
19
series1.name("Year 2008");
20
series2 = chart.bar(data2);
21
series2.name("Year 2010");
22
series3 = chart.bar(data3);
23
series3.name("Year 2012");
24
25
// set title
26
chart.title("Tooltips of one of the series can leave the chart bounds");
27
28
// set the padding for the chart
29
chart.bounds(10, 20, "90%", "70%");
30
chart.background("green 0.1");
31
32
// let tooltips to leave the chart bounds
33
series1.tooltip().allowLeaveChart(true);
34
series2.tooltip().allowLeaveChart(false);
35
36
series1.tooltip().format("This tooltip can be demonstrated out of the chart, if this becomes necessary to show it all");
37
series2.tooltip().format("This tooltip is not able to be demonstrated out of the chart");
38
39
// font settings for tooltip text
40
var tooltip1 = series1.tooltip();
41
tooltip1.fontWeight(900);
42
var title1 = series1.tooltip().title();
43
title1.fontWeight(900);
44
45
// adjust chart tooltips for the third series
46
chart.tooltip().format("This series tooltips' settings are inherited from chart tooltip defaults");
47
48
// draw
49
chart.container(stage);
50
chart.draw();
51
52
// limit the stage parameters for better illustration
53
document.getElementById("container").style.width="85%";
54
document.getElementById("container").style.background="#F0FFF0";
55
});