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
chart1.title().text("Line 1");
13
chart2.title().text("Line 2");
14
15
// create data for both charts
16
chart1.data([
17
-20,
18
30,
19
50,
20
-10,
21
{value:"25", fill:"green"},
22
-50,
23
70,
24
10]);
25
26
chart2.data([
27
20,
28
30,
29
-10,
30
20,
31
{value:"-25", fill:"green"},
32
-5,
33
-30,
34
50]);
35
36
// color the rest points in the same low-opacity color to make the fifth point of the data more noticeable
37
chart1.fill("green .3");
38
chart1.negativeFill("green .3");
39
chart2.fill("green .3");
40
chart2.negativeFill("green .3");
41
42
// set charts dimensions and position
43
chart1.bounds(0, 0, 300, 120);
44
chart1.type("column");
45
chart2.bounds(0, 120, 300, 120);
46
chart2.type("column");
47
48
// initiate chart drawing
49
chart1.draw();
50
chart2.draw();
51
52
});