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 column chart
3
var chart = anychart.column();
4
5
// turn on chart animation
6
chart.animation(true);
7
8
// set chart title text settings
9
chart.title('Top 10 Cosmetic Products by Revenue');
10
11
// create area series with passed data
12
var series = chart.column([
13
['Rouge', '80540'],
14
['Foundation', '94190'],
15
['Mascara', '102610'],
16
['Lip gloss', '110430'],
17
['Lipstick', '128000'],
18
['Nail polish', '143760'],
19
['Eyebrow pencil', '170670'],
20
['Eyeliner', '213210'],
21
['Eyeshadows', '249980']
22
]);
23
24
// set series tooltip settings
25
series.tooltip().titleFormat('{%X}');
26
27
series
28
.tooltip()
29
.position('center-top')
30
.anchor('center-bottom')
31
.offsetX(0)
32
.offsetY(5)
33
.format('${%Value}{groupsSeparator: }');
34
35
// set scale minimum
36
chart.yScale().minimum(0);
37
38
// set yAxis labels formatter
39
chart.yAxis().labels().format('${%Value}{groupsSeparator: }');
40
41
// tooltips position and interactivity settings
42
chart.tooltip().positionMode('point');
43
chart.interactivity().hoverMode('by-x');
44
45
// axes titles
46
chart.xAxis().title('Product');
47
chart.yAxis().title('Revenue');
48
49
// set container id for the chart
50
chart.container('container');
51
52
// initiate chart drawing
53
chart.draw();
54
});