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([-20, 30, 50, -10, 25, -50, 70, 10]);
17
chart2.data([20, 30, 0, 20, -25, -5, -30, 50]);
18
19
// set charts dimensions and position
20
chart1.bounds(0, 0, 300, 40);
21
chart1.type("line");
22
chart2.bounds(0, 50, 300, 40);
23
chart2.type("line");
24
25
// colorize our charts
26
chart1.negativeMarkers().enabled(true).stroke("1 red").fill("green").size(3);
27
chart2.negativeMarkers().enabled(true).stroke("1 red").fill("green").size(3);
28
29
// initiate chart drawing
30
chart1.draw();
31
chart2.draw();
32
});