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,37 +1,665 @@
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
+ */
12
+
13
+ /**
14
+ * Having this here means that the RGraph libraries can be included in any order, instead of you having
15
+ * to include the common core library first.
16
+ */
1
17
 
2
- RGraph=window.RGraph||{isRGraph:true};RGraph.Drawing=RGraph.Drawing||{};RGraph.Drawing.Text=function(conf)
3
- {if(typeof conf==='object'&&typeof conf.x==='number'&&typeof conf.y==='number'&&typeof conf.id==='string'){var id=conf.id
4
- var x=conf.x;var y=conf.y;var text=String(conf.text);var parseConfObjectForOptions=true;}else{var id=conf;var x=arguments[1];var y=arguments[2];var text=arguments[3];}
5
- this.id=id;this.canvas=document.getElementById(id);this.context=this.canvas.getContext('2d');this.colorsParsed=false;this.canvas.__object__=this;this.x=x;this.y=y;this.text=String(text);this.coords=[];this.coordsText=[];this.original_colors=[];this.firstDraw=true;this.type='drawing.text';this.isRGraph=true;this.uid=RGraph.CreateUID();this.canvas.uid=this.canvas.uid?this.canvas.uid:RGraph.CreateUID();this.properties={'chart.size':10,'chart.font':'Segoe UI, Arial, Verdana, sans-serif','chart.bold':false,'chart.angle':0,'chart.colors':['black'],'chart.events.click':null,'chart.events.mousemove':null,'chart.highlight.stroke':'#ccc','chart.highlight.fill':'rgba(255,255,255,0.7)','chart.tooltips':null,'chart.tooltips.effect':'fade','chart.tooltips.css.class':'RGraph_tooltip','chart.tooltips.event':'onclick','chart.tooltips.highlight':true,'chart.tooltips.coords.page':false,'chart.bounding':false,'chart.bounding.fill':'rgba(255,255,255,0.7)','chart.bounding.stroke':'#777','chart.bounding.shadow':false,'chart.bounding.shadow.color':'#ccc','chart.bounding.shadow.blur':3,'chart.bounding.shadow.offsetx':3,'chart.bounding.shadow.offsety':3,'chart.marker':false,'chart.halign':'left','chart.valign':'bottom','chart.link':null,'chart.link.target':'_self','chart.link.options':'','chart.text.accessible':true,'chart.text.accessible.overflow':'visible','chart.text.accessible.pointerevents':true,'chart.clearto':'rgba(0,0,0,0)','chart.shadow':false,'chart.shadow.color':'#ccc','chart.shadow.offsetx':2,'chart.shadow.offsety':2,'chart.shadow.blur':3}
6
- if(!this.canvas){alert('[DRAWING.TEXT] No canvas support');return;}
7
- this.$0={};if(!this.canvas.__rgraph_aa_translated__){this.context.translate(0.5,0.5);this.canvas.__rgraph_aa_translated__=true;}
8
- var RG=RGraph,ca=this.canvas,co=ca.getContext('2d'),prop=this.properties,pa2=RG.path2,win=window,doc=document,ma=Math
9
- if(RG.Effects&&typeof RG.Effects.decorate==='function'){RG.Effects.decorate(this);}
10
- this.set=this.Set=function(name)
11
- {var value=typeof arguments[1]==='undefined'?null:arguments[1];if(arguments.length===1&&typeof name==='object'){RG.parseObjectStyleConfig(this,name);return this;}
12
- if(name.substr(0,6)!='chart.'){name='chart.'+name;}
13
- while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
14
- prop[name]=value;return this;};this.get=this.Get=function(name)
15
- {if(name.substr(0,6)!='chart.'){name='chart.'+name;}
16
- while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
17
- return prop[name.toLowerCase()];};this.draw=this.Draw=function()
18
- {RG.fireCustomEvent(this,'onbeforedraw');if(!this.colorsParsed){this.parseColors();this.colorsParsed=true;}
19
- this.coords=[];this.coordsText=[];var dimensions=RG.measureText(this.text,prop['chart.text.bold'],prop['chart.text.font'],prop['chart.text.size']);co.fillStyle=prop['chart.colors'][0];if(prop['chart.shadow']){RG.setShadow(this,prop['chart.shadow.color'],prop['chart.shadow.offsetx'],prop['chart.shadow.offsety'],prop['chart.shadow.blur']);}
20
- var ret=RG.text2(this,{font:prop['chart.font'],size:prop['chart.size'],x:this.x,y:this.y,text:this.text,bold:prop['chart.bold'],angle:prop['chart.angle'],bounding:prop['chart.bounding'],'bounding.fill':prop['chart.bounding.fill'],'bounding.stroke':prop['chart.bounding.stroke'],'bounding.shadow':prop['chart.bounding.shadow'],'bounding.shadow.color':prop['chart.bounding.shadow.color'],'bounding.shadow.blur':prop['chart.bounding.shadow.blur'],'bounding.shadow.offsetx':prop['chart.bounding.shadow.offsetx'],'bounding.shadow.offsety':prop['chart.bounding.shadow.offsety'],marker:prop['chart.marker'],halign:prop['chart.halign'],valign:prop['chart.valign']});if(prop['chart.shadow']){RG.noShadow(this);}
21
- this.coords.push({0:ret.x,'x':ret.x,1:ret.y,'y':ret.y,2:ret.width,'width':ret.width,3:ret.height,'height':ret.height});RG.InstallEventListeners(this);if(this.firstDraw){RG.fireCustomEvent(this,'onfirstdraw');this.firstDraw=false;this.firstDrawFunc();}
22
- RG.FireCustomEvent(this,'ondraw');return this;};this.exec=function(func)
23
- {func(this);return this;};this.getObjectByXY=function(e)
24
- {if(this.getShape(e)){return this;}};this.getShape=function(e)
25
- {var prop=this.properties;var coords=this.coords;var mouseXY=RGraph.getMouseXY(e);var mouseX=mouseXY[0];var mouseY=mouseXY[1];for(var i=0,len=this.coords.length;i<len;i++){var left=coords[i].x;var top=coords[i].y;var width=coords[i].width;var height=coords[i].height;if(mouseX>=left&&mouseX<=(left+width)&&mouseY>=top&&mouseY<=(top+height)){return{0:this,1:left,2:top,3:width,4:height,5:0,'object':this,'x':left,'y':top,'width':width,'height':height,'index':0,'tooltip':prop['chart.tooltips']?prop['chart.tooltips'][0]:null};}}
26
- return null;};this.highlight=this.Highlight=function(shape)
27
- {if(typeof prop['chart.highlight.style']==='function'){(prop['chart.highlight.style'])(shape);}else{RG.Highlight.Rect(this,shape);}};this.parseColors=function()
28
- {if(this.original_colors.length===0){this.original_colors['chart.colors']=RG.array_clone(prop['chart.colors'])[0];this.original_colors['chart.fillstyle']=RG.array_clone(prop['chart.fillstyle']);this.original_colors['chart.strokestyle']=RG.array_clone(prop['chart.strokestyle']);this.original_colors['chart.highlight.stroke']=RG.array_clone(prop['chart.highlight.stroke']);this.original_colors['chart.highlight.fill']=RG.array_clone(prop['chart.highlight.fill']);}
29
- prop['chart.colors'][0]=this.parseSingleColorForGradient(prop['chart.colors'][0]);prop['chart.fillstyle']=this.parseSingleColorForGradient(prop['chart.fillstyle']);prop['chart.strokestyle']=this.parseSingleColorForGradient(prop['chart.strokestyle']);prop['chart.highlight.stroke']=this.parseSingleColorForGradient(prop['chart.highlight.stroke']);prop['chart.highlight.fill']=this.parseSingleColorForGradient(prop['chart.highlight.fill']);};this.reset=function()
30
- {};this.parseSingleColorForGradient=function(color)
31
- {if(!color){return color;}
32
- if(typeof color==='string'&&color.match(/^gradient\((.*)\)$/i)){var parts=RegExp.$1.split(':');var grad=co.createLinearGradient(0,0,ca.width,0);var diff=1/(parts.length-1);grad.addColorStop(0,RGraph.trim(parts[0]));for(var j=1,len=parts.length;j<len;++j){grad.addColorStop(j*diff,RG.trim(parts[j]));}}
33
- return grad?grad:color;};this.on=function(type,func)
34
- {if(type.substr(0,2)!=='on'){type='on'+type;}
35
- if(typeof this[type]!=='function'){this[type]=func;}else{RG.addCustomEventListener(this,type,func);}
36
- return this;};this.firstDrawFunc=function()
37
- {};RG.att(ca);RG.Register(this);if(parseConfObjectForOptions){RG.parseObjectStyleConfig(this,conf.options);}};
18
+ // Define the RGraph global variable
19
+ RGraph = window.RGraph || {isRGraph: true};
20
+ RGraph.Drawing = RGraph.Drawing || {};
21
+
22
+ /**
23
+ * The constructor. This function sets up the object. It takes the ID (the HTML attribute) of the canvas as the
24
+ * first argument, then th X position, the Y position and then the text to show
25
+ *
26
+ * @param string id The canvas tag ID
27
+ * @param number x The X position of the text
28
+ * @param number y The Y position of the text
29
+ * @param number text The text to show
30
+ */
31
+ RGraph.Drawing.Text = function (conf)
32
+ {
33
+ /**
34
+ * Allow for object config style
35
+ */
36
+ if ( typeof conf === 'object'
37
+ && typeof conf.x === 'number'
38
+ && typeof conf.y === 'number'
39
+ && typeof conf.id === 'string') {
40
+
41
+ var id = conf.id
42
+ var x = conf.x;
43
+ var y = conf.y;
44
+ var text = String(conf.text);
45
+
46
+ var parseConfObjectForOptions = true; // Set this so the config is parsed (at the end of the constructor)
47
+
48
+ } else {
49
+
50
+ var id = conf;
51
+ var x = arguments[1];
52
+ var y = arguments[2];
53
+ var text = arguments[3];
54
+ }
55
+
56
+
57
+
58
+
59
+ this.id = id;
60
+ this.canvas = document.getElementById(id);
61
+ this.context = this.canvas.getContext('2d');
62
+ this.colorsParsed = false;
63
+ this.canvas.__object__ = this;
64
+ this.x = x;
65
+ this.y = y;
66
+ this.text = String(text);
67
+ this.coords = [];
68
+ this.coordsText = [];
69
+ this.original_colors = [];
70
+ this.firstDraw = true; // After the first draw this will be false
71
+
72
+
73
+ /**
74
+ * This defines the type of this shape
75
+ */
76
+ this.type = 'drawing.text';
77
+
78
+
79
+ /**
80
+ * This facilitates easy object identification, and should always be true
81
+ */
82
+ this.isRGraph = true;
83
+
84
+
85
+ /**
86
+ * This adds a uid to the object that you can use for identification purposes
87
+ */
88
+ this.uid = RGraph.CreateUID();
89
+
90
+
91
+ /**
92
+ * This adds a UID to the canvas for identification purposes
93
+ */
94
+ this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.CreateUID();
95
+
96
+
97
+
98
+
99
+ /**
100
+ * Some example background properties
101
+ */
102
+ this.properties =
103
+ {
104
+ 'chart.size': 10,
105
+ 'chart.font': 'Segoe UI, Arial, Verdana, sans-serif',
106
+ 'chart.bold': false,
107
+ 'chart.angle': 0,
108
+ 'chart.colors': ['black'],
109
+ 'chart.events.click': null,
110
+ 'chart.events.mousemove': null,
111
+ 'chart.highlight.stroke': '#ccc',
112
+ 'chart.highlight.fill': 'rgba(255,255,255,0.7)',
113
+ 'chart.tooltips': null,
114
+ 'chart.tooltips.effect': 'fade',
115
+ 'chart.tooltips.css.class': 'RGraph_tooltip',
116
+ 'chart.tooltips.event': 'onclick',
117
+ 'chart.tooltips.highlight': true,
118
+ 'chart.tooltips.coords.page': false,
119
+ 'chart.bounding': false,
120
+ 'chart.bounding.fill': 'rgba(255,255,255,0.7)',
121
+ 'chart.bounding.stroke': '#777',
122
+ 'chart.bounding.shadow': false,
123
+ 'chart.bounding.shadow.color': '#ccc',
124
+ 'chart.bounding.shadow.blur': 3,
125
+ 'chart.bounding.shadow.offsetx': 3,
126
+ 'chart.bounding.shadow.offsety': 3,
127
+ 'chart.marker': false,
128
+ 'chart.halign': 'left',
129
+ 'chart.valign': 'bottom',
130
+ 'chart.link': null,
131
+ 'chart.link.target': '_self',
132
+ 'chart.link.options': '',
133
+ 'chart.text.accessible': true,
134
+ 'chart.text.accessible.overflow': 'visible',
135
+ 'chart.text.accessible.pointerevents': true,
136
+ 'chart.clearto': 'rgba(0,0,0,0)',
137
+ 'chart.shadow': false,
138
+ 'chart.shadow.color': '#ccc',
139
+ 'chart.shadow.offsetx': 2,
140
+ 'chart.shadow.offsety': 2,
141
+ 'chart.shadow.blur': 3
142
+ }
143
+
144
+ /**
145
+ * A simple check that the browser has canvas support
146
+ */
147
+ if (!this.canvas) {
148
+ alert('[DRAWING.TEXT] No canvas support');
149
+ return;
150
+ }
151
+
152
+ /**
153
+ * Create the dollar object so that functions can be added to them
154
+ */
155
+ this.$0 = {};
156
+
157
+
158
+ /**
159
+ * Translate half a pixel for antialiasing purposes - but only if it hasn't beeen
160
+ * done already
161
+ */
162
+ if (!this.canvas.__rgraph_aa_translated__) {
163
+ this.context.translate(0.5,0.5);
164
+
165
+ this.canvas.__rgraph_aa_translated__ = true;
166
+ }
167
+
168
+
169
+
170
+
171
+
172
+
173
+ // Short variable names
174
+ var RG = RGraph,
175
+ ca = this.canvas,
176
+ co = ca.getContext('2d'),
177
+ prop = this.properties,
178
+ pa2 = RG.path2,
179
+ win = window,
180
+ doc = document,
181
+ ma = Math
182
+
183
+
184
+
185
+ /**
186
+ * "Decorate" the object with the generic effects if the effects library has been included
187
+ */
188
+ if (RG.Effects && typeof RG.Effects.decorate === 'function') {
189
+ RG.Effects.decorate(this);
190
+ }
191
+
192
+
193
+
194
+
195
+
196
+ /**
197
+ * A setter method for setting properties.
198
+ *
199
+ * @param name string The name of the property to set OR it can be a map
200
+ * of name/value settings like what you set in the constructor
201
+ */
202
+ this.set =
203
+ this.Set = function (name)
204
+ {
205
+ var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
206
+
207
+ /**
208
+ * the number of arguments is only one and it's an
209
+ * object - parse it for configuration data and return.
210
+ */
211
+ if (arguments.length === 1 && typeof name === 'object') {
212
+ RG.parseObjectStyleConfig(this, name);
213
+ return this;
214
+ }
215
+
216
+
217
+
218
+
219
+
220
+ /**
221
+ * This should be done first - prepend the property name with "chart." if necessary
222
+ */
223
+ if (name.substr(0,6) != 'chart.') {
224
+ name = 'chart.' + name;
225
+ }
226
+
227
+
228
+
229
+
230
+ // Convert uppercase letters to dot+lower case letter
231
+ while(name.match(/([A-Z])/)) {
232
+ name = name.replace(/([A-Z])/, '.' + RegExp.$1.toLowerCase());
233
+ }
234
+
235
+
236
+
237
+
238
+
239
+
240
+ prop[name] = value;
241
+
242
+ return this;
243
+ };
244
+
245
+
246
+
247
+
248
+ /**
249
+ * A getter method for retrieving graph properties. It can be used like this: obj.Get('chart.strokestyle');
250
+ *
251
+ * @param name string The name of the property to get
252
+ */
253
+ this.get =
254
+ this.Get = function (name)
255
+ {
256
+ /**
257
+ * This should be done first - prepend the property name with "chart." if necessary
258
+ */
259
+ if (name.substr(0,6) != 'chart.') {
260
+ name = 'chart.' + name;
261
+ }
262
+
263
+ // Convert uppercase letters to dot+lower case letter
264
+ while(name.match(/([A-Z])/)) {
265
+ name = name.replace(/([A-Z])/, '.' + RegExp.$1.toLowerCase());
266
+ }
267
+
268
+ return prop[name.toLowerCase()];
269
+ };
270
+
271
+
272
+
273
+
274
+ /**
275
+ * Draws the rectangle
276
+ */
277
+ this.draw =
278
+ this.Draw = function ()
279
+ {
280
+ /**
281
+ * Fire the onbeforedraw event
282
+ */
283
+ RG.fireCustomEvent(this, 'onbeforedraw');
284
+
285
+
286
+ /**
287
+ * Parse the colors. This allows for simple gradient syntax
288
+ */
289
+ if (!this.colorsParsed) {
290
+
291
+ this.parseColors();
292
+
293
+ // Don't want to do this again
294
+ this.colorsParsed = true;
295
+ }
296
+
297
+
298
+ /**
299
+ * Stop the coods array from growing
300
+ */
301
+ this.coords = [];
302
+
303
+
304
+
305
+ /**
306
+ * Stop this growing uncntrollably
307
+ */
308
+ this.coordsText = [];
309
+
310
+
311
+
312
+
313
+ /**
314
+ * The font, its size and whether its bold or not can be set by properties,
315
+ * so now they have been (potentiall) set - measure the text
316
+ */
317
+ /**
318
+ * Measure the text and add the width/height
319
+ *
320
+ * text, bold, font, size
321
+ *
322
+ */
323
+ var dimensions = RG.measureText(this.text, prop['chart.text.bold'],prop['chart.text.font'], prop['chart.text.size']);
324
+
325
+
326
+
327
+ // ------------- DRAW TEXT HERE -------------
328
+ co.fillStyle = prop['chart.colors'][0];
329
+
330
+ // Shadow
331
+ if (prop['chart.shadow']) {
332
+ RG.setShadow(
333
+ this,
334
+ prop['chart.shadow.color'],
335
+ prop['chart.shadow.offsetx'],
336
+ prop['chart.shadow.offsety'],
337
+ prop['chart.shadow.blur']
338
+ );
339
+ }
340
+
341
+ var ret = RG.text2(this, {
342
+ font: prop['chart.font'],
343
+ size: prop['chart.size'],
344
+ x: this.x,
345
+ y: this.y,
346
+ text: this.text,
347
+ bold: prop['chart.bold'],
348
+ angle: prop['chart.angle'],
349
+ bounding: prop['chart.bounding'],
350
+ 'bounding.fill': prop['chart.bounding.fill'],
351
+ 'bounding.stroke': prop['chart.bounding.stroke'],
352
+ 'bounding.shadow': prop['chart.bounding.shadow'],
353
+ 'bounding.shadow.color': prop['chart.bounding.shadow.color'],
354
+ 'bounding.shadow.blur': prop['chart.bounding.shadow.blur'],
355
+ 'bounding.shadow.offsetx': prop['chart.bounding.shadow.offsetx'],
356
+ 'bounding.shadow.offsety': prop['chart.bounding.shadow.offsety'],
357
+ marker: prop['chart.marker'],
358
+ halign: prop['chart.halign'],
359
+ valign: prop['chart.valign']
360
+ });
361
+
362
+
363
+ // Shadow
364
+ if (prop['chart.shadow']) {
365
+ RG.noShadow(this);
366
+ }
367
+
368
+
369
+
370
+ // store the dimensions
371
+ this.coords.push({
372
+ 0: ret.x, 'x': ret.x,
373
+ 1: ret.y, 'y': ret.y,
374
+ 2: ret.width, 'width': ret.width,
375
+ 3: ret.height, 'height': ret.height
376
+ });
377
+
378
+
379
+
380
+ /**
381
+ * This installs the event listeners
382
+ */
383
+ RG.InstallEventListeners(this);
384
+
385
+
386
+ /**
387
+ * Fire the onfirstdraw event
388
+ */
389
+ if (this.firstDraw) {
390
+ RG.fireCustomEvent(this, 'onfirstdraw');
391
+ this.firstDraw = false;
392
+ this.firstDrawFunc();
393
+ }
394
+
395
+
396
+
397
+
398
+ /**
399
+ * Fire the ondraw event
400
+ */
401
+ RG.FireCustomEvent(this, 'ondraw');
402
+
403
+ return this;
404
+ };
405
+
406
+
407
+
408
+ /**
409
+ * Used in chaining. Runs a function there and then - not waiting for
410
+ * the events to fire (eg the onbeforedraw event)
411
+ *
412
+ * @param function func The function to execute
413
+ */
414
+ this.exec = function (func)
415
+ {
416
+ func(this);
417
+
418
+ return this;
419
+ };
420
+
421
+
422
+
423
+
424
+ /**
425
+ * The getObjectByXY() worker method
426
+ */
427
+ this.getObjectByXY = function (e)
428
+ {
429
+ if (this.getShape(e)) {
430
+ return this;
431
+ }
432
+ };
433
+
434
+
435
+
436
+
437
+ /**
438
+ * Not used by the class during creating the graph, but is used by event handlers
439
+ * to get the coordinates (if any) of the selected bar
440
+ *
441
+ * @param object e The event object
442
+ */
443
+ this.getShape = function (e)
444
+ {
445
+ var prop = this.properties;
446
+ var coords = this.coords;
447
+ var mouseXY = RGraph.getMouseXY(e);
448
+ var mouseX = mouseXY[0];
449
+ var mouseY = mouseXY[1];
450
+
451
+ for (var i=0,len=this.coords.length; i<len; i++) {
452
+
453
+ var left = coords[i].x;
454
+ var top = coords[i].y;
455
+ var width = coords[i].width;
456
+ var height = coords[i].height;
457
+
458
+ if (mouseX >= left && mouseX <= (left + width) && mouseY >= top && mouseY <= (top + height)) {
459
+
460
+ return {
461
+ 0: this, 1: left, 2: top, 3: width, 4: height, 5: 0,
462
+ 'object': this, 'x': left, 'y': top, 'width': width, 'height': height, 'index': 0, 'tooltip': prop['chart.tooltips'] ? prop['chart.tooltips'][0] : null
463
+ };
464
+ }
465
+ }
466
+
467
+ return null;
468
+ };
469
+
470
+
471
+
472
+
473
+ /**
474
+ * This function positions a tooltip when it is displayed
475
+ *
476
+ * @param obj object The chart object
477
+ * @param int x The X coordinate specified for the tooltip
478
+ * @param int y The Y coordinate specified for the tooltip
479
+ * @param objec tooltip The tooltips DIV element
480
+ *
481
+ this.positionTooltip = function (obj, x, y, tooltip, idx)
482
+ {
483
+ var coords = obj.coords[0];
484
+ var coordX = parseFloat(coords.x);
485
+ var coordY = parseFloat(coords.y);
486
+ var coordW = coords.width;
487
+ var coordH = coords.height;
488
+ var canvasXY = RG.getCanvasXY(obj.canvas);
489
+ var mouseXY = RG.getMouseXY(window.event);
490
+ var width = tooltip.offsetWidth;
491
+ var height = tooltip.offsetHeight;
492
+
493
+ // Set the top position
494
+ tooltip.style.left = 0;
495
+ tooltip.style.top = window.event.pageY - height - 5 + 'px';
496
+
497
+ // By default any overflow is hidden
498
+ tooltip.style.overflow = '';
499
+
500
+ // Reposition the tooltip if at the edges:
501
+
502
+ // LEFT edge
503
+ if (canvasXY[0] + mouseXY[0] - (width / 2) < 0) {
504
+ tooltip.style.left = canvasXY[0] + mouseXY[0] - (width * 0.1) + 'px';
505
+
506
+ // RIGHT edge
507
+ } else if (canvasXY[0] + mouseXY[0] + (width / 2) > doc.body.offsetWidth) {
508
+ tooltip.style.left = canvasXY[0] + mouseXY[0] - (width * 0.9) + 'px';
509
+
510
+ // Default positioning - CENTERED
511
+ } else {
512
+ tooltip.style.left = canvasXY[0] + mouseXY[0] - (width / 2) + 'px';
513
+ }
514
+ };*/
515
+
516
+
517
+
518
+
519
+ /**
520
+ * Each object type has its own Highlight() function which highlights the appropriate shape
521
+ *
522
+ * @param object shape The shape to highlight
523
+ */
524
+ this.highlight =
525
+ this.Highlight = function (shape)
526
+ {
527
+ if (typeof prop['chart.highlight.style'] === 'function') {
528
+ (prop['chart.highlight.style'])(shape);
529
+ } else {
530
+ RG.Highlight.Rect(this, shape);
531
+ }
532
+ };
533
+
534
+
535
+
536
+
537
+ /**
538
+ * This allows for easy specification of gradients
539
+ */
540
+ this.parseColors = function ()
541
+ {
542
+ // Save the original colors so that they can be restored when the canvas is reset
543
+ if (this.original_colors.length === 0) {
544
+ this.original_colors['chart.colors'] = RG.array_clone(prop['chart.colors'])[0];
545
+ this.original_colors['chart.fillstyle'] = RG.array_clone(prop['chart.fillstyle']);
546
+ this.original_colors['chart.strokestyle'] = RG.array_clone(prop['chart.strokestyle']);
547
+ this.original_colors['chart.highlight.stroke'] = RG.array_clone(prop['chart.highlight.stroke']);
548
+ this.original_colors['chart.highlight.fill'] = RG.array_clone(prop['chart.highlight.fill']);
549
+ }
550
+
551
+
552
+
553
+
554
+ /**
555
+ * Parse various properties for colors
556
+ */
557
+ prop['chart.colors'][0] = this.parseSingleColorForGradient(prop['chart.colors'][0]);
558
+ prop['chart.fillstyle'] = this.parseSingleColorForGradient(prop['chart.fillstyle']);
559
+ prop['chart.strokestyle'] = this.parseSingleColorForGradient(prop['chart.strokestyle']);
560
+ prop['chart.highlight.stroke'] = this.parseSingleColorForGradient(prop['chart.highlight.stroke']);
561
+ prop['chart.highlight.fill'] = this.parseSingleColorForGradient(prop['chart.highlight.fill']);
562
+ };
563
+
564
+
565
+
566
+
567
+ /**
568
+ * Use this function to reset the object to the post-constructor state. Eg reset colors if
569
+ * need be etc
570
+ */
571
+ this.reset = function ()
572
+ {
573
+ };
574
+
575
+
576
+
577
+
578
+ /**
579
+ * This parses a single color value
580
+ */
581
+ this.parseSingleColorForGradient = function (color)
582
+ {
583
+ if (!color) {
584
+ return color;
585
+ }
586
+
587
+ if (typeof color === 'string' && color.match(/^gradient\((.*)\)$/i)) {
588
+
589
+ var parts = RegExp.$1.split(':');
590
+
591
+ // Create the gradient
592
+ var grad = co.createLinearGradient(0,0,ca.width,0);
593
+
594
+ var diff = 1 / (parts.length - 1);
595
+
596
+ grad.addColorStop(0, RGraph.trim(parts[0]));
597
+
598
+ for (var j=1,len=parts.length; j<len; ++j) {
599
+ grad.addColorStop(j * diff, RG.trim(parts[j]));
600
+ }
601
+ }
602
+
603
+ return grad ? grad : color;
604
+ };
605
+
606
+
607
+
608
+
609
+ /**
610
+ * Using a function to add events makes it easier to facilitate method chaining
611
+ *
612
+ * @param string type The type of even to add
613
+ * @param function func
614
+ */
615
+ this.on = function (type, func)
616
+ {
617
+ if (type.substr(0,2) !== 'on') {
618
+ type = 'on' + type;
619
+ }
620
+
621
+ if (typeof this[type] !== 'function') {
622
+ this[type] = func;
623
+ } else {
624
+ RG.addCustomEventListener(this, type, func);
625
+ }
626
+
627
+ return this;
628
+ };
629
+
630
+
631
+
632
+
633
+ /**
634
+ * This function runs once only
635
+ * (put at the end of the file (before any effects))
636
+ */
637
+ this.firstDrawFunc = function ()
638
+ {
639
+ };
640
+
641
+
642
+
643
+
644
+ RG.att(ca);
645
+
646
+
647
+
648
+
649
+
650
+ /**
651
+ * Objects are now always registered so that the chart is redrawn if need be.
652
+ */
653
+ RG.Register(this);
654
+
655
+
656
+
657
+
658
+ /**
659
+ * This is the 'end' of the constructor so if the first argument
660
+ * contains configuration data - handle that.
661
+ */
662
+ if (parseConfObjectForOptions) {
663
+ RG.parseObjectStyleConfig(this, conf.options);
664
+ }
665
+ };