rgraph-rails 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/lib/rgraph-rails/version.rb +1 -1
  4. data/license.txt +4 -16
  5. data/vendor/assets/javascripts/RGraph.bar.js +3734 -241
  6. data/vendor/assets/javascripts/RGraph.bipolar.js +2005 -115
  7. data/vendor/assets/javascripts/RGraph.common.annotate.js +395 -35
  8. data/vendor/assets/javascripts/RGraph.common.context.js +595 -30
  9. data/vendor/assets/javascripts/RGraph.common.core.js +5282 -405
  10. data/vendor/assets/javascripts/RGraph.common.csv.js +276 -19
  11. data/vendor/assets/javascripts/RGraph.common.deprecated.js +450 -35
  12. data/vendor/assets/javascripts/RGraph.common.dynamic.js +1395 -86
  13. data/vendor/assets/javascripts/RGraph.common.effects.js +1545 -90
  14. data/vendor/assets/javascripts/RGraph.common.key.js +753 -54
  15. data/vendor/assets/javascripts/RGraph.common.resizing.js +563 -37
  16. data/vendor/assets/javascripts/RGraph.common.sheets.js +352 -29
  17. data/vendor/assets/javascripts/RGraph.common.tooltips.js +450 -32
  18. data/vendor/assets/javascripts/RGraph.common.zoom.js +219 -14
  19. data/vendor/assets/javascripts/RGraph.drawing.background.js +570 -35
  20. data/vendor/assets/javascripts/RGraph.drawing.circle.js +544 -35
  21. data/vendor/assets/javascripts/RGraph.drawing.image.js +755 -52
  22. data/vendor/assets/javascripts/RGraph.drawing.marker1.js +645 -41
  23. data/vendor/assets/javascripts/RGraph.drawing.marker2.js +633 -37
  24. data/vendor/assets/javascripts/RGraph.drawing.marker3.js +514 -36
  25. data/vendor/assets/javascripts/RGraph.drawing.poly.js +559 -39
  26. data/vendor/assets/javascripts/RGraph.drawing.rect.js +548 -35
  27. data/vendor/assets/javascripts/RGraph.drawing.text.js +664 -36
  28. data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +812 -50
  29. data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +856 -51
  30. data/vendor/assets/javascripts/RGraph.fuel.js +964 -58
  31. data/vendor/assets/javascripts/RGraph.funnel.js +984 -55
  32. data/vendor/assets/javascripts/RGraph.gantt.js +1354 -77
  33. data/vendor/assets/javascripts/RGraph.gauge.js +1421 -87
  34. data/vendor/assets/javascripts/RGraph.hbar.js +2562 -146
  35. data/vendor/assets/javascripts/RGraph.hprogress.js +1401 -80
  36. data/vendor/assets/javascripts/RGraph.line.js +4226 -244
  37. data/vendor/assets/javascripts/RGraph.meter.js +1280 -74
  38. data/vendor/assets/javascripts/RGraph.modaldialog.js +301 -19
  39. data/vendor/assets/javascripts/RGraph.odo.js +1264 -71
  40. data/vendor/assets/javascripts/RGraph.pie.js +2288 -137
  41. data/vendor/assets/javascripts/RGraph.radar.js +1847 -110
  42. data/vendor/assets/javascripts/RGraph.rose.js +1977 -108
  43. data/vendor/assets/javascripts/RGraph.rscatter.js +1432 -80
  44. data/vendor/assets/javascripts/RGraph.scatter.js +3036 -168
  45. data/vendor/assets/javascripts/RGraph.semicircularprogress.js +1120 -60
  46. data/vendor/assets/javascripts/RGraph.svg.bar.js +1067 -0
  47. data/vendor/assets/javascripts/RGraph.svg.common.ajax.js +247 -0
  48. data/vendor/assets/javascripts/RGraph.svg.common.core.js +3363 -0
  49. data/vendor/assets/javascripts/RGraph.svg.common.csv.js +277 -0
  50. data/vendor/assets/javascripts/RGraph.svg.common.fx.js +1304 -0
  51. data/vendor/assets/javascripts/RGraph.svg.common.sheets.js +353 -0
  52. data/vendor/assets/javascripts/RGraph.svg.common.tooltips.js +233 -0
  53. data/vendor/assets/javascripts/RGraph.svg.hbar.js +1141 -0
  54. data/vendor/assets/javascripts/RGraph.svg.line.js +1486 -0
  55. data/vendor/assets/javascripts/RGraph.svg.pie.js +781 -0
  56. data/vendor/assets/javascripts/RGraph.svg.radar.js +1326 -0
  57. data/vendor/assets/javascripts/RGraph.svg.semicircularprogress.js +817 -0
  58. data/vendor/assets/javascripts/RGraph.thermometer.js +1135 -62
  59. data/vendor/assets/javascripts/RGraph.vprogress.js +1470 -83
  60. data/vendor/assets/javascripts/RGraph.waterfall.js +1347 -80
  61. metadata +15 -3
