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