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: 'Company Profit Dynamic in Regions by Year',
5
header: ['#', 'Florida', 'Texas', 'Nevada', 'Arizona'],
6
rows: [
7
['2001', 128.14, -90.54, -43.76, -122.56],
8
['2002', 112.61, 104.19, 61.34, -87.12],
9
['2003', -123.21, 135.12, -34.17, 54.32]
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
// set chart title text settings
23
chart.interactivity().hoverMode('single');
24
25
// set axis settings
26
chart.xAxis().value(0).labels(false);
27
chart.xAxis(1).stroke(null).orientation('top');
28
chart.xAxis(2).stroke(null).orientation('bottom');
29
chart.yAxis().title('Profit in $');
30
chart.yAxis().labels().format('{%Value}k.');
31
32
chart.labels(true);
33
chart
34
.tooltip()
35
.title(false)
36
.separator(false)
37
.format('{%Name} {%Value}{decimalSeparator:\\,}k.');
38
39
// turn on legend
40
chart.legend().enabled(true).fontSize(13).padding([0, 0, 20, 0]);
41
42
// turn on grids
43
chart.xGrid().stroke('#ddd').drawLastLine(false);
44
45
// tune column paddings
46
// chart.barsPadding(0.1).barGroupsPadding(0.9);
47
48
// set container id for the chart
49
chart.container('container');
50
51
// initiate chart drawing
52
chart.draw();
53
});