diff options
author | Manuel Luis SanmartĂn Rozada | 2015-04-03 23:26:36 +0200 |
---|---|---|
committer | Pim van den Berg | 2015-06-22 11:03:45 +0200 |
commit | 41c5ef3e4f128efd3fbba27c4bdd99ea71b65ecb (patch) | |
tree | d1d8f3a0014519fb78cde92927f96ebb5b73f4b2 /js | |
parent | jsrrdgraph: Use dash lines in canvas for the grid. (diff) | |
download | apt-panopticon_cgp-41c5ef3e4f128efd3fbba27c4bdd99ea71b65ecb.zip apt-panopticon_cgp-41c5ef3e4f128efd3fbba27c4bdd99ea71b65ecb.tar.gz apt-panopticon_cgp-41c5ef3e4f128efd3fbba27c4bdd99ea71b65ecb.tar.bz2 apt-panopticon_cgp-41c5ef3e4f128efd3fbba27c4bdd99ea71b65ecb.tar.xz |
jsrrdgraph: Fix tabs and spaces
Diffstat (limited to '')
-rw-r--r-- | js/RrdGfxCanvas.js | 2 | ||||
-rw-r--r-- | js/RrdGfxPdf.js | 38 | ||||
-rw-r--r-- | js/RrdGfxSvg.js | 49 | ||||
-rw-r--r-- | js/RrdGraph.js | 8 |
4 files changed, 49 insertions, 48 deletions
diff --git a/js/RrdGfxCanvas.js b/js/RrdGfxCanvas.js index 110c032..7f79b6b 100644 --- a/js/RrdGfxCanvas.js +++ b/js/RrdGfxCanvas.js | |||
@@ -105,7 +105,7 @@ RrdGfxCanvas.prototype.dashed_line = function (X0, Y0, X1, Y1, width, color, das | |||
105 | } else if (X0 === X1) { | 105 | } else if (X0 === X1) { |
106 | X0 += 0.5; | 106 | X0 += 0.5; |
107 | X1 += 0.5; | 107 | X1 += 0.5; |
108 | } | 108 | } |
109 | 109 | ||
110 | this.ctx.moveTo(X0, Y0); | 110 | this.ctx.moveTo(X0, Y0); |
111 | this.ctx.lineTo(X1, Y1); | 111 | this.ctx.lineTo(X1, Y1); |
diff --git a/js/RrdGfxPdf.js b/js/RrdGfxPdf.js index 7cde098..868d521 100644 --- a/js/RrdGfxPdf.js +++ b/js/RrdGfxPdf.js | |||
@@ -154,20 +154,20 @@ RrdGfxPdf.CORE_FONTS= { | |||
154 | 154 | ||
155 | RrdGfxPdf.prototype.parse_color = function(str) | 155 | RrdGfxPdf.prototype.parse_color = function(str) |
156 | { | 156 | { |
157 | var bits; | 157 | var bits; |
158 | if ((bits = /^#?([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/.exec(str))) { | 158 | if ((bits = /^#?([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/.exec(str))) { |
159 | return [parseInt(bits[1]+bits[1], 16), parseInt(bits[2]+bits[2], 16), parseInt(bits[3]+bits[3], 16), 1.0]; | 159 | return [parseInt(bits[1]+bits[1], 16), parseInt(bits[2]+bits[2], 16), parseInt(bits[3]+bits[3], 16), 1.0]; |
160 | } else if ((bits = /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(str))) { | 160 | } else if ((bits = /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(str))) { |
161 | return [parseInt(bits[1], 16), parseInt(bits[2], 16), parseInt(bits[3], 16), 1.0]; | 161 | return [parseInt(bits[1], 16), parseInt(bits[2], 16), parseInt(bits[3], 16), 1.0]; |
162 | } else if ((bits = /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(str))) { | 162 | } else if ((bits = /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(str))) { |
163 | return [parseInt(bits[1], 16), parseInt(bits[2], 16), parseInt(bits[3], 16), parseInt(bits[4], 16)/255]; | 163 | return [parseInt(bits[1], 16), parseInt(bits[2], 16), parseInt(bits[3], 16), parseInt(bits[4], 16)/255]; |
164 | } else if ((bits = /^rgb\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\)$/.exec(str))) { | 164 | } else if ((bits = /^rgb\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\)$/.exec(str))) { |
165 | return [parseInt(bits[1], 10), parseInt(bits[2], 10), parseInt(bits[3], 10), 1.0]; | 165 | return [parseInt(bits[1], 10), parseInt(bits[2], 10), parseInt(bits[3], 10), 1.0]; |
166 | } else if ((bits = /^rgba\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([0-9.]+)\)$/.exec(str))) { | 166 | } else if ((bits = /^rgba\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([0-9.]+)\)$/.exec(str))) { |
167 | return [parseInt(bits[1], 10), parseInt(bits[2], 10), parseInt(bits[3], 10), parseFloat(bits[4], 10)]; | 167 | return [parseInt(bits[1], 10), parseInt(bits[2], 10), parseInt(bits[3], 10), parseFloat(bits[4], 10)]; |
168 | } else { | 168 | } else { |
169 | throw "Unknow color format '"+str+"'"; | 169 | throw "Unknow color format '"+str+"'"; |
170 | } | 170 | } |
171 | }; | 171 | }; |
172 | 172 | ||
173 | RrdGfxPdf.prototype.size = function (width, height) | 173 | RrdGfxPdf.prototype.size = function (width, height) |
@@ -358,12 +358,12 @@ RrdGfxPdf.prototype.text = function (x, y, color, font, tabwidth, angle, h_align | |||
358 | 358 | ||
359 | var tm = []; | 359 | var tm = []; |
360 | tm[0] = Math.cos(angle*Math.PI/180.0); | 360 | tm[0] = Math.cos(angle*Math.PI/180.0); |
361 | tm[1] = Math.sin(angle*Math.PI/180.0); | 361 | tm[1] = Math.sin(angle*Math.PI/180.0); |
362 | tm[2] = -tm[1]; | 362 | tm[2] = -tm[1]; |
363 | tm[3] = tm[0]; | 363 | tm[3] = tm[0]; |
364 | 364 | ||
365 | tm[4] = x + (tm[1] * y) - (tm[0] * x); | 365 | tm[4] = x + (tm[1] * y) - (tm[0] * x); |
366 | tm[5] = y - (tm[0] * y) - (tm[1] * x); | 366 | tm[5] = y - (tm[0] * y) - (tm[1] * x); |
367 | 367 | ||
368 | var rgba = this.parse_color(color); | 368 | var rgba = this.parse_color(color); |
369 | this._save(); | 369 | this._save(); |
diff --git a/js/RrdGfxSvg.js b/js/RrdGfxSvg.js index 927cb14..533abb8 100644 --- a/js/RrdGfxSvg.js +++ b/js/RrdGfxSvg.js | |||
@@ -24,7 +24,8 @@ | |||
24 | * RrdGfxSvg | 24 | * RrdGfxSvg |
25 | * @constructor | 25 | * @constructor |
26 | */ | 26 | */ |
27 | var RrdGfxSvg = function(svgId) { | 27 | var RrdGfxSvg = function(svgId) |
28 | { | ||
28 | this.svg = document.getElementById(svgId); | 29 | this.svg = document.getElementById(svgId); |
29 | this.svgns = "http://www.w3.org/2000/svg"; | 30 | this.svgns = "http://www.w3.org/2000/svg"; |
30 | this.xmlns = "http://www.w3.org/XML/1998/namespace"; | 31 | this.xmlns = "http://www.w3.org/XML/1998/namespace"; |
@@ -32,7 +33,7 @@ var RrdGfxSvg = function(svgId) { | |||
32 | this.path_color = null; | 33 | this.path_color = null; |
33 | this.path_width = null; | 34 | this.path_width = null; |
34 | this.dash = false; | 35 | this.dash = false; |
35 | this.dash_offset = null; | 36 | this.dash_offset = null; |
36 | this.dash_array = null; | 37 | this.dash_array = null; |
37 | }; | 38 | }; |
38 | 39 | ||
@@ -70,10 +71,10 @@ RrdGfxSvg.prototype.line = function (X0, Y0, X1, Y1, width, color) | |||
70 | { | 71 | { |
71 | var shape = document.createElementNS(this.svgns, "line"); | 72 | var shape = document.createElementNS(this.svgns, "line"); |
72 | 73 | ||
73 | X0 = Math.round(X0)+0.5; | 74 | X0 = Math.round(X0)+0.5; |
74 | Y0 = Math.round(Y0)+0.5; | 75 | Y0 = Math.round(Y0)+0.5; |
75 | X1 = Math.round(X1)+0.5; | 76 | X1 = Math.round(X1)+0.5; |
76 | Y1 = Math.round(Y1)+0.5; | 77 | Y1 = Math.round(Y1)+0.5; |
77 | 78 | ||
78 | shape.setAttributeNS(null, "x1", X0); | 79 | shape.setAttributeNS(null, "x1", X0); |
79 | shape.setAttributeNS(null, "y1", Y0); | 80 | shape.setAttributeNS(null, "y1", Y0); |
@@ -91,10 +92,10 @@ RrdGfxSvg.prototype.dashed_line = function (X0, Y0, X1, Y1, width, color, dash_o | |||
91 | { | 92 | { |
92 | var shape = document.createElementNS(this.svgns, "line"); | 93 | var shape = document.createElementNS(this.svgns, "line"); |
93 | 94 | ||
94 | X0 = Math.round(X0)+0.5; | 95 | X0 = Math.round(X0)+0.5; |
95 | Y0 = Math.round(Y0)+0.5; | 96 | Y0 = Math.round(Y0)+0.5; |
96 | X1 = Math.round(X1)+0.5; | 97 | X1 = Math.round(X1)+0.5; |
97 | Y1 = Math.round(Y1)+0.5; | 98 | Y1 = Math.round(Y1)+0.5; |
98 | 99 | ||
99 | shape.setAttributeNS(null, "x1", X0); | 100 | shape.setAttributeNS(null, "x1", X0); |
100 | shape.setAttributeNS(null, "y1", Y0); | 101 | shape.setAttributeNS(null, "y1", Y0); |
@@ -129,12 +130,12 @@ RrdGfxSvg.prototype.rectangle = function (X0, Y0, X1, Y1, width, style) | |||
129 | 130 | ||
130 | RrdGfxSvg.prototype.new_area = function (X0, Y0, X1, Y1, X2, Y2, color) | 131 | RrdGfxSvg.prototype.new_area = function (X0, Y0, X1, Y1, X2, Y2, color) |
131 | { | 132 | { |
132 | X0 = Math.round(X0)+0.5; | 133 | X0 = Math.round(X0)+0.5; |
133 | Y0 = Math.round(Y0)+0.5; | 134 | Y0 = Math.round(Y0)+0.5; |
134 | X1 = Math.round(X1)+0.5; | 135 | X1 = Math.round(X1)+0.5; |
135 | Y1 = Math.round(Y1)+0.5; | 136 | Y1 = Math.round(Y1)+0.5; |
136 | X2 = Math.round(X2)+0.5; | 137 | X2 = Math.round(X2)+0.5; |
137 | Y2 = Math.round(Y2)+0.5; | 138 | Y2 = Math.round(Y2)+0.5; |
138 | 139 | ||
139 | this.path_color = color; | 140 | this.path_color = color; |
140 | this.path = 'M'+X0+','+Y0; | 141 | this.path = 'M'+X0+','+Y0; |
@@ -144,8 +145,8 @@ RrdGfxSvg.prototype.new_area = function (X0, Y0, X1, Y1, X2, Y2, color) | |||
144 | 145 | ||
145 | RrdGfxSvg.prototype.add_point = function (x, y) | 146 | RrdGfxSvg.prototype.add_point = function (x, y) |
146 | { | 147 | { |
147 | x = Math.round(x)+0.5; | 148 | x = Math.round(x)+0.5; |
148 | y = Math.round(y)+0.5; | 149 | y = Math.round(y)+0.5; |
149 | 150 | ||
150 | this.path += ' L'+x+','+y; | 151 | this.path += ' L'+x+','+y; |
151 | }; | 152 | }; |
@@ -188,24 +189,24 @@ RrdGfxSvg.prototype.stroke_end = function () | |||
188 | 189 | ||
189 | RrdGfxSvg.prototype.moveTo = function (x,y) | 190 | RrdGfxSvg.prototype.moveTo = function (x,y) |
190 | { | 191 | { |
191 | x = Math.round(x)+0.5; | 192 | x = Math.round(x)+0.5; |
192 | y = Math.round(y)+0.5; | 193 | y = Math.round(y)+0.5; |
193 | 194 | ||
194 | this.path += ' M'+x+','+y; | 195 | this.path += ' M'+x+','+y; |
195 | }; | 196 | }; |
196 | 197 | ||
197 | RrdGfxSvg.prototype.lineTo = function (x,y) | 198 | RrdGfxSvg.prototype.lineTo = function (x,y) |
198 | { | 199 | { |
199 | x = Math.round(x)+0.5; | 200 | x = Math.round(x)+0.5; |
200 | y = Math.round(y)+0.5; | 201 | y = Math.round(y)+0.5; |
201 | 202 | ||
202 | this.path += ' L'+x+','+y; | 203 | this.path += ' L'+x+','+y; |
203 | }; | 204 | }; |
204 | 205 | ||
205 | RrdGfxSvg.prototype.text = function (x, y, color, font, tabwidth, angle, h_align, v_align, text) | 206 | RrdGfxSvg.prototype.text = function (x, y, color, font, tabwidth, angle, h_align, v_align, text) |
206 | { | 207 | { |
207 | x = Math.round(x); | 208 | x = Math.round(x); |
208 | y = Math.round(y); | 209 | y = Math.round(y); |
209 | 210 | ||
210 | var svgtext = document.createElementNS(this.svgns, "text"); | 211 | var svgtext = document.createElementNS(this.svgns, "text"); |
211 | 212 | ||
diff --git a/js/RrdGraph.js b/js/RrdGraph.js index 25823aa..1a9cc9f 100644 --- a/js/RrdGraph.js +++ b/js/RrdGraph.js | |||
@@ -27,8 +27,8 @@ | |||
27 | */ | 27 | */ |
28 | var RrdGraphDescError = function (message) | 28 | var RrdGraphDescError = function (message) |
29 | { | 29 | { |
30 | this.name = "RrdGraphDescError"; | 30 | this.name = "RrdGraphDescError"; |
31 | this.message = (message) ? message : "Error"; | 31 | this.message = (message) ? message : "Error"; |
32 | }; | 32 | }; |
33 | RrdGraphDescError.prototype = new Error(); | 33 | RrdGraphDescError.prototype = new Error(); |
34 | 34 | ||
@@ -430,8 +430,8 @@ RrdGraphDesc.prototype.hrule = function (graph, value, color, legend, dashes, da | |||
430 | */ | 430 | */ |
431 | var RrdVdefError = function (message) | 431 | var RrdVdefError = function (message) |
432 | { | 432 | { |
433 | this.name = "RrdVdefError"; | 433 | this.name = "RrdVdefError"; |
434 | this.message = (message) ? message : "Error"; | 434 | this.message = (message) ? message : "Error"; |
435 | }; | 435 | }; |
436 | RrdVdefError.prototype = new Error(); | 436 | RrdVdefError.prototype = new Error(); |
437 | 437 | ||