HTMLcopy
1
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
// create data set on our data
3
var chartData = {
4
title: 'Top 3 Products with Region Sales Data',
5
header: ['#', 'Florida', 'Texas', 'Arizona', 'Nevada'],
6
rows: [
7
['Nail polish', 6814, 3054, 4376, 4229],
8
['Eyebrow pencil', 7012, 5067, 8987, 3932],
9
['Lipstick', 8814, 9054, 4376, 9256]
10
]
11
};
12
13
// create column chart
14
var chart = anychart.column();
15
16
// set chart data
17
chart.data(chartData);
18
19
// turn on chart animation
20
chart.animation(true);
21
22
chart.yAxis().labels().format('${%Value}{groupsSeparator: }');
23
24
// set titles for Y-axis
25
chart.yAxis().title('Revenue');
26
27
chart
28
.labels()
29
.enabled(true)
30
.position('center-top')
31
.anchor('center-bottom')
32
.format('${%Value}{groupsSeparator: }');
33
chart.hovered().labels(false);
34
35
// turn on legend and tune it
36
chart.legend().enabled(true).fontSize(13).padding([0, 0, 20, 0]);
37
38
// interactivity settings and tooltip position
39
chart.interactivity().hoverMode('single');
40
41
chart
42
.tooltip()
43
.positionMode('point')
44
.position('center-top')
45
.anchor('center-bottom')
46
.offsetX(0)
47
.offsetY(5)
48
.titleFormat('{%X}')
49
.format('{%SeriesName} : ${%Value}{groupsSeparator: }');
50
51
// set container id for the chart
52
chart.container('container');
53
54
// initiate chart drawing
55
chart.draw();
56
});