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 chart = anychart.line();
3
chart.line(getData());
4
chart.xAxis(true);
5
6
var scroller = chart.xScroller();
7
scroller.enabled(true);
8
9
// Set event type
10
scroller.listen('scrollerChange', function (e) {
11
var startRatio = e.startRatio;
12
var endRatio = e.endRatio;
13
chart.title("The chart shows the part from " + startRatio + " to " + endRatio);
14
});
15
16
chart.title('Drag the scroller');
17
chart.container('container');
18
chart.draw();
19
});
20
21
function getData(){
22
return [
23
['JAN', 22],
24
['FEB', 24],
25
['MAR', 10],
26
['APR', 29],
27
['MAY', 34],
28
['JUN', 29],
29
['JUL', 43],
30
['AUG', 43],
31
['SEP', 20],
32
['OCT', 2],
33
['NOV', 0],
34
['DEC', 4]
35
];
36
}