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