-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspeedgraph.js
More file actions
78 lines (78 loc) · 1.63 KB
/
speedgraph.js
File metadata and controls
78 lines (78 loc) · 1.63 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
var SpeedGraph = new Class({
element: null,
plot: null,
maxDataInterval: 600 * 1000,
maxShowInterval: -1,
create: function(a) {
this.element = $(a);
this.plot = new Flotr.Plot(this.element, [{
data: []
}, {
data: []
}], {
legend: {
position: "nw"
},
lines: {
show: true,
lineWidth: 1
},
xaxis: {
tickSize: 60,
tickFormatter: function(b) {
return (new Date(Number(b))).format("%H:%M:%S")
}
},
yaxis: {
min: 0,
minMaxTickSize: 512,
tickFormatter: function(b) {
return (parseInt(b).toFileSize() + g_perSec)
}
},
shadowSize: 0
})
},
draw: function() {
if (!(utWebUI.config || {}).showDetails || utWebUI.mainTabs.active != "mainInfoPane-speedTab") {
return
}
this.plot.repaint()
},
resizeTo: function(a, c) {
var b = {};
if (typeof(a) === "number" && a > 0) {
b.width = a
}
if (typeof(c) === "number" && c > 0) {
b.height = c
}
this.element.setStyles(b);
this.draw()
},
showLegend: function(a) {
this.plot.options.legend.show = !!a;
this.draw()
},
setLabels: function(b, a) {
if (typeof(b) !== "undefined") {
this.plot.series[0].label = b
}
if (typeof(a) !== "undefined") {
this.plot.series[1].label = a
}
},
addData: function(a, e) {
var c = Date.now();
var b = this.plot.series[0].data;
var d = this.plot.series[1].data;
b.push([c, a]);
d.push([c, e]);
while ((c - b[0][0]) > this.maxDataInterval) {
b.shift();
d.shift()
}
this.plot.options.xaxis.min = c - (0 < this.maxShowInterval && this.maxShowInterval < this.maxDataInterval ? this.maxShowInterval : this.maxDataInterval);
this.draw()
}
});