-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathLine_Chart_Data_Streaming.html
65 lines (56 loc) · 2.05 KB
/
Line_Chart_Data_Streaming.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html lang="en" ng-app="MyApp">
<head>
<meta charset="UTF-8">
<title>Anychart AngularJS plugin demo.</title>
<script src="../node_modules/angular/angular.min.js"></script>
<script src="../node_modules/anychart/dist/js/anychart-base.min.js"></script>
<script src="../node_modules/anychart/dist/js/anychart-ui.min.js"></script>
<script src="../node_modules/anychart/dist/js/anychart-exports.min.js"></script>
<script src="../dist/anychart-angularjs.min.js"></script>
<link rel="stylesheet" href="../node_modules/anychart/dist/css/anychart-ui.min.css">
<link rel="stylesheet" href="../node_modules/anychart/dist/fonts/css/anychart-font.min.css">
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
</style>
<script>
(function() {
'use strict';
var counter = 0;
function random() {
return 100 - Math.round(100 * Math.random());
}
var data = [];
for (var i = 0; i < 50; i++)
data.push([counter++, random()]);
var dataSet = anychart.data.set(data);
angular
.module('MyApp', ['anychart-angularjs'])
.controller('MyCtrl', ['$scope', '$http', 'AnychartService', function($scope, $http, AnychartService) {
$scope.data = dataSet;
$scope.afterDraw = function(chart) {
chart.yScale().minimum(0).maximum(100);
setInterval(function() {
dataSet.remove(0);
dataSet.append([counter++, random()]);
}, 500);
};
}]);
})();
</script>
</head>
<body ng-controller="MyCtrl">
<div
anychart
ac-type="line"
ac-data="data"
ac-chart-draw="afterDraw"
style="width: 100%; height: 100%">
</div>
</body>
</html>