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