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