rgraph-rails 5.00 → 6.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/publish-geml.yaml +46 -0
  3. data/.gitignore +1 -0
  4. data/README.md +4 -5
  5. data/lib/rgraph-rails/version.rb +1 -1
  6. data/rgraph-rails.gemspec +4 -4
  7. data/vendor/assets/javascripts/RGraph.activity.js +1691 -0
  8. data/vendor/assets/javascripts/RGraph.bar.js +4253 -236
  9. data/vendor/assets/javascripts/RGraph.bipolar.js +3958 -162
  10. data/vendor/assets/javascripts/RGraph.common.annotate.js +414 -35
  11. data/vendor/assets/javascripts/RGraph.common.context.js +635 -30
  12. data/vendor/assets/javascripts/RGraph.common.core.js +10485 -419
  13. data/vendor/assets/javascripts/RGraph.common.csv.js +508 -27
  14. data/vendor/assets/javascripts/RGraph.common.dynamic.js +1693 -90
  15. data/vendor/assets/javascripts/RGraph.common.effects.js +1629 -89
  16. data/vendor/assets/javascripts/RGraph.common.key.js +1003 -53
  17. data/vendor/assets/javascripts/RGraph.common.moment.js +5670 -0
  18. data/vendor/assets/javascripts/RGraph.common.sheets.js +541 -31
  19. data/vendor/assets/javascripts/RGraph.common.sheets.php +351 -0
  20. data/vendor/assets/javascripts/RGraph.common.starburst.js +382 -0
  21. data/vendor/assets/javascripts/RGraph.common.table.js +386 -0
  22. data/vendor/assets/javascripts/RGraph.common.tooltips.js +1433 -32
  23. data/vendor/assets/javascripts/RGraph.drawing.background.js +660 -35
  24. data/vendor/assets/javascripts/RGraph.drawing.circle.js +618 -34
  25. data/vendor/assets/javascripts/RGraph.drawing.image.js +857 -52
  26. data/vendor/assets/javascripts/RGraph.drawing.line.js +712 -0
  27. data/vendor/assets/javascripts/RGraph.drawing.marker1.js +760 -38
  28. data/vendor/assets/javascripts/RGraph.drawing.marker2.js +740 -37
  29. data/vendor/assets/javascripts/RGraph.drawing.marker3.js +573 -36
  30. data/vendor/assets/javascripts/RGraph.drawing.poly.js +667 -36
  31. data/vendor/assets/javascripts/RGraph.drawing.rect.js +638 -34
  32. data/vendor/assets/javascripts/RGraph.drawing.text.js +672 -37
  33. data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +653 -52
  34. data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +714 -51
  35. data/vendor/assets/javascripts/RGraph.fuel.js +1149 -59
  36. data/vendor/assets/javascripts/RGraph.funnel.js +1277 -56
  37. data/vendor/assets/javascripts/RGraph.gantt.js +1646 -82
  38. data/vendor/assets/javascripts/RGraph.gauge.js +1773 -89
  39. data/vendor/assets/javascripts/RGraph.hbar.js +3869 -159
  40. data/vendor/assets/javascripts/RGraph.horseshoe.js +970 -0
  41. data/vendor/assets/javascripts/RGraph.hprogress.js +1829 -81
  42. data/vendor/assets/javascripts/RGraph.line.js +5293 -244
  43. data/vendor/assets/javascripts/RGraph.meter.js +1570 -77
  44. data/vendor/assets/javascripts/RGraph.modaldialog.js +300 -19
  45. data/vendor/assets/javascripts/RGraph.odo.js +1553 -68
  46. data/vendor/assets/javascripts/RGraph.pie.js +3273 -129
  47. data/vendor/assets/javascripts/RGraph.radar.js +2333 -108
  48. data/vendor/assets/javascripts/RGraph.rose.js +2685 -114
  49. data/vendor/assets/javascripts/RGraph.rscatter.js +1920 -80
  50. data/vendor/assets/javascripts/RGraph.scatter.js +4215 -171
  51. data/vendor/assets/javascripts/RGraph.segmented.js +1006 -0
  52. data/vendor/assets/javascripts/RGraph.semicircularprogress.js +1980 -59
  53. data/vendor/assets/javascripts/RGraph.svg.activity.js +1696 -0
  54. data/vendor/assets/javascripts/RGraph.svg.bar.js +2575 -77
  55. data/vendor/assets/javascripts/RGraph.svg.bipolar.js +3533 -106
  56. data/vendor/assets/javascripts/RGraph.svg.common.ajax.js +240 -21
  57. data/vendor/assets/javascripts/RGraph.svg.common.core.js +7105 -299
  58. data/vendor/assets/javascripts/RGraph.svg.common.csv.js +408 -28
  59. data/vendor/assets/javascripts/RGraph.svg.common.fx.js +1291 -68
  60. data/vendor/assets/javascripts/RGraph.svg.common.key.js +451 -20
  61. data/vendor/assets/javascripts/RGraph.svg.common.sheets.js +543 -31
  62. data/vendor/assets/javascripts/RGraph.svg.common.table.js +391 -0
  63. data/vendor/assets/javascripts/RGraph.svg.common.tooltips.js +1072 -23
  64. data/vendor/assets/javascripts/RGraph.svg.funnel.js +1151 -32
  65. data/vendor/assets/javascripts/RGraph.svg.gauge.js +1429 -34
  66. data/vendor/assets/javascripts/RGraph.svg.hbar.js +2692 -65
  67. data/vendor/assets/javascripts/RGraph.svg.horseshoe.js +969 -0
  68. data/vendor/assets/javascripts/RGraph.svg.line.js +2855 -86
  69. data/vendor/assets/javascripts/RGraph.svg.pie.js +1630 -58
  70. data/vendor/assets/javascripts/RGraph.svg.radar.js +1772 -58
  71. data/vendor/assets/javascripts/RGraph.svg.rose.js +2419 -83
  72. data/vendor/assets/javascripts/RGraph.svg.scatter.js +2280 -65
  73. data/vendor/assets/javascripts/RGraph.svg.segmented.js +930 -0
  74. data/vendor/assets/javascripts/RGraph.svg.semicircularprogress.js +1612 -29
  75. data/vendor/assets/javascripts/RGraph.svg.waterfall.js +1525 -50
  76. data/vendor/assets/javascripts/RGraph.thermometer.js +1411 -64
  77. data/vendor/assets/javascripts/RGraph.vprogress.js +1915 -81
  78. data/vendor/assets/javascripts/RGraph.waterfall.js +1896 -89
  79. data/vendor/assets/javascripts/financial-data.js +1067 -0
  80. metadata +37 -16
  81. data/.travis.yml +0 -11
  82. data/vendor/assets/javascripts/RGraph.common.deprecated.js +0 -35
  83. data/vendor/assets/javascripts/RGraph.common.resizing.js +0 -38
  84. data/vendor/assets/javascripts/RGraph.common.zoom.js +0 -15
  85. data/vendor/assets/javascripts/RGraph.cornergauge.js +0 -71
