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
var stage = anychart.graphics.create("container");
4
5
// data
6
var dataSet = anychart.data.set([
7
["Department Stores", 637166, 254463, 353554, 856175, 2101358],
8
["Discount Stores", 721630, 366655, 734634, 365654, 2188573],
9
["Men's/Women's Specialty Stores", 148662, 252522, 123488, 903112, 1427784],
10
["All other outlets", 90000, 61000, 72000, 94000, 83000, 400000]
11
]);
12
13
14
// create charts
15
columnChart = anychart.column();
16
splineChart = anychart.line();
17
18
series1 = columnChart.column(dataSet.mapAs({x: 0, value: 1}));
19
series2 = columnChart.column(dataSet.mapAs({x: 0, value: 2}));
20
series3 = columnChart.column(dataSet.mapAs({x: 0, value: 3}));
21
series4 = columnChart.column(dataSet.mapAs({x: 0, value: 4}));
22
23
series1.name("Shop 1");
24
series2.name("Shop 2");
25
series3.name("Shop 3");
26
series4.name("Shop 4");
27
28
seriesSpline = splineChart.spline(dataSet.mapAs({x: 0, value: 5}));
29
30
// set bounds
31
columnChart.bounds(0, 0, "100%", "50%");
32
splineChart.bounds(0, "50%", "100%", "50%");
33
34
// set the tooltip title and text for the Column Chart
35
columnChart.tooltip().titleFormat("{%seriesName}");
36
columnChart.tooltip().format("Department: {%x} \nSum: {%value}");
37
38
// set the tooltip content
39
seriesSpline.tooltip().format(function(e){
40
var value = (this.value)/1000000;
41
return "Total: $" + value + "M";
42
});
43
44
// set container and draw charts
45
columnChart.container(stage);
46
columnChart.draw();
47
splineChart.container(stage);
48
splineChart.draw();
49
});