rgraph-rails 1.0.7 → 1.0.8

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