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