forked from gphat/clack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulti.html
More file actions
91 lines (75 loc) · 2.08 KB
/
multi.html
File metadata and controls
91 lines (75 loc) · 2.08 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
layout: default
---
<p>Multi till the sun die.</p>
<div id="chartContainer" style="display: inline-block; position: relative"></div>
<script>
$(document).ready(function() {
var c = new CLACK.Chart(
document.getElementById('chartContainer'), {
}
);
var series = 2;
var points = 30;
var currentDate = new Date();
var colors = d3.scale.category10();
// 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.45 * Math.PI * j + i + currentDate.getSeconds()) * 2);
}
c.addSeries('default', {
x: exes,
y: whys,
label: 'default ' + j,
color: colors(j)
});
}
// The other one!
for(var j = 0; j < series; j++) {
var exes = [];
var whys = [];
for(var i = 0; i <= points; i++) {
exes.push(i + 103419);
whys.push(Math.floor(Math.random() * 100));
}
c.addSeries('other', {
x: exes,
y: whys,
label: 'other ' + j,
color: colors(j + series)
});
}
c.getContext('other').renderer = new CLACK.ScatterPlotRenderer();
c.getContext('other').rangeAxisOrientation = 'right';
c.getContext('other').domainAxisOrientation = 'top';
c.getContext('other').showDomainGrid = false;
c.getContext('other').showRangeGrid = false;
// 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)], true);
c.draw();
// console.timeEnd('redraw');
x += 1;
}
for(var j = 0; j < series; j++) {
var y = Math.floor(Math.random() * 50);
// console.time('redraw');
c.addToSeries('other', j, [x + 103419], [Math.floor(Math.random() * 100)], true);
c.draw();
// console.timeEnd('redraw');
x += 1;
}
setTimeout(addAPoint,1000);
}
setTimeout(addAPoint,1000);
});
</script>