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