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
var stage = anychart.graphics.create("container");
3
// create charts
4
chart1 = anychart.sparkline();
5
chart2 = anychart.sparkline();
6
7
// set container id for the charts
8
chart1.container(stage);
9
chart2.container(stage);
10
chart1.title(true);
11
chart2.title(true);
12
13
chart1.title().text("Column 1");
14
chart2.title().text("Column 2");
15
16
// create data for both charts
17
chart1.data([-20, 30, 50, -10, 25, -50, 70, 10]);
18
chart2.data([20, 30, -10, 20, -35, -15, -40, 50]);
19
20
// set charts dimensions and position
21
chart1.bounds(0, 0, 300, 40);
22
chart1.type("column");
23
chart2.bounds(0, 50, 300, 40);
24
chart2.type("column");
25
26
// color the rest points in the same low-opacity color to make the special points of the data more noticeable
27
chart1.fill("green .3");
28
chart1.negativeFill("green .3");
29
chart2.fill("green .3");
30
chart2.negativeFill("green .3");
31
32
// colorize our charts
33
chart1.firstFill("darkRed");
34
chart1.lastFill("green");
35
chart2.firstFill("darkRed");
36
chart2.lastFill("green");
37
38
// initiate chart drawing
39
chart1.draw();
40
chart2.draw();
41
});