@@ -1,38 +1,741 @@
1
+ 'version:2023-09-16 (6.14)';
2
+ //
3
+ // o--------------------------------------------------------------------------------o
4
+ // | This file is part of the RGraph package - you can learn more at: |
5
+ // | |
6
+ // | https://www.rgraph.net |
7
+ // | |
8
+ // | RGraph is licensed under the Open Source MIT license. That means that it's |
9
+ // | totally free to use and there are no restrictions on what you can do with it! |
10
+ // o--------------------------------------------------------------------------------o
11
+
12
+ //
13
+ // Having this here means that the RGraph libraries can be included in any order, instead of you having
14
+ // to include the common core library first.
15
+ //
1
16
 
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,canvas=document.getElementById(id),x=conf.x,y=conf.y,text=conf.text,parseConfObjectForOptions=true;}else{var id=conf,canvas=document.getElementById(id),x=arguments[1],y=arguments[2],text=arguments[3];}
4
- this.id=id;this.canvas=document.getElementById(this.id);this.context=this.canvas.getContext('2d')
5
- this.colorsParsed=false;this.canvas.__object__=this;this.original_colors=[];this.firstDraw=true;this.propertyNameAliases={};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.colors.stroke':'black','chart.colors.fill':'white','chart.text.color':'black','chart.text.size':12,'chart.text.font':'Arial, Verdana, sans-serif','chart.text.bold':false,'chart.text.italic':false,'chart.text.accessible':true,'chart.text.accessible.overflow':'visible','chart.text.accessible.pointerevents':false,'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.style':null,'chart.highlight.stroke':'rgba(0,0,0,0)','chart.highlight.fill':'#fcc','chart.tooltips':null,'chart.tooltips.highlight':true,'chart.tooltips.event':'onclick','chart.voffset':20,'chart.clearto':'rgba(0,0,0,0)'}
6
- if(!this.canvas){alert('[DRAWING.MARKER2] No canvas support');return;}
7
- 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;}
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
- {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;}
19
- if(!this.colorsParsed){this.parseColors();this.colorsParsed=true;}
20
- var x=this.alignRight?this.x-this.metrics[0]-6:this.x,y=this.y-6-prop['chart.voffset']-this.metrics[1],width=this.metrics[0]+6,height=this.metrics[1];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']);}
21
- co.strokeStyle=prop['chart.colors.stroke'];co.fillStyle=prop['chart.colors.fill'];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'],color:prop['chart.text.color'],bold:prop['chart.text.bold'],italic:prop['chart.text.italic'],x:ma.round(this.x)-(this.alignRight?this.metrics[0]+3:-3),y:y+(height/2),text:this.text,valign:'center',halign:'left',tag:'labels'});this.coords[0].push([x,y,width,height]);RG.noShadow(this);co.textBaseline='alphabetic';RG.installEventListeners(this);if(this.firstDraw){this.firstDraw=false;RG.fireCustomEvent(this,'onfirstdraw');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),mouseX=mouseXY[0],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};}}
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{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']]);pa2(co,'b r % % % % f % s %',this.coords[0][0],this.coords[0][1],this.coords[0][2],this.coords[0][3],prop['chart.highlight.fill'],prop['chart.highlight.stroke']);}}};this.parseColors=function()
28
- {if(this.original_colors.length===0){this.original_colors['chart.colors.fill']=RG.arrayClone(prop['chart.colors.fill']);this.original_colors['chart.colors.stroke']=RG.arrayClone(prop['chart.colors.stroke']);this.original_colors['chart.highlight.fill']=RG.arrayClone(prop['chart.highlight.fill']);this.original_colors['chart.highlight.stroke']=RG.arrayClone(prop['chart.highlight.stroke']);this.original_colors['chart.text.color']=RG.arrayClone(prop['chart.text.color']);}
29
- prop['chart.colors.fill']=this.parseSingleColorForGradient(prop['chart.colors.fill']);prop['chart.colors.stroke']=this.parseSingleColorForGradient(prop['chart.colors.stroke']);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()
30
- {};this.parseSingleColorForGradient=function(color)
31
- {if(!color){return color;}
32
- if(typeof color==='string'&&color.match(/^gradient\((.*)\)$/i)){if(color.match(/^gradient\(({.*})\)$/i)){return RGraph.parseJSONGradient({object:this,def:RegExp.$1});}
33
- var parts=RegExp.$1.split(':'),grad=co.createLinearGradient(this.x,this.y,this.x+this.metrics[0],this.y),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.register(this);if(parseConfObjectForOptions){RG.parseObjectStyleConfig(this,conf.options);}};
17
+ // Define the RGraph global variable
18
+ RGraph = window.RGraph || {isrgraph:true,isRGraph: true,rgraph:true};
19
+ RGraph.Drawing = RGraph.Drawing || {};
20
+
21
+ //
22
+ // The constructor. This function sets up the object.
23
+ //
24
+ RGraph.Drawing.Marker2 = function (conf)
25
+ {
26
+ var id = conf.id,
27
+ canvas = document.getElementById(id),
28
+ x = conf.x,
29
+ y = conf.y,
30
+ text = conf.text;
31
+
32
+ this.id = id;
33
+ this.canvas = document.getElementById(this.id);
34
+ this.context = this.canvas.getContext('2d')
35
+ this.colorsParsed = false;
36
+ this.canvas.__object__ = this;
37
+ this.original_colors = [];
38
+ this.firstDraw = true; // After the first draw this will be false
39
+
40
+ //
41
+ // Store the properties
42
+ //
43
+ this.x = x;
44
+ this.y = y;
45
+ this.text = text;
46
+
47
+
48
+ //
49
+ // This defines the type of this shape
50
+ //
51
+ this.type = 'drawing.marker2';
52
+
53
+
54
+ //
55
+ // This facilitates easy object identification, and should always be true
56
+ //
57
+ this.isRGraph = true;
58
+ this.isrgraph = true;
59
+ this.rgraph = true;
60
+
61
+
62
+ //
63
+ // This adds a uid to the object that you can use for identification purposes
64
+ //
65
+ this.uid = RGraph.createUID();
66
+
67
+
68
+ //
69
+ // This adds a UID to the canvas for identification purposes
70
+ //
71
+ this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.createUID();
72
+
73
+
74
+ //
75
+ // Some example background properties
76
+ //
77
+ this.properties =
78
+ {
79
+ colorsStroke: 'black',
80
+ colorsFill: 'white',
81
+
82
+ textColor: 'black',
83
+ textSize: 12,
84
+ textFont: 'Arial, Verdana, sans-serif',
85
+ textBold: false,
86
+ textItalic: false,
87
+ textAccessible: false,
88
+ textAccessibleOverflow: 'visible',
89
+ textAccessiblePointerevents: false,
90
+ text: null,
91
+
92
+ shadow: true,
93
+ shadowColor: 'gray',
94
+ shadowOffsetx: 3,
95
+ shadowOffsety: 3,
96
+ shadowBlur: 5,
97
+
98
+ highlightStyle: null,
99
+ highlightStroke: 'rgba(0,0,0,0)',
100
+ highlightFill: '#fcc',
101
+
102
+ tooltips: null,
103
+ tooltipsHighlight: true,
104
+ tooltipsCssClass: 'RGraph_tooltip',
105
+ tooltipsCss: null,
106
+ tooltipsEffect: 'slide',
107
+ tooltipsEvent: 'onclick',
108
+ tooltipsFormattedPoint: '.',
109
+ tooltipsFormattedThousand: ',',
110
+ tooltipsFormattedDecimals: 0,
111
+ tooltipsFormattedUnitsPre: '',
112
+ tooltipsFormattedUnitsPost: '',
113
+ tooltipsFormattedListType: 'ul',
114
+ tooltipsFormattedListItems: null,
115
+ tooltipsPointer: true,
116
+ tooltipsPointerOffsetx: 0,
117
+ tooltipsPointerOffsety: 0,
118
+ tooltipsPositionStatic: true,
119
+
120
+ voffset: 20,
121
+
122
+ clearto: 'rgba(0,0,0,0)'
123
+ }
124
+
125
+ //
126
+ // A simple check that the browser has canvas support
127
+ //
128
+ if (!this.canvas) {
129
+ alert('[DRAWING.MARKER2] No canvas support');
130
+ return;
131
+ }
132
+
133
+ //
134
+ // These are used to store coords
135
+ //
136
+ this.coords = [];
137
+ this.coordsText = [];
138
+
139
+
140
+ //
141
+ // Create the dollar object so that functions can be added to them
142
+ //
143
+ this.$0 = {};
144
+
145
+
146
+
147
+
148
+ // Easy access to properties and the path function
149
+ var properties = this.properties;
150
+ this.path = RGraph.pathObjectFunction;
151
+
152
+
153
+
154
+ //
155
+ // "Decorate" the object with the generic effects if the effects library has been included
156
+ //
157
+ if (RGraph.Effects && typeof RGraph.Effects.decorate === 'function') {
158
+ RGraph.Effects.decorate(this);
159
+ }
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+ //
169
+ // A setter method for setting graph properties. It can be used like this: obj.set('colorsStroke', '#666');
170
+ //
171
+
172
+ // @param name string The name of the property to set OR it can be a map
173
+ // of name/value settings like what you set in the constructor
174
+ //
175
+ this.set = function (name)
176
+ {
177
+ var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
178
+
179
+ // the number of arguments is only one and it's an
180
+ // object - parse it for configuration data and return.
181
+ if (arguments.length === 1 && typeof arguments[0] === 'object') {
182
+ for (i in arguments[0]) {
183
+ if (typeof i === 'string') {
184
+ this.set(i, arguments[0][i]);
185
+ }
186
+ }
187
+
188
+ return this;
189
+ }
190
+
191
+ properties[name] = value;
192
+
193
+ return this;
194
+ };
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+ //
204
+ // A getter method for retrieving graph properties. It can be used like this: obj.get('colorsStroke');
205
+ //
206
+ // @param name string The name of the property to get
207
+ //
208
+ this.get = function (name)
209
+ {
210
+ return properties[name];
211
+ };
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+ //
221
+ // Draws the marker
222
+ //
223
+ this.draw = function ()
224
+ {
225
+ //
226
+ // Fire the onbeforedraw event
227
+ //
228
+ RGraph.fireCustomEvent(this, 'onbeforedraw');
229
+
230
+
231
+
232
+ // Translate half a pixel for antialiasing purposes - but only if it hasn't been
233
+ // done already
234
+ //
235
+ // MUST be the first thing done!
236
+ //
237
+ if (!this.canvas.__rgraph_aa_translated__) {
238
+ this.context.translate(0.5,0.5);
239
+
240
+ this.canvas.__rgraph_aa_translated__ = true;
241
+ }
242
+
243
+ //
244
+ // Reset the linewidth
245
+ //
246
+ this.context.lineWidth = 1;
247
+
248
+
249
+ this.metrics = RGraph.measureText(
250
+ this.text,
251
+ properties.textBold,
252
+ properties.textFont,
253
+ properties.textSize
254
+ );
255
+
256
+
257
+
258
+ if (this.x + this.metrics[0] >= this.canvas.width) {
259
+ this.alignRight = true;
260
+ }
261
+
262
+
263
+
264
+
265
+ //
266
+ // Parse the colors. This allows for simple gradient syntax
267
+ //
268
+ if (!this.colorsParsed) {
269
+
270
+ this.parseColors();
271
+
272
+ // Don't want to do this again
273
+ this.colorsParsed = true;
274
+ }
275
+
276
+
277
+
278
+
279
+ //
280
+ // Draw the box *
281
+ //
282
+
283
+ var x = this.alignRight ? this.x - this.metrics[0] - 6 : this.x,
284
+ y = this.y - 6 - properties.voffset - this.metrics[1],
285
+ width = this.metrics[0] + 6,
286
+ height = this.metrics[1];
287
+
288
+ // Store these coords as the coords of the label
289
+ this.coords[0] = [x, y, width, height];
290
+
291
+
292
+
293
+ //
294
+ // Stop this growing uncntrollably
295
+ //
296
+ this.coordsText = [];
297
+
298
+
299
+ // Set the linewidth
300
+ this.context.lineWidth = properties.linewidth;
301
+
302
+
303
+
304
+
305
+
306
+ //
307
+ // Draw the box that the text sits in
308
+ //
309
+
310
+ if (properties.shadow) {
311
+ RGraph.setShadow(
312
+ this,
313
+ properties.shadowColor,
314
+ properties.shadowOffsetx,
315
+ properties.shadowOffsety,
316
+ properties.shadowBlur
317
+ );
318
+ }
319
+
320
+ this.context.strokeStyle = properties.colorsStroke;
321
+ this.context.fillStyle = properties.colorsFill;
322
+
323
+ // This partcular strokeRect has 0 width and so ends up being a line
324
+ this.context.strokeRect(x + (this.alignRight ? width : 0), y, 0, height + properties.voffset - 6);
325
+
326
+ this.context.strokeRect(x, y, width, height);
327
+ this.context.fillRect(x, y, width, height);
328
+
329
+ RGraph.noShadow(this);
330
+
331
+ this.context.fillStyle = properties.textColor;
332
+
333
+ // Draw the text
334
+ RGraph.text({
335
+
336
+ object: this,
337
+
338
+ font: properties.textFont,
339
+ size: properties.textSize,
340
+ color: properties.textColor,
341
+ bold: properties.textBold,
342
+ italic: properties.textItalic,
343
+
344
+ x: Math.round(this.x) - (this.alignRight ? this.metrics[0] + 3 : -3),
345
+ y: y + (height / 2),
346
+ text: this.text,
347
+ valign: 'center',
348
+ halign: 'left',
349
+ tag: 'labels'
350
+ });
351
+
352
+ this.coords[0].push([
353
+ x,
354
+ y,
355
+ width,
356
+ height
357
+ ]);
358
+
359
+
360
+
361
+
362
+
363
+
364
+
365
+
366
+ // Must turn the shadow off
367
+ RGraph.noShadow(this);
368
+
369
+
370
+
371
+ //
372
+ // Reset the testBaseline
373
+ //
374
+ this.context.textBaseline = 'alphabetic';
375
+
376
+
377
+
378
+
379
+ //
380
+ // Add custom text thats specified
381
+ //
382
+ RGraph.addCustomText(this);
383
+
384
+
385
+
386
+
387
+
388
+
389
+ //
390
+ // This installs the event listeners
391
+ //
392
+ RGraph.installEventListeners(this);
393
+
394
+
395
+ //
396
+ // Fire the onfirstdraw event
397
+ //
398
+ if (this.firstDraw) {
399
+ this.firstDraw = false;
400
+ RGraph.fireCustomEvent(this, 'onfirstdraw');
401
+ this.firstDrawFunc();
402
+ }
403
+
404
+
405
+
406
+
407
+ //
408
+ // Fire the draw event
409
+ //
410
+ RGraph.fireCustomEvent(this, 'ondraw');
411
+
412
+ return this;
413
+ };
414
+
415
+
416
+
417
+
418
+
419
+
420
+
421
+ //
422
+ // Used in chaining. Runs a function there and then - not waiting for
423
+ // the events to fire (eg the onbeforedraw event)
424
+ //
425
+ // @param function func The function to execute
426
+ //
427
+ this.exec = function (func)
428
+ {
429
+ func(this);
430
+
431
+ return this;
432
+ };
433
+
434
+
435
+
436
+
437
+
438
+
439
+
440
+
441
+ //
442
+ // The getObjectByXY() worker method
443
+ //
444
+ this.getObjectByXY = function (e)
445
+ {
446
+ if (this.getShape(e)) {
447
+ return this;
448
+ }
449
+ };
450
+
451
+
452
+
453
+
454
+
455
+
456
+
457
+
458
+ //
459
+ // Not used by the class during creating the shape, but is used by event handlers
460
+ // to get the coordinates (if any) of the selected bar
461
+ //
462
+ // @param object e The event object
463
+ // @param object OPTIONAL You can pass in the bar object instead of the
464
+ // function using "this"
465
+ //
466
+ this.getShape = function (e)
467
+ {
468
+ var mouseXY = RGraph.getMouseXY(e),
469
+ mouseX = mouseXY[0],
470
+ mouseY = mouseXY[1];
471
+
472
+ if (mouseX >= this.coords[0][0] && mouseX <= (this.coords[0][0] + this.coords[0][2]) ) {
473
+
474
+ if (mouseY >= this.coords[0][1] && mouseY <= (this.coords[0][1] + this.coords[0][3])) {
475
+
476
+ if (RGraph.parseTooltipText && properties.tooltips) {
477
+ var tooltip = RGraph.parseTooltipText(properties.tooltips, 0);
478
+ }
479
+
480
+ return {
481
+ object: this,
482
+ x: this.coords[0][0],
483
+ y: this.coords[0][1],
484
+ width: this.coords[0][2],
485
+ height: this.coords[0][3],
486
+ dataset: 0,
487
+ index: 0,
488
+ sequentialIndex: 0,
489
+ tooltip: typeof tooltip === 'string' ? tooltip : null
490
+ };
491
+ }
492
+ }
493
+
494
+ return null;
495
+ };
496
+
497
+
498
+
499
+
500
+
501
+
502
+
503
+
504
+ //
505
+ // Each object type has its own Highlight() function which highlights the appropriate shape
506
+ //
507
+ // @param object shape The shape to highlight
508
+ //
509
+ this.highlight = function (shape)
510
+ {
511
+ if (properties.tooltipsHighlight) {
512
+ if (typeof properties.highlightStyle === 'function') {
513
+ (properties.highlightStyle)(shape);
514
+ } else {
515
+
516
+ this.path(
517
+ 'b r % % % % f % s %',
518
+ this.coords[0][0],this.coords[0][1],this.coords[0][2],this.coords[0][3],
519
+ properties.highlightFill,properties.highlightStroke
520
+ );
521
+
522
+ this.path(
523
+ 'b r % % % % f % s %',
524
+ this.coords[0][0],this.coords[0][1],this.coords[0][2],this.coords[0][3],
525
+ properties.highlightFill,properties.highlightStroke
526
+ );
527
+ }
528
+ }
529
+ };
530
+
531
+
532
+
533
+
534
+ //
535
+ // This allows for easy specification of gradients
536
+ //
537
+ this.parseColors = function ()
538
+ {
539
+ // Save the original colors so that they can be restored when the canvas is reset
540
+ if (this.original_colors.length === 0) {
541
+ this.original_colors.colorsFill = RGraph.arrayClone(properties.colorsFill);
542
+ this.original_colors.colorsStroke = RGraph.arrayClone(properties.colorsStroke);
543
+ this.original_colors.highlightFill = RGraph.arrayClone(properties.highlightFill);
544
+ this.original_colors.highlightStroke = RGraph.arrayClone(properties.highlightStroke);
545
+ this.original_colors.textColor = RGraph.arrayClone(properties.textColor);
546
+ }
547
+
548
+ //
549
+ // Parse various properties for colors
550
+ //
551
+ properties.colorsFill = this.parseSingleColorForGradient(properties.colorsFill);
552
+ properties.colorsStroke = this.parseSingleColorForGradient(properties.colorsStroke);
553
+ properties.highlightStroke = this.parseSingleColorForGradient(properties.highlightStroke);
554
+ properties.highlightFill = this.parseSingleColorForGradient(properties.highlightFill);
555
+ properties.textColor = this.parseSingleColorForGradient(properties.textColor);
556
+ };
557
+
558
+
559
+
560
+
561
+
562
+
563
+
564
+
565
+ //
566
+ // Use this function to reset the object to the post-constructor state. Eg reset colors if
567
+ // need be etc
568
+ //
569
+ this.reset = function ()
570
+ {
571
+ };
572
+
573
+
574
+
575
+
576
+
577
+
578
+
579
+
580
+ //
581
+ // This parses a single color value
582
+ //
583
+ this.parseSingleColorForGradient = function (color)
584
+ {
585
+ if (!color) {
586
+ return color;
587
+ }
588
+
589
+ if (typeof color === 'string' && color.match(/^gradient\((.*)\)$/i)) {
590
+
591
+
592
+
593
+ // Allow for JSON gradients
594
+ if (color.match(/^gradient\(({.*})\)$/i)) {
595
+ return RGraph.parseJSONGradient({object: this, def: RegExp.$1});
596
+ }
597
+
598
+ // Create the gradient
599
+ var parts = RegExp.$1.split(':'),
600
+ grad = this.context.createLinearGradient(
601
+ this.x,
602
+ this.y,
603
+ this.x + this.metrics[0],
604
+ this.y
605
+ ),
606
+ diff = 1 / (parts.length - 1);
607
+
608
+ grad.addColorStop(0, RGraph.trim(parts[0]));
609
+
610
+ for (var j=1; j<parts.length; ++j) {
611
+ grad.addColorStop(j * diff, RGraph.trim(parts[j]));
612
+ }
613
+ }
614
+
615
+ return grad ? grad : color;
616
+ };
617
+
618
+
619
+
620
+
621
+
622
+
623
+
624
+
625
+ //
626
+ // Using a function to add events makes it easier to facilitate method chaining
627
+ //
628
+ // @param string type The type of even to add
629
+ // @param function func
630
+ //
631
+ this.on = function (type, func)
632
+ {
633
+ if (type.substr(0,2) !== 'on') {
634
+ type = 'on' + type;
635
+ }
636
+
637
+ if (typeof this[type] !== 'function') {
638
+ this[type] = func;
639
+ } else {
640
+ RGraph.addCustomEventListener(this, type, func);
641
+ }
642
+
643
+ return this;
644
+ };
645
+
646
+
647
+
648
+
649
+
650
+
651
+
652
+
653
+ //
654
+ // This function runs once only
655
+ // (put at the end of the file (before any effects))
656
+ //
657
+ this.firstDrawFunc = function ()
658
+ {
659
+ };
660
+
661
+
662
+
663
+
664
+
665
+
666
+
667
+
668
+ //
669
+ // A worker function that handles Bar chart specific tooltip substitutions
670
+ //
671
+ this.tooltipSubstitutions = function (opt)
672
+ {
673
+ return {
674
+ index: 0,
675
+ dataset: 0,
676
+ sequentialIndex: 0,
677
+ value: null
678
+ };
679
+ };
680
+
681
+
682
+
683
+
684
+
685
+
686
+
687
+
688
+ //
689
+ // This allows for static tooltip positioning
690
+ //
691
+ this.positionTooltipStatic = function (args)
692
+ {
693
+ var obj = args.object,
694
+ e = args.event,
695
+ tooltip = args.tooltip,
696
+ index = args.index,
697
+ canvasXY = RGraph.getCanvasXY(obj.canvas);
698
+
699
+ // Position the tooltip in the X direction
700
+ args.tooltip.style.left = (
701
+ canvasXY[0] // The X coordinate of the canvas
702
+ - (tooltip.offsetWidth / 2) // Subtract half of the tooltip width
703
+ + obj.properties.tooltipsOffsetx // Add any user defined offset
704
+ + this.coords[0][0]
705
+ + (this.coords[0][2] / 2)
706
+ ) + 'px';
707
+
708
+ args.tooltip.style.top = (
709
+ canvasXY[1] // The Y coordinate of the canvas
710
+ - tooltip.offsetHeight // The height of the tooltip
711
+ + obj.properties.tooltipsOffsety // Add any user defined offset
712
+ + this.coords[0][1]
713
+ - 10
714
+ ) + 'px';
715
+ };
716
+
717
+
718
+
719
+
720
+
721
+
722
+
723
+
724
+ //
725
+ // Objects are now always registered so that the chart is redrawn if need be.
726
+ //
727
+ RGraph.register(this);
728
+
729
+
730
+
731
+
732
+
733
+
734
+
735
+
736
+ //
737
+ // the number of arguments is only one and it's an
738
+ // object - parse it for configuration data and return.
739
+ //
740
+ RGraph.parseObjectStyleConfig(this, conf.options);
741
+ };