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
chart1.seriesType("line");
7
chart2.seriesType("line");
8
9
chart1.title("Line 1");
10
chart2.title("Line 2");
11
12
// create data for both charts
13
chart1.data([-20, 30, 50, -10, 25, -50, 70, 10]);
14
chart2.data([20, 30, 0, 20, -25, -5, -30, 50]);
15
16
// set charts dimensions and position
17
chart1.bounds(0, 0, 300, 40);
18
chart2.bounds(0, 50, 300, 40);
19
20
// colorize our charts
21
chart1.negativeMarkers().enabled(true).stroke("1 red").fill("green").size(3);
22
chart2.negativeMarkers().enabled(true).stroke("1 red").fill("green").size(3);
23
24
// set container id for the charts
25
chart1.container(stage);
26
chart2.container(stage);
27
28
// initiate chart drawing
29
chart1.draw();
30
chart2.draw();
31
});