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
3
// create data table on loaded data
4
var dataTable = anychart.data.table();
5
dataTable.addData(getData());
6
7
// map loaded data
8
var mapping = dataTable.mapAs({'value': 1});
9
10
// create stock chart
11
var chart = anychart.stock();
12
13
// add a series
14
chart.plot(0).line(mapping);
15
16
// adjust the scroller
17
chart.selectRange('2004-01-02','2004-01-15');
18
chart.scroller().thumbs(false);
19
chart.scroller().fill('green 0.1');
20
chart.scroller().selectedFill('green 0.5');
21
chart.scroller().allowRangeChange(false);
22
23
// adjust the title according to scroller
24
chart.title("Adjust the scroller");
25
26
// set container id for the chart
27
chart.container('container');
28
29
// initiate chart drawing
30
chart.draw();
31
});
32
33
function getData(){
34
return [
35
['2004-01-02', 2011.08],
36
['2004-01-05', 2020.78],
37
['2004-01-06', 2044.55],
38
['2004-01-07', 2056.75],
39
['2004-01-08', 2089.60],
40
['2004-01-09', 2083.63],
41
['2004-01-12', 2093.54],
42
['2004-01-13', 2113.11],
43
['2004-01-14', 2104.29],
44
['2004-01-15', 2101.86],
45
['2004-01-16', 2126.12],
46
['2004-01-20', 2149.03],
47
['2004-01-21', 2139.33],
48
['2004-01-22', 2146.32],
49
['2004-01-23', 2124.76],
50
['2004-01-26', 2120.56],
51
['2004-01-27', 2148.05],
52
['2004-01-28', 2125.02],
53
['2004-01-29', 2085.54],
54
['2004-01-30', 2068.36]
55
];
56
}