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 a chart
4
var chart = anychart.line();
5
6
// enable the scroller
7
chart.xScroller(true);
8
9
var xZoom = chart.xZoom();
10
11
// zooms settings
12
xZoom.setToPointsCount(6);
13
14
var startRatio = xZoom.getStartRatio();
15
var endRatio = xZoom.getEndRatio();
16
17
// get the limits ratio
18
chart.title("The chart shows the part from " + startRatio + " to " + endRatio);
19
20
// adding a listener
21
chart.xScroller().listen("scrollerchangefinish", function(e){
22
var startRatio = e.startRatio;
23
var endRatio = e.endRatio;
24
// change the chart title
25
chart.title("The chart shows the part from " + startRatio + " to " + endRatio);
26
});
27
28
// create a series
29
var series = chart.line(getData());
30
series.name("Total support requests");
31
32
// define chart settings
33
chart.xAxis().title("Hours");
34
chart.yAxis().title("Support requests");
35
36
// display a chart
37
chart.container("container");
38
chart.draw();
39
});
40
41
function getData(){
42
return [
43
["00:00", 10],
44
["01:00", 4],
45
["02:00", 17],
46
["03:00", 20],
47
["04:00", 20],
48
["05:00", 16],
49
["06:00", 35],
50
["07:00", 6],
51
["08:00", 15],
52
["09:00", 19],
53
["10:00", 25],
54
["11:00", 34],
55
["12:00", 42],
56
["13:00", 14],
57
["14:00", 50],
58
["15:00", 25],
59
["16:00", 34],
60
["17:00", 40],
61
["18:00", 64],
62
["19:00", 48],
63
["20:00", 22],
64
["21:00", 37],
65
["22:00", 53],
66
["23:00", 62]
67
];
68
}