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 dataSet = anychart.data.set([
5
{x: "Facebook", value: 103.42, yoy: 27},
6
{x: "Google Search", value: 75.98, yoy: 37},
7
{x: "Google Play", value: 73.67, yoy: 28},
8
{x: "YouTube", value: 71.96, yoy: 27},
9
{x: "Google Maps", value: 68.58, yoy: 14},
10
{x: "Gmail", value: 64.41, yoy: 29},
11
{x: "Instagram", value: 31.99, yoy: 66},
12
{x: "Maps (Apple)", value: 31.89, yoy: 64},
13
{x: "Stocks", value: 30.78, yoy: 32},
14
{x: "Twitter", value: 30.76, yoy: 36}
15
]);
16
17
// set chart type
18
var chart = anychart.column();
19
20
chart.title().enabled(true).useHtml(true).text("Hover over point to get information on <br> one of top 10 Smartphone<br> Applications of 2013").hAlign("center");
21
22
// disable x axis title
23
chart.xAxis().title().enabled(false);
24
25
// allow two lines in x axis labels
26
chart.xAxis().staggerMode(2);
27
28
// set data
29
var column = chart.column(dataSet);
30
31
var view = dataSet.mapAs();
32
33
// set listener on chart
34
column.listen(
35
36
// listener type
37
"pointmouseover",
38
39
// function, if listener triggers
40
function(e) {
41
// receive all necessary information and summarize it in one variable
42
var infoGetter = "Application Name:<b>" +
43
view.get(e.pointIndex, "x") +
44
"</b><br/><a style='color: red;'>Average</a> Unique Users: <b>" +
45
view.get(e.pointIndex, "value") +
46
"</b> millions<br/>Year Over Year: <b>" +
47
view.get(e.pointIndex, "yoy") + "%</b>" ;
48
49
// set received information into chart title
50
chart.title().text(infoGetter).fontWeight(300);
51
}
52
);
53
column.listen(
54
55
// listener type
56
"pointmouseout",
57
58
// function, if listener triggers
59
function () {
60
chart.title().fontWeight(900).text("Hover over point to get information on <br> one of top 10 Smartphone<br> Applications of 2013");
61
}
62
);
63
64
// set container and draw chart
65
chart.container("container").draw();
66
});