diff options
Diffstat (limited to 'js/RrdGfxSvg.js')
-rw-r--r-- | js/RrdGfxSvg.js | 49 |
1 files changed, 25 insertions, 24 deletions
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 | ||