@@ -1,20 +1,277 @@
1
+ // version: 2017-01-02
2
+ /**
3
+ * o--------------------------------------------------------------------------------o
4
+ * | This file is part of the RGraph package - you can learn more at: |
5
+ * | |
6
+ * | http://www.rgraph.net |
7
+ * | |
8
+ * | RGraph is licensed under the Open Source MIT license. That means that it's |
9
+ * | totally free to use! |
10
+ * o--------------------------------------------------------------------------------o
11
+ */
1
12
 
2
- RGraph=window.RGraph||{isRGraph:true};RGraph.CSV=function(url,func)
3
- {var RG=RGraph,ua=navigator.userAgent,ma=Math;this.url=url;this.ready=func;this.data=null;this.numrows=null;this.numcols=null;this.seperator=arguments[2]||',';this.endofline=arguments[3]||/\r?\n/;this.splitCSV=function(str,split)
4
- {var arr=[];var field='';var inDoubleQuotes=false;var inSingleQuotes=false;var preserve=(typeof split==='object'&&split.preserve)?true:false;if(typeof split==='object'){if(typeof split.char==='string'){split=split.char;}else{split=',';}}
5
- for(var i=0,len=str.length;i<len;i+=1){char=str.charAt(i);if((char==='"')&&!inDoubleQuotes){inDoubleQuotes=true;continue;}else if((char==='"')&&inDoubleQuotes){inDoubleQuotes=false;continue;}
6
- if((char==="'")&&!inSingleQuotes){inSingleQuotes=true;continue;}else if((char==="'")&&inSingleQuotes){inSingleQuotes=false;continue;}else if(char===split&&!inDoubleQuotes&&!inSingleQuotes){arr.push(field);field='';continue;}else{field=field+char;}}
7
- arr.push(field);if(!preserve){for(i=0,len=arr.length;i<len;i+=1){arr[i]=arr[i].trim();}}
8
- return arr;};this.fetch=function()
9
- {var sep=this.seperator;var eol=this.endofline;var obj=this;if(this.url.substring(0,3)=='id:'){var data=document.getElementById(this.url.substring(3)).innerHTML.trim();obj.data=data.split(eol);obj.numrows=obj.data.length;for(var i=0,len=obj.data.length;i<len;i+=1){var row=obj.splitCSV(obj.data[i],{preserve:false,char:sep});if(!obj.numcols){obj.numcols=row.length;}
10
- for(var j=0;j<row.length;j+=1){if((/^[0-9.]+$/).test(row[j])){row[j]=parseFloat(row[j]);}
11
- obj.data[i]=row;}}
12
- obj.ready(obj);}else{RGraph.AJAX.getString(this.url,function(data)
13
- {data=data.replace(/(\r?\n)+$/,'');obj.data=data.split(eol);obj.numrows=obj.data.length;for(var i=0,len=obj.data.length;i<len;i+=1){var row=obj.splitCSV(obj.data[i],{preserve:false,char:sep});if(!obj.numcols){obj.numcols=row.length;}
14
- for(var j=0;j<row.length;j+=1){if((/^\-?[0-9.]+$/).test(row[j])){row[j]=parseFloat(row[j]);}
15
- obj.data[i]=row;}}
16
- obj.ready(obj);});}};this.getRow=function(index)
17
- {var row=[];var start=arguments[1]||0;for(var i=start;i<this.numcols;i+=1){row.push(this.data[index][i]);}
18
- return row;};this.getCol=this.getColumn=function(index)
19
- {var col=[];var start=arguments[1]||0;for(var i=start;i<this.numrows;i+=1){col.push(this.data[i][index]);}
20
- return col;};this.fetch();};
13
+ /**
14
+ * Initialise the various objects
15
+ */
16
+ RGraph = window.RGraph || {isRGraph: true};
17
+
18
+
19
+
20
+
21
+ RGraph.CSV = function (url, func)
22
+ {
23
+ var RG = RGraph,
24
+ ua = navigator.userAgent,
25
+ ma = Math;
26
+
27
+
28
+
29
+
30
+ /**
31
+ * Some default values
32
+ */
33
+ this.url = url;
34
+ this.ready = func;
35
+ this.data = null;
36
+ this.numrows = null;
37
+ this.numcols = null;
38
+ this.seperator = arguments[2] || ',';
39
+ this.endofline = arguments[3] || /\r?\n/;
40
+ this.uid = RGraph.createUID();
41
+
42
+
43
+
44
+
45
+ /**
46
+ * A Custom split function
47
+ *
48
+ * @param string str The CSV string to split
49
+ * @param mixed char The character to split on - or it can also be an object like this:
50
+ * {
51
+ * preserve: false, // Whether to preserve whitespace
52
+ * char: ',' // The character to split on
53
+ * }
54
+ */
55
+ this.splitCSV = function (str, split)
56
+ {
57
+ // Defaults
58
+ var arr = [];
59
+ var field = '';
60
+ var inDoubleQuotes = false;
61
+ var inSingleQuotes = false;
62
+ var preserve = (typeof split === 'object' && split.preserve) ? true : false;
63
+
64
+ // The character to split the CSV string on
65
+ if (typeof split === 'object') {
66
+ if (typeof split.char === 'string') {
67
+ split = split.char;
68
+ } else {
69
+ split = ',';
70
+ }
71
+ } // If not an object just leave the char as it's supplied
72
+
73
+
74
+
75
+ for (var i=0,len=str.length; i<len; i+=1) {
76
+
77
+ char = str.charAt(i);
78
+
79
+ if ( (char === '"') && !inDoubleQuotes) {
80
+ inDoubleQuotes = true;
81
+ continue;
82
+
83
+ } else if ( (char === '"') && inDoubleQuotes) {
84
+ inDoubleQuotes = false;
85
+ continue;
86
+ }
87
+ if ( (char === "'") && !inSingleQuotes) {
88
+ inSingleQuotes = true;
89
+ continue;
90
+
91
+ } else if ( (char === "'") && inSingleQuotes) {
92
+ inSingleQuotes = false;
93
+ continue;
94
+
95
+ } else if (char === split && !inDoubleQuotes && !inSingleQuotes) {
96
+ // TODO look ahead in order to allow for multi-character seperators
97
+ arr.push(field);
98
+ field = '';
99
+ continue;
100
+
101
+ } else {
102
+ field = field + char;
103
+ }
104
+ }
105
+
106
+ // Add the last field
107
+ arr.push(field);
108
+
109
+ // Now trim each value if necessary
110
+ if (!preserve) {
111
+ for (i=0,len=arr.length; i<len; i+=1) {
112
+ arr[i] = arr[i].trim();
113
+ }
114
+ }
115
+
116
+ return arr;
117
+ };
118
+
119
+
120
+
121
+
122
+ /**
123
+ * This function splits the CSV data into an array so that it can be useful.
124
+ */
125
+ this.fetch = function ()
126
+ {
127
+ var sep = this.seperator,
128
+ eol = this.endofline,
129
+ obj = this;
130
+
131
+ if (this.url.substring(0,3) === 'id:' || this.url.substring(0,4) === 'str:') {
132
+
133
+ // Get rid of any surrounding whitespace
134
+ if (this.url.substring(0,3) === 'id:') {
135
+ var data = document.getElementById(this.url.substring(3)).innerHTML.trim();
136
+
137
+ } else if (this.url.substring(0,4) === 'str:') {
138
+ var data = this.url.substring(4).trim();
139
+ }
140
+
141
+ // Store the CSV data on the CSV object (ie - this object)
142
+ obj.data = data.split(eol);
143
+
144
+ // Store the number of rows
145
+ obj.numrows = obj.data.length;
146
+
147
+ for (var i=0,len=obj.data.length; i<len; i+=1) {
148
+
149
+
150
+ /**
151
+ * Split the individual line
152
+ */
153
+ //var row = obj.data[i].split(sep);
154
+ var row = obj.splitCSV(obj.data[i], {preserve: false, char: sep});
155
+
156
+
157
+ if (!obj.numcols) {
158
+ obj.numcols = row.length;
159
+ }
160
+
161
+ /**
162
+ * If the cell is purely made up of numbers - convert it
163
+ */
164
+ for (var j=0; j<row.length; j+=1) {
165
+ if ((/^\-?[0-9.]+$/).test(row[j])) {
166
+ row[j] = parseFloat(row[j]);
167
+ }
168
+
169
+ // Assign the split-up-row back to the data array
170
+ obj.data[i] = row;
171
+ }
172
+ }
173
+
174
+ // Call the ready function straight away
175
+ obj.ready(obj);
176
+
177
+ } else {
178
+
179
+ RGraph.AJAX.getString(this.url, function (data)
180
+ {
181
+ data = data.replace(/(\r?\n)+$/, '');
182
+
183
+ /**
184
+ * Split the lines in the CSV
185
+ */
186
+ obj.data = data.split(eol);
187
+
188
+ /**
189
+ * Store the number of rows
190
+ */
191
+ obj.numrows = obj.data.length;
192
+
193
+
194
+
195
+ /**
196
+ * Loop thru each lines in the CSV file
197
+ */
198
+ for (var i=0,len=obj.data.length; i<len; i+=1) {
199
+ /**
200
+ * Use the new split function to split each row NOT preserving whitespace
201
+ */
202
+ //var row = obj.data[i].split(sep);
203
+ var row = obj.splitCSV(obj.data[i], {preserve: false, char: sep});
204
+
205
+ if (!obj.numcols) {
206
+ obj.numcols = row.length;
207
+ }
208
+
209
+ /**
210
+ * If the cell is purely made up of numbers - convert it
211
+ */
212
+ for (var j=0; j<row.length; j+=1) {
213
+ if ((/^\-?[0-9.]+$/).test(row[j])) {
214
+ row[j] = parseFloat(row[j]);
215
+ }
216
+
217
+ // Assign the split-up-row back to the data array
218
+ obj.data[i] = row;
219
+ }
220
+ }
221
+
222
+ // Call the ready function straight away
223
+ obj.ready(obj);
224
+ });
225
+ }
226
+ };
227
+
228
+
229
+
230
+
231
+ /**
232
+ * Returns a row of the CSV file
233
+ *
234
+ * @param number index The index of the row to fetch
235
+ * @param start OPTIONAL If desired you can specify a column to start at (which starts at 0 by default)
236
+ */
237
+ this.getRow = function (index)
238
+ {
239
+ var row = [];
240
+ var start = arguments[1] || 0;
241
+
242
+ for (var i=start; i<this.numcols; i+=1) {
243
+ row.push(this.data[index][i]);
244
+ }
245
+
246
+ return row;
247
+ };
248
+
249
+
250
+
251
+
252
+ /**
253
+ * Returns a column of the CSV file
254
+ *
255
+ * @param number index The index of the column to fetch
256
+ * @param start OPTIONAL If desired you can specify a row to start at (which starts at 0 by default)
257
+ */
258
+ this.getCol =
259
+ this.getColumn = function (index)
260
+ {
261
+ var col = [];
262
+ var start = arguments[1] || 0;
263
+
264
+ for (var i=start; i<this.numrows; i+=1) {
265
+ col.push(this.data[i][index]);
266
+ }
267
+
268
+ return col;
269
+ };
270
+
271
+
272
+
273
+
274
+
275
+ // Fetch the CSV file
276
+ this.fetch();
277
+ };
@@ -1,36 +1,451 @@
1
+ // version: 2017-01-02
2
+ /**
3
+ * o--------------------------------------------------------------------------------o
4
+ * | This file is part of the RGraph package - you can learn more at: |
5
+ * | |
6
+ * | http://www.rgraph.net |
7
+ * | |
8
+ * | RGraph is licensed under the Open Source MIT license. That means that it's |
9
+ * | totally free to use! |
10
+ * o--------------------------------------------------------------------------------o
11
+ */
1
12
 
