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