forked from gphat/clack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmany.html
More file actions
76 lines (64 loc) · 1.86 KB
/
many.html
File metadata and controls
76 lines (64 loc) · 1.86 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
69
70
71
72
73
74
75
76
---
layout: default
---
<p>20 charts, each with 4 timeseries and 30 points updating every 5ms. Axes are intentionally not shown because D3 is prohibitively slow at updating the axes at this speed.</p>
<div id="root"></div>
<script>
$(document).ready(function() {
var charts = [];
var colors = d3.scale.category10();
console.time("many charts");
for(var x = 0; x < 20; x++) {
var div = document.createElement('div');
div.id = 'chart' + x;
div.style.display = "inline-block";
div.style.margin = "5px";
div.style.position = "relative";
document.getElementById('root').appendChild(div);
var c = new CLACK.Chart(
document.getElementById('chart' + x)
);
var context = c.getContext('default');
context.showRangeAxis = false;
context.showRangeGrid = false;
context.showDomainAxis = false;
context.showDomainGrid = false;
var series = 4;
var points = 30;
var currentDate = new Date();
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', {
x: exes,
y: whys,
label: 'foobar ' + j,
color: colors(j)
});
}
c.draw();
charts.push(c);
}
console.timeEnd('many charts');
var x = 31;
var addAPoint = function() {
for(var i = 0; i < charts.length; i++) {
var c = charts[i];
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)], true);
c.draw();
// console.timeEnd('redraw');
x += 1;
}
}
setTimeout(addAPoint,5);
}
setTimeout(addAPoint,5);
});
</script>