2
- RGraph=window.RGraph||{isRGraph:true};(function(win,doc,undefined)
3
- {var RG=RGraph,ua=navigator.userAgent,ma=Math;RG.text=RG.Text=function(context,font,size,x,y,text)
4
- {var args=arguments;if((typeof(text)!='string'&&typeof(text)!='number')||text=='undefined'){return;}
5
- if(typeof(text)=='string'&&text.match(/\r\n/)){var dimensions=RGraph.MeasureText('M',args[11],font,size);var arr=text.split('\r\n');if(args[6]&&args[6]=='center')y=(y-(dimensions[1]*((arr.length-1)/2)));for(var i=1;i<arr.length;++i){RGraph.Text(context,font,size,args[9]==-90?(x+(size*1.5)):x,y+(dimensions[1]*i),arr[i],args[6]?args[6]:null,args[7],args[8],args[9],args[10],args[11],args[12]);}
6
- text=arr[0];}
7
- if(document.all&&RGraph.ISOLD){y+=2;}
8
- context.font=(args[11]?'Bold ':'')+size+'pt '+font;var i;var origX=x;var origY=y;var originalFillStyle=context.fillStyle;var originalLineWidth=context.lineWidth;if(typeof(args[6])=='undefined')args[6]='bottom';if(typeof(args[7])=='undefined')args[7]='left';if(typeof(args[8])=='undefined')args[8]=null;if(typeof(args[9])=='undefined')args[9]=0;if(navigator.userAgent.indexOf('Opera')!=-1){context.canvas.__rgraph_valign__=args[6];context.canvas.__rgraph_halign__=args[7];}
9
- context.save();context.canvas.__rgraph_originalx__=x;context.canvas.__rgraph_originaly__=y;context.translate(x,y);x=0;y=0;if(args[9]){context.rotate(args[9]/(180/RGraph.PI));}
10
- if(args[6]){var vAlign=args[6];if(vAlign=='center'){context.textBaseline='middle';}else if(vAlign=='top'){context.textBaseline='top';}}
11
- if(args[7]){var hAlign=args[7];var width=context.measureText(text).width;if(hAlign){if(hAlign=='center'){context.textAlign='center';}else if(hAlign=='right'){context.textAlign='right';}}}
12
- context.fillStyle=originalFillStyle;context.save();context.fillText(text,0,0);context.lineWidth=1;var width=context.measureText(text).width;var width_offset=(hAlign=='center'?(width/2):(hAlign=='right'?width:0));var height=size*1.5;var height_offset=(vAlign=='center'?(height/2):(vAlign=='top'?height:0));var ieOffset=RGraph.ISOLD?2:0;if(args[8]){context.strokeRect(-3-width_offset,0-3-height-ieOffset+height_offset,width+6,height+6);if(args[10]){context.fillStyle=args[10];context.fillRect(-3-width_offset,0-3-height-ieOffset+height_offset,width+6,height+6);}
13
- context.fillStyle=originalFillStyle;context.fillText(text,0,0);}
14
- context.restore();context.lineWidth=originalLineWidth;context.restore();};RG.getMouseXY=function(e)
15
- {var el=(RGraph.ISOLD?event.srcElement:e.target);var x;var y;var paddingLeft=el.style.paddingLeft?parseInt(el.style.paddingLeft):0;var paddingTop=el.style.paddingTop?parseInt(el.style.paddingTop):0;var borderLeft=el.style.borderLeftWidth?parseInt(el.style.borderLeftWidth):0;var borderTop=el.style.borderTopWidth?parseInt(el.style.borderTopWidth):0;if(RGraph.ISIE8)e=event;if(typeof(e.offsetX)=='number'&&typeof(e.offsetY)=='number'){x=e.offsetX;y=e.offsetY;}else{x=0;y=0;while(el!=document.body&&el){x+=el.offsetLeft;y+=el.offsetTop;el=el.offsetParent;}
16
- x=e.pageX-x;y=e.pageY-y;}
17
- return[x,y];};RG.oldBrowserCompat=RG.OldBrowserCompat=function(co)
18
- {if(!co){return;}
19
- if(!co.measureText){co.measureText=function(text)
20
- {var textObj=document.createElement('DIV');textObj.innerHTML=text;textObj.style.position='absolute';textObj.style.top='-100px';textObj.style.left=0;document.body.appendChild(textObj);var width={width:textObj.offsetWidth};textObj.style.display='none';return width;}}
21
- if(!co.fillText){co.fillText=function(text,targetX,targetY)
22
- {return false;}}
23
- if(!co.canvas.addEventListener){window.addEventListener=function(ev,func,bubble)
24
- {return this.attachEvent('on'+ev,func);}
25
- co.canvas.addEventListener=function(ev,func,bubble)
26
- {return this.attachEvent('on'+ev,func);}}};RG.each=function(arr,func)
27
- {for(var i=0,len=arr.length;i<len;i+=1){if(typeof arguments[2]!=='undefined'){var ret=func.call(arguments[2],i,arr[i]);}else{var ret=func.call(arr,i,arr[i]);}
28
- if(ret===false){return;}}};RG.getHeight=RG.GetHeight=function(obj)
29
- {return obj.canvas.height;};RG.getWidth=RG.GetWidth=function(obj)
30
- {return obj.canvas.width;};RG.timer=RG.Timer=function(label)
31
- {if(typeof RG.TIMER_LAST_CHECKPOINT=='undefined'){RG.TIMER_LAST_CHECKPOINT=Date.now();}
32
- var now=Date.now();console.log(label+': '+(now-RG.TIMER_LAST_CHECKPOINT).toString());RG.TIMER_LAST_CHECKPOINT=now;};RG.setConfig=RG.SetConfig=function(obj,config)
33
- {for(i in config){if(typeof i==='string'){obj.Set(i,config[i]);}}
34
- return obj;};})(window,document);window.$empty=function(value)
35
- {if(!value||value.length<=0){return true;}
36
- return false;};
13
+ RGraph = window.RGraph || {isRGraph: true};
14
+
15
+ // Module pattern
16
+ (function (win, doc, undefined)
17
+ {
18
+ var RG = RGraph,
19
+ ua = navigator.userAgent,
20
+ ma = Math;
21
+
22
+
23
+
24
+
25
+ /**
26
+ * This is a useful function which is basically a shortcut for drawing left, right, top and bottom alligned text.
27
+ *
28
+ * @param object context The context
29
+ * @param string font The font
30
+ * @param int size The size of the text
31
+ * @param int x The X coordinate
32
+ * @param int y The Y coordinate
33
+ * @param string text The text to draw
34
+ * @parm string The vertical alignment. Can be null. "center" gives center aligned text, "top" gives top aligned text.
35
+ * Anything else produces bottom aligned text. Default is bottom.
36
+ * @param string The horizontal alignment. Can be null. "center" gives center aligned text, "right" gives right aligned text.
37
+ * Anything else produces left aligned text. Default is left.
38
+ * @param bool Whether to show a bounding box around the text. Defaults not to
39
+ * @param int The angle that the text should be rotate at (IN DEGREES)
40
+ * @param string Background color for the text
41
+ * @param bool Whether the text is bold or not
42
+ */
43
+ RG.text =
44
+ RG.Text = function (context, font, size, x, y, text)
45
+ {
46
+ // "Cache" the args as a local variable
47
+ var args = arguments;
48
+
49
+ // Handle undefined - change it to an empty string
50
+ if ((typeof(text) != 'string' && typeof(text) != 'number') || text == 'undefined') {
51
+ return;
52
+ }
53
+
54
+
55
+
56
+
57
+ /**
58
+ * This accommodates multi-line text
59
+ */
60
+ if (typeof(text) == 'string' && text.match(/\r\n/)) {
61
+
62
+ var dimensions = RGraph.MeasureText('M', args[11], font, size);
63
+
64
+ /**
65
+ * Measure the text (width and height)
66
+ */
67
+
68
+ var arr = text.split('\r\n');
69
+
70
+ /**
71
+ * Adjust the Y position
72
+ */
73
+
74
+ // This adjusts the initial y position
75
+ if (args[6] && args[6] == 'center') y = (y - (dimensions[1] * ((arr.length - 1) / 2)));
76
+
77
+ for (var i=1; i<arr.length; ++i) {
78
+
79
+ RGraph.Text(context,
80
+ font,
81
+ size,
82
+ args[9] == -90 ? (x + (size * 1.5)) : x,
83
+ y + (dimensions[1] * i),
84
+ arr[i],
85
+ args[6] ? args[6] : null,
86
+ args[7],
87
+ args[8],
88
+ args[9],
89
+ args[10],
90
+ args[11],
91
+ args[12]);
92
+ }
93
+
94
+ // Update text to just be the first line
95
+ text = arr[0];
96
+ }
97
+
98
+
99
+ // Accommodate MSIE
100
+ if (document.all && RGraph.ISOLD) {
101
+ y += 2;
102
+ }
103
+
104
+
105
+ context.font = (args[11] ? 'Bold ': '') + size + 'pt ' + font;
106
+
107
+ var i;
108
+ var origX = x;
109
+ var origY = y;
110
+ var originalFillStyle = context.fillStyle;
111
+ var originalLineWidth = context.lineWidth;
112
+
113
+ // Need these now the angle can be specified, ie defaults for the former two args
114
+ if (typeof(args[6]) == 'undefined') args[6] = 'bottom'; // Vertical alignment. Default to bottom/baseline
115
+ if (typeof(args[7]) == 'undefined') args[7] = 'left'; // Horizontal alignment. Default to left
116
+ if (typeof(args[8]) == 'undefined') args[8] = null; // Show a bounding box. Useful for positioning during development. Defaults to false
117
+ if (typeof(args[9]) == 'undefined') args[9] = 0; // Angle (IN DEGREES) that the text should be drawn at. 0 is middle right, and it goes clockwise
118
+
119
+ // The alignment is recorded here for purposes of Opera compatibility
120
+ if (navigator.userAgent.indexOf('Opera') != -1) {
121
+ context.canvas.__rgraph_valign__ = args[6];
122
+ context.canvas.__rgraph_halign__ = args[7];
123
+ }
124
+
125
+ // First, translate to x/y coords
126
+ context.save();
127
+
128
+ context.canvas.__rgraph_originalx__ = x;
129
+ context.canvas.__rgraph_originaly__ = y;
130
+
131
+ context.translate(x, y);
132
+ x = 0;
133
+ y = 0;
134
+
135
+ // Rotate the canvas if need be
136
+ if (args[9]) {
137
+ context.rotate(args[9] / (180 / RGraph.PI));
138
+ }
139
+
140
+
141
+ // Vertical alignment - defaults to bottom
142
+ if (args[6]) {
143
+
144
+ var vAlign = args[6];
145
+
146
+ if (vAlign == 'center') {
147
+ context.textBaseline = 'middle';
148
+ } else if (vAlign == 'top') {
149
+ context.textBaseline = 'top';
150
+ }
151
+ }
152
+
153
+
154
+ // Hoeizontal alignment - defaults to left
155
+ if (args[7]) {
156
+
157
+ var hAlign = args[7];
158
+ var width = context.measureText(text).width;
159
+
160
+ if (hAlign) {
161
+ if (hAlign == 'center') {
162
+ context.textAlign = 'center';
163
+ } else if (hAlign == 'right') {
164
+ context.textAlign = 'right';
165
+ }
166
+ }
167
+ }
168
+
169
+
170
+ context.fillStyle = originalFillStyle;
171
+
172
+ /**
173
+ * Draw a bounding box if requested
174
+ */
175
+ context.save();
176
+ context.fillText(text,0,0);
177
+ context.lineWidth = 1;
178
+
179
+ var width = context.measureText(text).width;
180
+ var width_offset = (hAlign == 'center' ? (width / 2) : (hAlign == 'right' ? width : 0));
181
+ var height = size * 1.5; // !!!
182
+ var height_offset = (vAlign == 'center' ? (height / 2) : (vAlign == 'top' ? height : 0));
183
+ var ieOffset = RGraph.ISOLD ? 2 : 0;
184
+
185
+ if (args[8]) {
186
+
187
+ context.strokeRect(-3 - width_offset,
188
+ 0 - 3 - height - ieOffset + height_offset,
189
+ width + 6,
190
+ height + 6);
191
+ /**
192
+ * If requested, draw a background for the text
193
+ */
194
+ if (args[10]) {
195
+ context.fillStyle = args[10];
196
+ context.fillRect(-3 - width_offset,
197
+ 0 - 3 - height - ieOffset + height_offset,
198
+ width + 6,
199
+ height + 6);
200
+ }
201
+
202
+
203
+ context.fillStyle = originalFillStyle;
204
+
205
+
206
+ /**
207
+ * Do the actual drawing of the text
208
+ */
209
+ context.fillText(text,0,0);
210
+ }
211
+ context.restore();
212
+
213
+ // Reset the lineWidth
214
+ context.lineWidth = originalLineWidth;
215
+
216
+ context.restore();
217
+ };
218
+
219
+
220
+
221
+
222
+ /**
223
+ * This function returns the mouse position in relation to the canvas
224
+ *
225
+ * @param object e The event object.
226
+ */
227
+ RG.getMouseXY = function (e)
228
+ {
229
+ var el = (RGraph.ISOLD ? event.srcElement : e.target);
230
+ var x;
231
+ var y;
232
+
233
+ // ???
234
+ var paddingLeft = el.style.paddingLeft ? parseInt(el.style.paddingLeft) : 0;
235
+ var paddingTop = el.style.paddingTop ? parseInt(el.style.paddingTop) : 0;
236
+ var borderLeft = el.style.borderLeftWidth ? parseInt(el.style.borderLeftWidth) : 0;
237
+ var borderTop = el.style.borderTopWidth ? parseInt(el.style.borderTopWidth) : 0;
238
+
239
+ if (RGraph.ISIE8) e = event;
240
+
241
+ // Browser with offsetX and offsetY
242
+ if (typeof(e.offsetX) == 'number' && typeof(e.offsetY) == 'number') {
243
+ x = e.offsetX;
244
+ y = e.offsetY;
245
+
246
+ // FF and other
247
+ } else {
248
+ x = 0;
249
+ y = 0;
250
+
251
+ while (el != document.body && el) {
252
+ x += el.offsetLeft;
253
+ y += el.offsetTop;
254
+
255
+ el = el.offsetParent;
256
+ }
257
+
258
+ x = e.pageX - x;
259
+ y = e.pageY - y;
260
+ }
261
+
262
+ return [x, y];
263
+ };
264
+
265
+
266
+
267
+
268
+ /**
269
+ * This function attempts to "fill in" missing functions from the canvas
270
+ * context object. Only two at the moment - measureText() nd fillText().
271
+ *
272
+ * @param object context The canvas 2D context
273
+ */
274
+ RG.oldBrowserCompat =
275
+ RG.OldBrowserCompat = function (co)
276
+ {
277
+ if (!co) {
278
+ return;
279
+ }
280
+
281
+ if (!co.measureText) {
282
+
283
+ // This emulates the measureText() function
284
+ co.measureText = function (text)
285
+ {
286
+ var textObj = document.createElement('DIV');
287
+ textObj.innerHTML = text;
288
+ textObj.style.position = 'absolute';
289
+ textObj.style.top = '-100px';
290
+ textObj.style.left = 0;
291
+ document.body.appendChild(textObj);
292
+
293
+ var width = {width: textObj.offsetWidth};
294
+
295
+ textObj.style.display = 'none';
296
+
297
+ return width;
298
+ }
299
+ }
300
+
301
+ if (!co.fillText) {
302
+ // This emulates the fillText() method
303
+ co.fillText = function (text, targetX, targetY)
304
+ {
305
+ return false;
306
+ }
307
+ }
308
+
309
+ // If IE8, add addEventListener()
310
+ if (!co.canvas.addEventListener) {
311
+ window.addEventListener = function (ev, func, bubble)
312
+ {
313
+ return this.attachEvent('on' + ev, func);
314
+ }
315
+
316
+ co.canvas.addEventListener = function (ev, func, bubble)
317
+ {
318
+ return this.attachEvent('on' + ev, func);
319
+ }
320
+ }
321
+ };
322
+
323
+
324
+
325
+
326
+ /**
327
+ * Similar to the jQuery each() function - this lets you iterate easily over an array. The 'this' variable is set]
328
+ * to the array in the callback function.
329
+ *
330
+ * @param array arr The array
331
+ * @param function func The function to call
332
+ * @param object Optionally you can specify the object that the "this" variable is set to
333
+ */
334
+ RG.each = function (arr, func)
335
+ {
336
+ for(var i=0, len=arr.length; i<len; i+=1) {
337
+
338
+ if (typeof arguments[2] !== 'undefined') {
339
+ var ret = func.call(arguments[2], i, arr[i]);
340
+ } else {
341
+ var ret = func.call(arr, i, arr[i]);
342
+ }
343
+
344
+ if (ret === false) {
345
+ return;
346
+ }
347
+ }
348
+ };
349
+
350
+
351
+
352
+
353
+ /**
354
+ * An old function the was used before all 4 gutters were added
355
+ *
356
+ * DEPRECATED
357
+ *
358
+ * @param object obj The chart object
359
+ */
360
+ RG.getHeight =
361
+ RG.GetHeight = function (obj)
362
+ {
363
+ return obj.canvas.height;
364
+ };
365
+
366
+
367
+
368
+
369
+ /**
370
+ * An old function the was used before all 4 gutters were added
371
+ *
372
+ * DEPRECATED
373
+ *
374
+ * @param object obj The chart object
375
+ */
376
+ RG.getWidth =
377
+ RG.GetWidth = function (obj)
378
+ {
379
+ return obj.canvas.width;
380
+ };
381
+
382
+
383
+
384
+
385
+ /**
386
+ * A timer function for measuring... time!
387
+ *
388
+ * @param string label A string to associate with this 'checkpoint'
389
+ */
390
+ RG.timer =
391
+ RG.Timer = function (label)
392
+ {
393
+ if(typeof RG.TIMER_LAST_CHECKPOINT == 'undefined') {
394
+
395
+ RG.TIMER_LAST_CHECKPOINT = Date.now();
396
+ }
397
+
398
+ var now = Date.now();
399
+
400
+ console.log(label+': ' + (now - RG.TIMER_LAST_CHECKPOINT).toString());
401
+
402
+ RG.TIMER_LAST_CHECKPOINT = now;
403
+ };
404
+
405
+
406
+
407
+
408
+ /**
409
+ * If you prefer, you can use the SetConfig() method to set the configuration information
410
+ * for your chart. You may find that setting the configuration this way eases reuse.
411
+ *
412
+ * @param object obj The graph object
413
+ * @param object config The graph configuration information
414
+ */
415
+ RG.setConfig =
416
+ RG.SetConfig = function (obj, config)
417
+ {
418
+ for (i in config) {
419
+ if (typeof i === 'string') {
420
+ obj.Set(i, config[i]);
421
+ }
422
+ }
423
+
424
+ return obj;
425
+ };
426
+
427
+
428
+
429
+
430
+ // End module pattern
431
+ })(window, document);
432
+
433
+
434
+
435
+
436
+ /**
437
+ * Checks whether strings or numbers are empty or not. It also
438
+ * handles null or variables set to undefined. If a variable really
439
+ * is undefined - ie it hasn't been declared at all - you need to use
440
+ * "typeof variable" and check the return value - which will be undefined.
441
+ *
442
+ * @param mixed value The variable to check
443
+ */
444
+ window.$empty = function (value)
445
+ {
446
+ if (!value || value.length <= 0) {
447
+ return true;
448
+ }
449
+
450
+ return false;
451
+ };