-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstant.html
More file actions
68 lines (55 loc) · 1.47 KB
/
Copy pathinstant.html
File metadata and controls
68 lines (55 loc) · 1.47 KB
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
66
67
68
---
layout: default
---
<p>Each series' current value with a min and max.</p>
<div id="chartContainer" style="display: inline-block; position: relative"></div>
<script>
$(document).ready(function() {
var c = new CLACK.Chart(
document.getElementById('chartContainer'), {
axes: false,
renderer: new CLACK.InstantRenderer()
}
);
var series = 4;
var points = 30;
var currentDate = new Date();
var colors = d3.scale.category10();
var context = c.getContext('default');
context.showRangeAxis = false;
context.showRangeGrid = false;
context.showDomainAxis = false;
context.showDomainGrid = false;
// console.time("generatechart");
for(var j = 0; j <= series; j++) {
var exes = [];
var whys = [];
for(var i = 0; i <= points; i++) {
exes.push(i);
whys.push((j + 1) * Math.sin(2 * Math.PI * j + i + currentDate.getSeconds()));
}
c.addSeries('default', {
name: 'Series ' + j,
x: exes,
y: whys,
label: 'foobar ' + j,
color: colors(j)
});
}
// console.timeEnd("generatechart");
c.draw();
var x = points;
var addAPoint = function() {
for(var j = 0; j <= series; j++) {
var y = Math.floor(Math.random() * 50);
// console.time('redraw');
c.addToSeries('default', j, [x], [(j + 1) * Math.sin(2 * Math.PI * j + x)]);
c.draw();
// console.timeEnd('redraw');
x += 1;
}
setTimeout(addAPoint,1000);
}
setTimeout(addAPoint,1000);
});
</script>