rgraph-rails 4.62 → 4.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +3 -4
  3. data/lib/rgraph-rails/version.rb +1 -1
  4. data/vendor/assets/javascripts/RGraph.bar.js +240 -3742
  5. data/vendor/assets/javascripts/RGraph.bipolar.js +165 -2005
  6. data/vendor/assets/javascripts/RGraph.common.annotate.js +35 -395
  7. data/vendor/assets/javascripts/RGraph.common.context.js +30 -595
  8. data/vendor/assets/javascripts/RGraph.common.core.js +418 -5359
  9. data/vendor/assets/javascripts/RGraph.common.csv.js +20 -276
  10. data/vendor/assets/javascripts/RGraph.common.deprecated.js +35 -450
  11. data/vendor/assets/javascripts/RGraph.common.dynamic.js +88 -1395
  12. data/vendor/assets/javascripts/RGraph.common.effects.js +90 -1545
  13. data/vendor/assets/javascripts/RGraph.common.key.js +52 -753
  14. data/vendor/assets/javascripts/RGraph.common.resizing.js +37 -563
  15. data/vendor/assets/javascripts/RGraph.common.sheets.js +29 -352
  16. data/vendor/assets/javascripts/RGraph.common.tooltips.js +32 -450
  17. data/vendor/assets/javascripts/RGraph.common.zoom.js +14 -219
  18. data/vendor/assets/javascripts/RGraph.cornergauge.js +71 -0
  19. data/vendor/assets/javascripts/RGraph.drawing.background.js +34 -570
  20. data/vendor/assets/javascripts/RGraph.drawing.circle.js +33 -544
  21. data/vendor/assets/javascripts/RGraph.drawing.image.js +51 -755
  22. data/vendor/assets/javascripts/RGraph.drawing.marker1.js +37 -645
  23. data/vendor/assets/javascripts/RGraph.drawing.marker2.js +36 -633
  24. data/vendor/assets/javascripts/RGraph.drawing.marker3.js +35 -514
  25. data/vendor/assets/javascripts/RGraph.drawing.poly.js +37 -559
  26. data/vendor/assets/javascripts/RGraph.drawing.rect.js +33 -548
  27. data/vendor/assets/javascripts/RGraph.drawing.text.js +36 -664
  28. data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +50 -812
  29. data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +51 -856
  30. data/vendor/assets/javascripts/RGraph.fuel.js +58 -964
  31. data/vendor/assets/javascripts/RGraph.funnel.js +55 -984
  32. data/vendor/assets/javascripts/RGraph.gantt.js +77 -1354
  33. data/vendor/assets/javascripts/RGraph.gauge.js +85 -1421
  34. data/vendor/assets/javascripts/RGraph.hbar.js +162 -2788
  35. data/vendor/assets/javascripts/RGraph.hprogress.js +80 -1401
  36. data/vendor/assets/javascripts/RGraph.line.js +249 -4248
  37. data/vendor/assets/javascripts/RGraph.meter.js +74 -1280
  38. data/vendor/assets/javascripts/RGraph.modaldialog.js +19 -301
  39. data/vendor/assets/javascripts/RGraph.odo.js +71 -1264
  40. data/vendor/assets/javascripts/RGraph.pie.js +137 -2288
  41. data/vendor/assets/javascripts/RGraph.radar.js +110 -1847
  42. data/vendor/assets/javascripts/RGraph.rose.js +108 -1977
  43. data/vendor/assets/javascripts/RGraph.rscatter.js +80 -1432
  44. data/vendor/assets/javascripts/RGraph.scatter.js +172 -3163
  45. data/vendor/assets/javascripts/RGraph.semicircularprogress.js +60 -1120
  46. data/vendor/assets/javascripts/RGraph.svg.bar.js +66 -1735
  47. data/vendor/assets/javascripts/RGraph.svg.common.ajax.js +21 -246
  48. data/vendor/assets/javascripts/RGraph.svg.common.core.js +255 -3937
  49. data/vendor/assets/javascripts/RGraph.svg.common.csv.js +20 -276
  50. data/vendor/assets/javascripts/RGraph.svg.common.fx.js +68 -1303
  51. data/vendor/assets/javascripts/RGraph.svg.common.key.js +19 -205
  52. data/vendor/assets/javascripts/RGraph.svg.common.sheets.js +29 -352
  53. data/vendor/assets/javascripts/RGraph.svg.common.tooltips.js +22 -273
  54. data/vendor/assets/javascripts/RGraph.svg.funnel.js +32 -0
  55. data/vendor/assets/javascripts/RGraph.svg.hbar.js +59 -1400
  56. data/vendor/assets/javascripts/RGraph.svg.line.js +70 -1580
  57. data/vendor/assets/javascripts/RGraph.svg.pie.js +55 -1131
  58. data/vendor/assets/javascripts/RGraph.svg.radar.js +57 -1502
  59. data/vendor/assets/javascripts/RGraph.svg.rose.js +66 -1817
  60. data/vendor/assets/javascripts/RGraph.svg.scatter.js +58 -1261
  61. data/vendor/assets/javascripts/RGraph.svg.semicircularprogress.js +28 -865
  62. data/vendor/assets/javascripts/RGraph.svg.waterfall.js +45 -1252
  63. data/vendor/assets/javascripts/RGraph.thermometer.js +63 -1136
  64. data/vendor/assets/javascripts/RGraph.vprogress.js +83 -1470
  65. data/vendor/assets/javascripts/RGraph.waterfall.js +83 -1347
  66. metadata +5 -4
  67. data/vendor/assets/javascripts/financial-data.js +0 -1067
@@ -1,220 +1,15 @@
1
- // version: 2017-05-08
2
- /**
3
- * o--------------------------------------------------------------------------------o
4
- * | This file is part of the RGraph package - you can learn more at: |
5
- * | |
6
- * | http://www.rgraph.net |
7
- * | |
8
- * | RGraph is licensed under the Open Source MIT license. That means that it's |
9
- * | totally free to use! |
10
- * o--------------------------------------------------------------------------------o
11
- */
12
1
 
13
- RGraph = window.RGraph || {isRGraph: true};
14
-
15
-
16
- // Module pattern
17
- (function (win, doc, undefined)
18
- {
19
- var RG = RGraph,
20
- ua = navigator.userAgent,
21
- ma = Math;
22
-
23
-
24
-
25
-
26
- /**
27
- * A zoom in function
28
- *
29
- * @param e object The event object
30
- */
31
- RG.zoom =
32
- RG.Zoom = function (e)
33
- {
34
- e = RGraph.fixEventObject(e);
35
-
36
-
37
- /**
38
- * Triggered from a context menu
39
- */
40
- if (e && e.target && e.target.__canvas__) {
41
- var canvas = e.target.__canvas__;
42
-
43
- /**
44
- * This is here to facilitate zooming by just a single left click
45
- */
46
- } else if (e && e.target && e.target.__object__) {
47
- var canvas = e.target.__object__.canvas;
48
- e.stopPropagation(); // Hmmmm
49
- }
50
-
51
- // Fallback for MSIE9
52
- if (!canvas) {
53
- var registry_canvas = RGraph.Registry.get('chart.contextmenu').__canvas__;
54
- if (registry_canvas) {
55
- var canvas = registry_canvas;
56
- }
57
- }
58
-
59
- var obj = canvas.__object__;
60
- var context = obj.context;
61
- var dataurl = canvas.toDataURL();
62
- var tmp = canvas;
63
- var coords = RG.getCanvasXY(canvas);
64
- var factor = obj.Get('chart.zoom.factor') - 1;
65
-
66
- var x = coords[0];
67
- var y = coords[1];
68
-
69
- var img = document.createElement('img');
70
- img.className = 'RGraph_zoomed_canvas';
71
- img.style.border = '1px solid #ccc';
72
- img.style.width = canvas.width + 'px';
73
- img.style.height = canvas.height + 'px';
74
- img.style.position = 'absolute';
75
- img.style.left = x + 'px';
76
- img.style.top = y + 'px';
77
- img.style.backgroundColor = 'white';
78
- img.style.opacity = obj.Get('chart.zoom.fade.in') ? 0 : 1;
79
- img.style.zIndex = 99;
80
- img.src = dataurl;
81
- document.body.appendChild(img);
82
-
83
- //RGraph.Registry.Set('chart.zoomedimage', img);
84
- // Store the zoomed image in a global var - NOT the registry
85
- RGraph.zoom_image = img;
86
- RGraph.zoom_image.obj = obj;
87
-
88
- // Image onclick should not hide the image
89
- img.onclick = function (e)
90
- {
91
- e = RGraph.fixEventObject(e);
92
- e.stopPropagation();
93
- return false;
94
- }
95
-
96
- //setTimeout(function (){document.body.onclick = RGraph.HideZoomedCanvas;}, 1);
97
-
98
-
99
- var width = parseInt(canvas.width);
100
- var height = parseInt(canvas.height);
101
- var frames = obj.Get('chart.zoom.frames');
102
- var delay = obj.Get('chart.zoom.delay');
103
-
104
- // Increase the width over 10 frames - center
105
- if (obj.Get('chart.zoom.hdir') == 'center') {
106
-
107
- for (var i=1; i<=frames; ++i) {
108
- var newWidth = width * factor * (i/frames) + width;
109
- var rightHandEdge = x + canvas.width;
110
- var newLeft = (x + (canvas.width / 2)) - (newWidth / 2);
111
-
112
- setTimeout("RGraph.zoom_image.style.width = '" + String(newWidth) + "px'; RGraph.zoom_image.style.left = '" + newLeft + "px'", i * delay);
113
- }
114
-
115
- // Left
116
- } else if (obj.Get('chart.zoom.hdir') == 'left') {
117
- for (var i=1; i<=frames; ++i) {
118
- var newWidth = width * factor * (i/frames) + width;
119
- var rightHandEdge = x + canvas.width;
120
- var newLeft = rightHandEdge - newWidth;
121
-
122
- setTimeout("RGraph.zoom_image.style.width = '" + String(newWidth) + "px'; RGraph.zoom_image.style.left = '" + newLeft + "px'", i * delay);
123
- }
124
-
125
- // Right (default)
126
- } else {
127
- for (var i=1; i<=frames; ++i) {
128
- var newWidth = width * factor * (i/frames) + width;
129
- setTimeout("RGraph.zoom_image.style.width = '" + String(newWidth) + "px'", i * delay);
130
- }
131
- }
132
-
133
- // Increase the height over 10 frames - up
134
- if (obj.Get('chart.zoom.vdir') == 'up') {
135
- for (var i=1; i<=frames; ++i) {
136
- var newHeight = (height * factor * (i/frames)) + height;
137
- var bottomEdge = y + canvas.height;
138
- var newTop = bottomEdge - newHeight;
139
-
140
- setTimeout("RGraph.zoom_image.style.height = '" + String(newHeight) + "px'; RGraph.zoom_image.style.top = '" + newTop + "px'", i * delay);
141
- }
142
-
143
- // center
144
- } else if (obj.Get('chart.zoom.vdir') == 'center') {
145
- for (var i=1; i<=frames; ++i) {
146
- var newHeight = (height * factor * (i/frames)) + height;
147
- var bottomEdge = (y + (canvas.height / 2)) + (newHeight / 2);
148
- var newTop = bottomEdge - newHeight;
149
-
150
- setTimeout("RGraph.zoom_image.style.height = '" + String(newHeight) + "px'; RGraph.zoom_image.style.top = '" + newTop + "px'", i * delay);
151
- }
152
-
153
- // Down (default
154
- } else {
155
- for (var i=1; i<=frames; ++i) {
156
- setTimeout("RGraph.zoom_image.style.height = '" + String(height * factor * (i/frames) + height) + "px'", i * delay);
157
- }
158
- }
159
-
160
- // If enabled, increase the opactity over the requested number of frames
161
- if (obj.Get('chart.zoom.fade.in')) {
162
- for (var i=1; i<=frames; ++i) {
163
- setTimeout("RGraph.zoom_image.style.opacity = " + Number(i / frames), i * (delay / 2));
164
- }
165
- }
166
-
167
- // If stipulated, produce a shadow
168
- if (obj.Get('chart.zoom.shadow')) {
169
- for (var i=1; i<=frames; ++i) {
170
- setTimeout("RGraph.zoom_image.style.boxShadow = 'rgba(128,128,128," + Number(i / frames) / 2 + ") 0 0 25px'", i * delay);
171
- setTimeout("RGraph.zoom_image.style.MozBoxShadow = 'rgba(128,128,128," + Number(i / frames) / 2 + ") 0 0 25px'", i * delay);
172
- setTimeout("RGraph.zoom_image.style.WebkitBoxShadow = 'rgba(128,128,128," + Number(i / frames) / 2 + ") 0 0 25px'", i * delay);
173
- }
174
- }
175
-
176
-
177
-
178
- /**
179
- * Create the background. As of March 2013 this is always done
180
- */
181
- var div = document.createElement('DIV');
182
- div.style.backgroundColor = 'white';
183
- div.style.opacity = 0;
184
- div.style.position = 'fixed';
185
- div.style.top = 0;
186
- div.style.left = 0;
187
- div.style.width = (screen.width + 100) + 'px';
188
- div.style.height = (screen.height + 100) + 'px';
189
- div.style.zIndex = 98;
190
-
191
- // Hides the zoomed caboodle
192
- div.onclick =
193
- div.oncontextmenu = function (e)
194
- {
195
- return RG.hideZoomedCanvas(e);
196
- }
197
-
198
- div.origHeight = div.style.height;
199
-
200
- document.body.appendChild(div);
201
-
202
- RG.zoom_background = div;
203
-
204
- // If the window is resized, hide the zoom
205
- //window.onresize = RGraph.HideZoomedCanvas;
206
-
207
- for (var i=1; i<=frames; ++i) {
208
- setTimeout("RGraph.zoom_background.style.opacity = " + (Number(i / frames) * 0.8), i * (delay / 2));
209
- }
210
-
211
- /**
212
- * Fire the onzoom event
213
- */
214
- RG.fireCustomEvent(obj, 'onzoom');
215
- }
216
-
217
-
218
-
219
- // End module pattern
220
- })(window, document);
2
+ RGraph=window.RGraph||{isRGraph:true};(function(win,doc,undefined)
3
+ {var RG=RGraph,ua=navigator.userAgent,ma=Math;RG.zoom=RG.Zoom=function(e)
4
+ {e=RGraph.fixEventObject(e);if(e&&e.target&&e.target.__canvas__){var canvas=e.target.__canvas__;}else if(e&&e.target&&e.target.__object__){var canvas=e.target.__object__.canvas;e.stopPropagation();}
5
+ if(!canvas){var registry_canvas=RGraph.Registry.get('chart.contextmenu').__canvas__;if(registry_canvas){var canvas=registry_canvas;}}
6
+ var obj=canvas.__object__;var context=obj.context;var dataurl=canvas.toDataURL();var tmp=canvas;var coords=RG.getCanvasXY(canvas);var factor=obj.Get('chart.zoom.factor')-1;var x=coords[0];var y=coords[1];var img=document.createElement('img');img.className='RGraph_zoomed_canvas';img.style.border='1px solid #ccc';img.style.width=canvas.width+'px';img.style.height=canvas.height+'px';img.style.position='absolute';img.style.left=x+'px';img.style.top=y+'px';img.style.backgroundColor='white';img.style.opacity=obj.Get('chart.zoom.fade.in')?0:1;img.style.zIndex=99;img.src=dataurl;document.body.appendChild(img);RGraph.zoom_image=img;RGraph.zoom_image.obj=obj;img.onclick=function(e)
7
+ {e=RGraph.fixEventObject(e);e.stopPropagation();return false;}
8
+ var width=parseInt(canvas.width);var height=parseInt(canvas.height);var frames=obj.Get('chart.zoom.frames');var delay=obj.Get('chart.zoom.delay');if(obj.Get('chart.zoom.hdir')=='center'){for(var i=1;i<=frames;++i){var newWidth=width*factor*(i/frames)+width;var rightHandEdge=x+canvas.width;var newLeft=(x+(canvas.width/2))-(newWidth/2);setTimeout("RGraph.zoom_image.style.width = '"+String(newWidth)+"px'; RGraph.zoom_image.style.left = '"+newLeft+"px'",i*delay);}}else if(obj.Get('chart.zoom.hdir')=='left'){for(var i=1;i<=frames;++i){var newWidth=width*factor*(i/frames)+width;var rightHandEdge=x+canvas.width;var newLeft=rightHandEdge-newWidth;setTimeout("RGraph.zoom_image.style.width = '"+String(newWidth)+"px'; RGraph.zoom_image.style.left = '"+newLeft+"px'",i*delay);}}else{for(var i=1;i<=frames;++i){var newWidth=width*factor*(i/frames)+width;setTimeout("RGraph.zoom_image.style.width = '"+String(newWidth)+"px'",i*delay);}}
9
+ if(obj.Get('chart.zoom.vdir')=='up'){for(var i=1;i<=frames;++i){var newHeight=(height*factor*(i/frames))+height;var bottomEdge=y+canvas.height;var newTop=bottomEdge-newHeight;setTimeout("RGraph.zoom_image.style.height = '"+String(newHeight)+"px'; RGraph.zoom_image.style.top = '"+newTop+"px'",i*delay);}}else if(obj.Get('chart.zoom.vdir')=='center'){for(var i=1;i<=frames;++i){var newHeight=(height*factor*(i/frames))+height;var bottomEdge=(y+(canvas.height/2))+(newHeight/2);var newTop=bottomEdge-newHeight;setTimeout("RGraph.zoom_image.style.height = '"+String(newHeight)+"px'; RGraph.zoom_image.style.top = '"+newTop+"px'",i*delay);}}else{for(var i=1;i<=frames;++i){setTimeout("RGraph.zoom_image.style.height = '"+String(height*factor*(i/frames)+height)+"px'",i*delay);}}
10
+ if(obj.Get('chart.zoom.fade.in')){for(var i=1;i<=frames;++i){setTimeout("RGraph.zoom_image.style.opacity = "+Number(i/frames),i*(delay/2));}}
11
+ if(obj.Get('chart.zoom.shadow')){for(var i=1;i<=frames;++i){setTimeout("RGraph.zoom_image.style.boxShadow = 'rgba(128,128,128,"+Number(i/frames)/2+") 0 0 25px'",i*delay);setTimeout("RGraph.zoom_image.style.MozBoxShadow = 'rgba(128,128,128,"+Number(i/frames)/2+") 0 0 25px'",i*delay);setTimeout("RGraph.zoom_image.style.WebkitBoxShadow = 'rgba(128,128,128,"+Number(i/frames)/2+") 0 0 25px'",i*delay);}}
12
+ var div=document.createElement('DIV');div.style.backgroundColor='white';div.style.opacity=0;div.style.position='fixed';div.style.top=0;div.style.left=0;div.style.width=(screen.width+100)+'px';div.style.height=(screen.height+100)+'px';div.style.zIndex=98;div.onclick=div.oncontextmenu=function(e)
13
+ {return RG.hideZoomedCanvas(e);}
14
+ div.origHeight=div.style.height;document.body.appendChild(div);RG.zoom_background=div;for(var i=1;i<=frames;++i){setTimeout("RGraph.zoom_background.style.opacity = "+(Number(i/frames)*0.8),i*(delay/2));}
15
+ RG.fireCustomEvent(obj,'onzoom');}})(window,document);
@@ -0,0 +1,71 @@
1
+
2
+ RGraph=window.RGraph||{isRGraph:true};RGraph.CornerGauge=function(conf)
3
+ {if(typeof conf==='object'&&typeof conf.min==='number'&&typeof conf.max==='number'&&typeof conf.value!=='undefined'&&typeof conf.id==='string'){var id=conf.id
4
+ var canvas=document.getElementById(id);var min=conf.min;var max=conf.max;var value=conf.value;var parseConfObjectForOptions=true;}else{var id=conf;var canvas=document.getElementById(id);var min=arguments[1];var max=arguments[2];var value=arguments[3];}
5
+ this.id=id;this.canvas=canvas;this.context=this.canvas.getContext?this.canvas.getContext("2d",{alpha:(typeof id==='object'&&id.alpha===false)?false:true}):null;this.canvas.__object__=this;this.type='cornergauge';this.min=min;this.max=max;this.value=RGraph.stringsToNumbers(value);this.angles={};this.angles.needle=[];this.centerpin={};this.isRGraph=true;this.currentValue=null;this.uid=RGraph.CreateUID();this.canvas.uid=this.canvas.uid?this.canvas.uid:RGraph.CreateUID();this.coordsText=[];this.original_colors=[];this.firstDraw=true;if(typeof(this.value)=='object'){for(var i=0;i<this.value.length;++i){if(this.value[i]>this.max)this.value[i]=max;if(this.value[i]<this.min)this.value[i]=min;}}else{if(this.value>this.max)this.value=max;if(this.value<this.min)this.value=min;}
6
+ this.properties={'chart.centerx':null,'chart.centery':null,'chart.radius':null,'chart.gutter.left':25,'chart.gutter.right':25,'chart.gutter.top':25,'chart.gutter.bottom':25,'chart.strokestyle':'black','chart.linewidth':2,'chart.title':'','chart.title.vpos':0.5,'chart.title.size':null,'chart.title.x':null,'chart.title.y':null,'chart.title.bold':true,'chart.text.font':'Arial','chart.text.color':'#666','chart.text.size':10,'chart.background.gradient.color1':'#ddd','chart.background.gradient.color2':'white','chart.shadow':true,'chart.shadow.color':'gray','chart.shadow.offsetx':0,'chart.shadow.offsety':0,'chart.shadow.blur':15,'chart.scale.decimals':0,'chart.scale.point':'.','chart.scale.thousand':',','chart.units.pre':'','chart.units.post':'','chart.resizable':false,'chart.chart.resize.handle.background':null,'chart.adjustable':false,'chart.annotatable':false,'chart.annotate.color':'black','chart.colors.ranges':null,'chart.red.start':min+(0.9*(this.max-min)),'chart.green.end':min+(0.7*(this.max-min)),'chart.red.color':'red','chart.yellow.color':'yellow','chart.green.color':'#0f0','chart.value.text':true,'chart.value.text.units.pre':'','chart.value.text.units.post':'','chart.value.text.boxed':true,'chart.value.text.font':'Arial','chart.value.text.size':18,'chart.value.text.bold':false,'chart.value.text.decimals':0,'chart.centerpin.stroke':'rgba(0,0,0,0)','chart.centerpin.fill':null,'chart.centerpin.color':'blue','chart.needle.colors':['#ccc','#D5604D','red','green','yellow'],'chart.zoom.factor':1.5,'chart.zoom.fade.in':true,'chart.zoom.fade.out':true,'chart.zoom.hdir':'right','chart.zoom.vdir':'down','chart.zoom.frames':25,'chart.zoom.delay':16.666,'chart.zoom.shadow':true,'chart.zoom.background':true}
7
+ if(!this.canvas.__rgraph_aa_translated__){this.context.translate(0.5,0.5);this.canvas.__rgraph_aa_translated__=true;}
8
+ var RG=RGraph;var ca=this.canvas;var co=ca.getContext('2d');var prop=this.properties;var jq=jQuery;var pa=RG.Path;var win=window;var doc=document;var ma=Math;this.set=this.Set=function(name,value)
9
+ {if(arguments.length===1&&typeof arguments[0]==='object'){RG.parseObjectStyleConfig(this,arguments[0]);return this;}
10
+ name=name.toLowerCase();if(name.substr(0,6)!='chart.'){name='chart.'+name;}
11
+ prop[name]=value;return this;};this.get=this.Get=function(name)
12
+ {if(name.substr(0,6)!='chart.'){name='chart.'+name;}
13
+ return prop[name];};this.draw=this.Draw=function()
14
+ {RG.FireCustomEvent(this,'onbeforedraw');this.currentValue=this.value;if(typeof this.gutterLeft=='undefined'){this.gutterLeft=prop['chart.gutter.left'];this.gutterRight=prop['chart.gutter.right'];this.gutterTop=prop['chart.gutter.top'];this.gutterBottom=prop['chart.gutter.bottom'];}
15
+ this.radius=Math.min((ca.width-this.gutterLeft-this.gutterRight),(ca.height-this.gutterTop-this.gutterBottom));if(typeof(prop['chart.radius'])=='number')this.radius=prop['chart.radius'];this.centerx=(ca.width/2)-(this.radius/2)+Math.max(30,this.radius*0.1);this.centery=(ca.height/2)+(this.radius/2)-(this.radius*0.1);this.coordsText=[];if(typeof prop['chart.centerx']==='number')this.centerx=prop['chart.centerx'];if(typeof prop['chart.centery']==='number')this.centery=prop['chart.centery'];if(!this.colorsParsed){this.parseColors();this.colorsParsed=true;}
16
+ this.DrawBackGround();this.DrawTickmarks();this.DrawColorBands();this.DrawLabel();this.DrawLabels();if(typeof this.value==='object'){for(var i=0,len=this.value.length;i<len;++i){this.DrawNeedle(i,this.value[i],this.radius-65);}}else{this.DrawNeedle(0,this.value,this.radius-65);}
17
+ this.DrawCenterpin();var size=prop['chart.title.size']?prop['chart.title.size']:prop['chart.text.size']+2
18
+ prop['chart.title.y']=this.centery+20-this.radius-((1.5*size)/2);RGraph.DrawTitle(this,prop['chart.title'],this.guttertop,this.centerx+(this.radius/2),size);if(prop['chart.contextmenu']){RGraph.ShowContext(this);}
19
+ if(prop['chart.resizable']){RGraph.AllowResizing(this);}
20
+ RGraph.InstallEventListeners(this);if(this.firstDraw){RG.fireCustomEvent(this,'onfirstdraw');this.firstDraw=false;this.firstDrawFunc();}
21
+ RGraph.FireCustomEvent(this,'ondraw');return this;};this.drawBackGround=this.DrawBackGround=function()
22
+ {if(prop['chart.shadow']){RGraph.SetShadow(this,prop['chart.shadow.color'],prop['chart.shadow.offsetx'],prop['chart.shadow.offsety'],prop['chart.shadow.blur']);}
23
+ co.strokeStyle=prop['chart.strokestyle'];co.lineWidth=prop['chart.linewidth']?prop['chart.linewidth']:0.0001;co.beginPath();co.arc(this.centerx,this.centery,30,0,RGraph.TWOPI,false);co.stroke();co.beginPath();co.moveTo(this.centerx-20,this.centery+20);co.arc(this.centerx-20,this.centery+20,this.radius,RGraph.PI+RGraph.HALFPI,RGraph.TWOPI,false);co.closePath();co.fill();co.stroke();RG.NoShadow(this);co.strokeStyle=prop['chart.strokestyle'];co.lineWidth=prop['chart.linewidth']?prop['chart.linewidth']:0.0001;co.beginPath();co.moveTo(this.centerx-20,this.centery+20);co.arc(this.centerx-20,this.centery+20,this.radius,RGraph.PI+RGraph.HALFPI,RGraph.TWOPI,false);co.closePath();co.stroke();RGraph.NoShadow(this);co.lineWidth=0;co.fillStyle=RGraph.RadialGradient(this,this.centerx,this.centery,0,this.centerx,this.centery,this.radius*0.5,prop['chart.background.gradient.color1'],prop['chart.background.gradient.color2']);co.beginPath();co.moveTo(this.centerx,this.centery);co.arc(this.centerx,this.centery,30,0,RGraph.TWOPI,0);co.closePath();co.fill();co.beginPath();co.moveTo(this.centerx-20,this.centery+20);co.lineTo(this.centerx-20,this.centery+20-this.radius);co.arc(this.centerx-20,this.centery+20,this.radius,RGraph.PI+RGraph.HALFPI,RGraph.TWOPI,false);co.closePath();co.fill();co.beginPath();co.lineWidth=1;co.strokeStyle='#eee';for(var i=0;i<=5;++i){var p1=RG.getRadiusEndPoint(this.centerx,this.centery,(RGraph.HALFPI/5*i)+RGraph.PI+RGraph.HALFPI,30);var p2=RG.getRadiusEndPoint(this.centerx,this.centery,(RGraph.HALFPI/5*i)+RGraph.PI+RGraph.HALFPI,this.radius-90);co.moveTo(p1[0],p1[1]);co.lineTo(p2[0],p2[1]);}
24
+ co.stroke();};this.drawNeedle=this.DrawNeedle=function(index,value,radius)
25
+ {var grad=RG.RadialGradient(this,this.centerx,this.centery,0,this.centerx,this.centery,20,'rgba(0,0,0,0)',prop['chart.needle.colors'][index])
26
+ this.angles.needle[index]=(((value-this.min)/(this.max-this.min))*RG.HALFPI)+RG.PI+RG.HALFPI;co.lineWidth=1
27
+ co.strokeStyle='rgba(0,0,0,0)';co.fillStyle=grad;co.beginPath();co.moveTo(this.centerx,this.centery);co.arc(this.centerx,this.centery,10,this.angles.needle[index]-RG.HALFPI,this.angles.needle[index]-RG.HALFPI+0.000001,false);co.arc(this.centerx,this.centery,radius-30,this.angles.needle[index],this.angles.needle[index]+0.000001,false);co.arc(this.centerx,this.centery,10,this.angles.needle[index]+RG.HALFPI,this.angles.needle[index]+RG.HALFPI+0.000001,false);co.stroke();co.fill();};this.drawCenterpin=this.DrawCenterpin=function()
28
+ {if(!prop['chart.centerpin.fill']){prop['chart.centerpin.fill']=RG.RadialGradient(this,this.centerx+5,this.centery-5,0,this.centerx+5,this.centery-5,20,'white',prop['chart.centerpin.color'])}
29
+ co.strokeStyle=prop['chart.centerpin.stroke'];co.fillStyle=prop['chart.centerpin.fill'];co.beginPath();co.lineWidth=2;co.arc(this.centerx,this.centery,15,0,RGraph.TWOPI,false);co.stroke();co.fill();};this.drawLabels=this.DrawLabels=function()
30
+ {var numLabels=6;co.fillStyle=prop['chart.text.color'];for(var i=0;i<numLabels;++i){co.beginPath();var num=Number(this.min+((this.max-this.min)*(i/(numLabels-1)))).toFixed(prop['chart.scale.decimals']);num=RG.number_format(this,num,prop['chart.units.pre'],prop['chart.units.post']);var angle=(i*18)/(180/RG.PI);RG.Text2(this,{'font':prop['chart.text.font'],'size':prop['chart.text.size'],'x':this.centerx+ma.sin(angle)*(this.radius-53),'y':this.centery-ma.cos(angle)*(this.radius-53),'text':String(num),'valign':'top','halign':'center','angle':90*(i/(numLabels-1)),'tag':'scale'});co.fill();}};this.drawTickmarks=this.DrawTickmarks=function()
31
+ {var bigTicks=5;var smallTicks=25;for(var i=0;i<smallTicks;++i){co.beginPath();var angle=(RG.HALFPI/(smallTicks-1))*i
32
+ co.lineWidth=1;co.arc(this.centerx,this.centery,this.radius-44,RG.PI+RG.HALFPI+angle,RG.PI+RG.HALFPI+angle+0.0001,false);co.arc(this.centerx,this.centery,this.radius-46,RG.PI+RG.HALFPI+angle,RG.PI+RG.HALFPI+angle+0.0001,false);co.stroke();}
33
+ for(var i=0;i<bigTicks;++i){co.beginPath();var angle=(RG.HALFPI/(bigTicks-1))*i
34
+ co.lineWidth=1;co.arc(this.centerx,this.centery,this.radius-43,RG.PI+RG.HALFPI+angle,RG.PI+RG.HALFPI+angle+0.0001,false);co.arc(this.centerx,this.centery,this.radius-47,RG.PI+RG.HALFPI+angle,RG.PI+RG.HALFPI+angle+0.0001,false);co.stroke();}};this.DrawColorBands=function()
35
+ {if(RG.is_array(prop['chart.colors.ranges'])){var ranges=prop['chart.colors.ranges'];for(var i=0,len=ranges.length;i<len;++i){co.fillStyle=ranges[i][2];co.lineWidth=0;co.beginPath();co.arc(this.centerx,this.centery,this.radius-54-(prop['chart.text.size']*1.5),(((ranges[i][0]-this.min)/(this.max-this.min))*RG.HALFPI)+(RG.PI+RG.HALFPI),(((ranges[i][1]-this.min)/(this.max-this.min))*RG.HALFPI)+(RG.PI+RG.HALFPI),false);co.arc(this.centerx,this.centery,this.radius-54-10-(prop['chart.text.size']*1.5),(((ranges[i][1]-this.min)/(this.max-this.min))*RG.HALFPI)+(RG.PI+RG.HALFPI),(((ranges[i][0]-this.min)/(this.max-this.min))*RG.HALFPI)+(RG.PI+RG.HALFPI),true);co.closePath();co.fill();}
36
+ return;}
37
+ co.strokeStyle=prop['chart.green.color'];co.fillStyle=prop['chart.green.color'];var greenStart=RG.PI+RG.HALFPI;var greenEnd=greenStart+(RG.TWOPI-greenStart)*((prop['chart.green.end']-this.min)/(this.max-this.min))
38
+ co.beginPath();co.arc(this.centerx,this.centery,this.radius-54-(prop['chart.text.size']*1.5),greenStart,greenEnd,false);co.arc(this.centerx,this.centery,this.radius-54-(prop['chart.text.size']*1.5)-10,greenEnd,greenStart,true);co.fill();co.strokeStyle=prop['chart.yellow.color'];co.fillStyle=prop['chart.yellow.color'];var yellowStart=greenEnd;var yellowEnd=(((prop['chart.red.start']-this.min)/(this.max-this.min))*RG.HALFPI)+RG.PI+RG.HALFPI;co.beginPath();co.arc(this.centerx,this.centery,this.radius-54-(prop['chart.text.size']*1.5),yellowStart,yellowEnd,false);co.arc(this.centerx,this.centery,this.radius-54-(prop['chart.text.size']*1.5)-10,yellowEnd,yellowStart,true);co.fill();co.strokeStyle=prop['chart.red.color'];co.fillStyle=prop['chart.red.color'];var redStart=yellowEnd;var redEnd=RGraph.TWOPI;co.beginPath();co.arc(this.centerx,this.centery,this.radius-54-(prop['chart.text.size']*1.5),redStart,redEnd,false);co.arc(this.centerx,this.centery,this.radius-54-(prop['chart.text.size']*1.5)-10,redEnd,redStart,true);co.fill();};this.drawLabel=this.DrawLabel=function()
39
+ {if(prop['chart.value.text']){co.strokeStyle=prop['chart.text.color'];co.fillStyle=prop['chart.text.color'];var value=typeof(this.value)=='number'?this.value.toFixed(prop['chart.value.text.decimals']):this.value;if(typeof(value)=='object'){for(var i=0;i<value.length;++i){value[i]=parseFloat(value[i]).toFixed(prop['chart.value.text.decimals']);}
40
+ value=value.toString();}
41
+ RG.Text2(this,{'font':prop['chart.value.text.font'],'size':prop['chart.value.text.size'],'x':this.centerx+(ma.cos((RG.PI/180)*45)*(this.radius/3)),'y':this.centery-(ma.sin((RG.PI/180)*45)*(this.radius/3)),'text':prop['chart.value.text.units.pre']+value+prop['chart.value.text.units.post'],'valign':'center','halign':'center','bounding':prop['chart.value.text.boxed'],'boundingFill':'white','bold':prop['chart.value.text.bold'],'tag':'value.text'});}};this.getShape=function(e){};this.getValue=function(e)
42
+ {var mouseXY=RGraph.getMouseXY(e);var mouseX=mouseXY[0];var mouseY=mouseXY[1];var angle=RG.getAngleByXY(this.centerx,this.centery,mouseX,mouseY);if(angle>RG.TWOPI&&angle<(RG.PI+RG.HALFPI)){return null;}
43
+ var value=((angle-(RG.PI+RG.HALFPI))/(RG.TWOPI-(RG.PI+RG.HALFPI)))*(this.max-this.min);value=value+this.min;if(value<this.min){value=this.min}
44
+ if(value>this.max){value=this.max}
45
+ if(mouseX>this.centerx&&mouseY>this.centery){value=this.max;}
46
+ return value;};this.getObjectByXY=function(e)
47
+ {var mouseXY=RGraph.getMouseXY(e);if(mouseXY[0]>(this.centerx-5)&&mouseXY[0]<(this.centerx+this.radius)&&mouseXY[1]>(this.centery-this.radius)&&mouseXY[1]<(this.centery+5)&&RG.getHypLength(this.centerx,this.centery,mouseXY[0],mouseXY[1])<=this.radius){return this;}};this.adjusting_mousemove=this.Adjusting_mousemove=function(e)
48
+ {if(prop['chart.adjustable']&&RG.Registry.Get('chart.adjusting')&&RG.Registry.Get('chart.adjusting').uid==this.uid){this.value=this.getValue(e);RG.Clear(ca);RG.RedrawCanvas(ca);RG.FireCustomEvent(this,'onadjust');}};this.getAngle=function(value)
49
+ {if(value<this.min||value>this.max){return null;}
50
+ var angle=((value-this.min)/(this.max-this.min))*RG.HALFPI
51
+ angle+=(RG.PI+RG.HALFPI);return angle;};this.parseColors=function()
52
+ {if(this.original_colors.length===0){this.original_colors['chart.colors.ranges']=RG.array_clone(prop['chart.colors.ranges']);this.original_colors['chart.green.color']=RG.array_clone(prop['chart.green.color']);this.original_colors['chart.yellow.color']=RG.array_clone(prop['chart.yellow.color']);this.original_colors['chart.red.color']=RG.array_clone(prop['chart.red.color']);}
53
+ if(!RG.is_null(prop['chart.colors.ranges'])){for(var i=0;i<prop['chart.colors.ranges'].length;++i){prop['chart.colors.ranges'][i][2]=this.parseSingleColorForGradient(prop['chart.colors.ranges'][i][2]);}}else{prop['chart.green.color']=this.parseSingleColorForGradient(prop['chart.green.color']);prop['chart.yellow.color']=this.parseSingleColorForGradient(prop['chart.yellow.color']);prop['chart.red.color']=this.parseSingleColorForGradient(prop['chart.red.color']);}};this.reset=function()
54
+ {};this.parseSingleColorForGradient=function(color)
55
+ {if(!color||typeof(color)!='string'){return color;}
56
+ if(color.match(/^gradient\((.*)\)$/i)){var parts=RegExp.$1.split(':');var radius_start=this.radius-54-prop['chart.text.size'];var radius_end=radius_start-15;var grad=co.createRadialGradient(this.centerx,this.centery,radius_start,this.centerx,this.centery,radius_end);var 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]));}}
57
+ return grad?grad:color;};this.on=function(type,func)
58
+ {if(type.substr(0,2)!=='on'){type='on'+type;}
59
+ this[type]=func;return this;};this.firstDrawFunc=function()
60
+ {};this.grow=function()
61
+ {var opt=arguments[0];var callback=arguments[1];var numFrames=30;var frame=0;var obj=this;if(typeof this.value==='number'){var origValue=Number(this.currentValue);if(this.currentValue===null){this.currentValue=this.min;origValue=this.min;}
62
+ var newValue=this.value;var diff=newValue-origValue;var step=(diff/numFrames);var frame=0;var iterator=function()
63
+ {frame++;obj.value=((frame/numFrames)*diff)+origValue
64
+ if(obj.value>obj.max)obj.value=obj.max;if(obj.value<obj.min)obj.value=obj.min;RGraph.Clear(obj.canvas);RGraph.RedrawCanvas(obj.canvas);if(frame<30){RGraph.Effects.updateCanvas(iterator);}else if(typeof callback==='function'){callback(obj);}};iterator();}else{if(obj.currentValue==null){obj.currentValue=[];for(var i=0,len=obj.value.length;i<len;++i){obj.currentValue[i]=obj.min;}
65
+ origValue=RG.array_clone(obj.currentValue);}
66
+ var origValue=RG.array_clone(obj.currentValue);var newValue=RG.array_clone(obj.value);var diff=[];var step=[];for(var i=0,len=newValue.length;i<len;++i){diff[i]=newValue[i]-Number(obj.currentValue[i]);step[i]=(diff[i]/numFrames);}
67
+ var max=this.max;var min=this.min;var iterator=function()
68
+ {frame++;for(var i=0,len=obj.value.length;i<len;++i){obj.value[i]=((frame/numFrames)*diff[i])+origValue[i];if(obj.value[i]>max)obj.value[i]=max;if(obj.value[i]<min)obj.value[i]=min;RG.clear(obj.canvas);RG.redrawCanvas(obj.canvas);}
69
+ if(frame<30){RG.Effects.updateCanvas(iterator);}else if(typeof callback==='function'){callback(obj);}};iterator();}
70
+ return this;}
71
+ RG.Register(this);if(parseConfObjectForOptions){RG.parseObjectStyleConfig(this,conf.options);}};
@@ -1,571 +1,35 @@
1
- // version: 2017-05-08
2
- /**
3
- * o--------------------------------------------------------------------------------o
4
- * | This file is part of the RGraph package - you can learn more at: |
5
- * | |
6
- * | http://www.rgraph.net |
7
- * | |
8
- * | RGraph is licensed under the Open Source MIT license. That means that it's |
9
- * | totally free to use! |
10
- * o--------------------------------------------------------------------------------o
11
- */
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
1
 
18
- // Define the RGraph global variable
19
- RGraph = window.RGraph || {isRGraph: true};
20
- RGraph.Drawing = RGraph.Drawing || {};
21
-
22
- /**
23
- * The constructor. This function sets up the object. It only takes the ID (the HTML attribute) of the canvas as the
24
- * first argument - the gutters are set as properties.
25
- *
26
- * @param string id The canvas tag ID
27
- */
28
- RGraph.Drawing.Background = function (conf)
29
- {
30
- /**
31
- * Allow for object config style
32
- */
33
- if ( typeof conf === 'object'
34
- && typeof conf.id === 'string') {
35
-
36
- var id = conf.id,
37
- canvas = document.getElementById(id),
38
- parseConfObjectForOptions = true; // Set this so the config is parsed (at the end of the constructor)
39
-
40
- } else {
41
-
42
- var id = conf,
43
- canvas = document.getElementById(id);
44
- }
45
-
46
-
47
-
48
-
49
- this.id = id;
50
- this.canvas = document.getElementById(this.id);
51
- this.context = this.canvas.getContext('2d');
52
- this.canvas.__object__ = this;
53
- this.original_colors = [];
54
- this.firstDraw = true; // After the first draw this will be false
55
-
56
-
57
- /**
58
- * This defines the type of this shape
59
- */
60
- this.type = 'drawing.background';
61
-
62
-
63
- /**
64
- * This facilitates easy object identification, and should always be true
65
- */
66
- this.isRGraph = true;
67
-
68
-
69
- /**
70
- * This adds a uid to the object that you can use for identification purposes
71
- */
72
- this.uid = RGraph.CreateUID();
73
-
74
-
75
- /**
76
- * This adds a UID to the canvas for identification purposes
77
- */
78
- this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.createUID();
79
-
80
-
81
-
82
-
83
- /**
84
- * Some example background properties
85
- */
86
- this.properties =
87
- {
88
- 'chart.background.barcolor1': 'rgba(0,0,0,0)',
89
- 'chart.background.barcolor2': 'rgba(0,0,0,0)',
90
- 'chart.background.grid': true,
91
- 'chart.background.grid.color': '#ddd',
92
- 'chart.background.grid.width': 1,
93
- 'chart.background.grid.vlines': true,
94
- 'chart.background.grid.hlines': true,
95
- 'chart.background.grid.border': true,
96
- 'chart.background.grid.autofit':true,
97
- 'chart.background.grid.autofit.numhlines': 5,
98
- 'chart.background.grid.autofit.numvlines': 20,
99
- 'chart.background.grid.dashed': false,
100
- 'chart.background.grid.dotted': false,
101
-
102
- 'chart.background.image': null,
103
- 'chart.background.image.stretch': true,
104
- 'chart.background.image.x': null,
105
- 'chart.background.image.y': null,
106
- 'chart.background.image.w': null,
107
- 'chart.background.image.h': null,
108
- 'chart.background.image.align': null,
109
- 'chart.background.color': null,
110
-
111
- 'chart.gutter.left': 25,
112
- 'chart.gutter.right': 25,
113
- 'chart.gutter.top': 25,
114
- 'chart.gutter.bottom': 25,
115
-
116
- 'chart.text.color': 'black', // Gradients aren't supported for this color
117
- 'chart.text.size': 12,
118
- 'chart.text.font': 'Segoe UI, Arial, Verdana, sans-serif',
119
- 'chart.text.accessible': true,
120
- 'chart.text.accessible.overflow': 'visible',
121
- 'chart.text.accessible.pointerevents': true,
122
- 'chart.events.click': null,
123
- 'chart.events.mousemove': null,
124
-
125
- 'chart.tooltips': null,
126
- 'chart.tooltips.highlight': true,
127
- 'chart.tooltips.event': 'onclick',
128
-
129
- 'chart.highlight.stroke': 'rgba(0,0,0,0)',
130
- 'chart.highlight.fill': 'rgba(255,255,255,0.7)',
131
-
132
- 'chart.linewidth': 1,
133
-
134
- 'chart.title': '',
135
- 'chart.title.size': null,
136
- 'chart.title.font': null,
137
- 'chart.title.background': null, // Gradients aren't supported for this color
138
- 'chart.title.hpos': null,
139
- 'chart.title.vpos': null,
140
- 'chart.title.bold': true,
141
- 'chart.title.color': 'black',
142
- 'chart.title.x': null,
143
- 'chart.title.y': null,
144
- 'chart.title.halign': null,
145
- 'chart.title.valign': null,
146
-
147
- 'chart.title.xaxis': '',
148
- 'chart.title.xaxis.bold': true,
149
- 'chart.title.xaxis.size': null,
150
- 'chart.title.xaxis.font': null,
151
- 'chart.title.xaxis.x': null,
152
- 'chart.title.xaxis.y': null,
153
- 'chart.title.xaxis.pos': null,
154
-
155
- 'chart.title.yaxis': '',
156
- 'chart.title.yaxis.bold': true,
157
- 'chart.title.yaxis.size': null,
158
- 'chart.title.yaxis.font': null,
159
- 'chart.title.yaxis.color': 'black', // Gradients aren't supported for this color
160
- 'chart.title.yaxis.x': null,
161
- 'chart.title.yaxis.y': null,
162
- 'chart.title.yaxis.pos': null,
163
- 'chart.clearto': 'rgba(0,0,0,0)'
164
- }
165
-
166
- /**
167
- * A simple check that the browser has canvas support
168
- */
169
- if (!this.canvas) {
170
- alert('[DRAWING.BACKGROUND] No canvas support');
171
- return;
172
- }
173
-
174
-
175
-
176
- /**
177
- * Create the dollar object so that functions can be added to them
178
- */
179
- this.$0 = {};
180
-
181
-
182
-
183
- /**
184
- * Translate half a pixel for antialiasing purposes - but only if it hasn't beeen
185
- * done already
186
- */
187
- if (!this.canvas.__rgraph_aa_translated__) {
188
- this.context.translate(0.5,0.5);
189
- this.canvas.__rgraph_aa_translated__ = true;
190
- }
191
-
192
-
193
-
194
-
195
- // Short variable names
196
- var RG = RGraph,
197
- ca = this.canvas,
198
- co = ca.getContext('2d'),
199
- prop = this.properties,
200
- pa = RG.Path,
201
- pa2 = RG.path2,
202
- win = window,
203
- doc = document,
204
- ma = Math
205
-
206
-
207
-
208
- /**
209
- * "Decorate" the object with the generic effects if the effects library has been included
210
- */
211
- if (RG.Effects && typeof RG.Effects.decorate === 'function') {
212
- RG.Effects.decorate(this);
213
- }
214
-
215
-
216
-
217
-
218
- /**
219
- * A setter method for setting graph properties. It can be used like this: obj.Set('chart.strokestyle', '#666');
220
- *
221
- * @param name string The name of the property to set OR it can be a map
222
- * of name/value settings like what you set in the constructor
223
- */
224
- this.set =
225
- this.Set = function (name)
226
- {
227
- var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
228
-
229
- /**
230
- * the number of arguments is only one and it's an
231
- * object - parse it for configuration data and return.
232
- */
233
- if (arguments.length === 1 && typeof name === 'object') {
234
- RG.parseObjectStyleConfig(this, name);
235
- return this;
236
- }
237
-
238
-
239
-
240
-
241
-
242
- /**
243
- * This should be done first - prepend the property name with "chart." if necessary
244
- */
245
- if (name.substr(0,6) != 'chart.') {
246
- name = 'chart.' + name;
247
- }
248
-
249
-
250
-
251
- // Convert uppercase letters to dot+lower case letter
252
- while(name.match(/([A-Z])/)) {
253
- name = name.replace(/([A-Z])/, '.' + RegExp.$1.toLowerCase());
254
- }
255
-
256
-
257
- prop[name] = value;
258
-
259
- return this;
260
- };
261
-
262
-
263
-
264
-
265
- /**
266
- * A getter method for retrieving graph properties. It can be used like this: obj.Get('chart.strokestyle');
267
- *
268
- * @param name string The name of the property to get
269
- */
270
- this.get =
271
- this.Get = function (name)
272
- {
273
- /**
274
- * This should be done first - prepend the property name with "chart." if necessary
275
- */
276
- if (name.substr(0,6) != 'chart.') {
277
- name = 'chart.' + name;
278
- }
279
-
280
- // Convert uppercase letters to dot+lower case letter
281
- while(name.match(/([A-Z])/)) {
282
- name = name.replace(/([A-Z])/, '.' + RegExp.$1.toLowerCase());
283
- }
284
-
285
- return prop[name.toLowerCase()];
286
- };
287
-
288
-
289
-
290
-
291
- /**
292
- * Draws the circle
293
- */
294
- this.draw =
295
- this.Draw = function ()
296
- {
297
- /**
298
- * Fire the onbeforedraw event
299
- */
300
- RG.fireCustomEvent(this, 'onbeforedraw');
301
-
302
-
303
- /***********************
304
- * DRAW BACKGROUND HERE *
305
- ***********************/
306
- this.gutterLeft = prop['chart.gutter.left'];
307
- this.gutterRight = prop['chart.gutter.right'];
308
- this.gutterTop = prop['chart.gutter.top'];
309
- this.gutterBottom = prop['chart.gutter.bottom'];
310
-
311
-
312
- /**
313
- * Parse the colors. This allows for simple gradient syntax
314
- */
315
- if (!this.colorsParsed) {
316
-
317
- this.parseColors();
318
-
319
- // Don't want to do this again
320
- this.colorsParsed = true;
321
- }
322
-
323
- /**
324
- * Set the shadow
325
- */
326
- RG.drawBackgroundImage(this);
327
- RG.Background.draw(this);
328
-
329
- /**
330
- * This installs the event listeners
331
- */
332
- RG.installEventListeners(this);
333
-
334
-
335
- /**
336
- * Fire the onfirstdraw event
337
- */
338
- if (this.firstDraw) {
339
- RG.fireCustomEvent(this, 'onfirstdraw');
340
- this.firstDraw = false;
341
- this.firstDrawFunc();
342
- }
343
-
344
-
345
-
346
- /**
347
- * Fire the ondraw event
348
- */
349
- RG.fireCustomEvent(this, 'ondraw');
350
-
351
- return this;
352
- };
353
-
354
-
355
-
356
-
357
- /**
358
- * Used in chaining. Runs a function there and then - not waiting for
359
- * the events to fire (eg the onbeforedraw event)
360
- *
361
- * @param function func The function to execute
362
- */
363
- this.exec = function (func)
364
- {
365
- func(this);
366
-
367
- return this;
368
- };
369
-
370
-
371
-
372
-
373
- /**
374
- * The getObjectByXY() worker method
375
- */
376
- this.getObjectByXY = function (e)
377
- {
378
- if (this.getShape(e)) {
379
- return this;
380
- }
381
- };
382
-
383
-
384
-
385
-
386
- /**
387
- * Not used by the class during creating the shape, but is used by event handlers
388
- * to get the coordinates (if any) of the selected bar
389
- *
390
- * @param object e The event object
391
- * @param object OPTIONAL You can pass in the bar object instead of the
392
- * function using "this"
393
- */
394
- this.getShape = function (e)
395
- {
396
- var mouseXY = RG.getMouseXY(e),
397
- mouseX = mouseXY[0],
398
- mouseY = mouseXY[1];
399
-
400
- if (
401
- mouseX >= this.gutterLeft
402
- && mouseX <= (ca.width - this.gutterRight)
403
- && mouseY >= this.gutterTop
404
- && mouseY <= (ca.height - this.gutterBottom)
405
- ) {
406
-
407
- var tooltip = prop['chart.tooltips'] ? prop['chart.tooltips'][0] : null
408
-
409
- return {
410
- 0: this, 1: 0 /* the index */, 2: tooltip,
411
- 'object': this,'index': 0, 'tooltip': tooltip
412
- };
413
- }
414
-
415
- return null;
416
- };
417
-
418
-
419
-
420
-
421
- /**
422
- * Each object type has its own Highlight() function which highlights the appropriate shape
423
- *
424
- * @param object shape The shape to highlight
425
- */
426
- this.highlight =
427
- this.Highlight = function (shape)
428
- {
429
- if (prop['chart.tooltips.highlight']) {
430
- if (typeof prop['chart.highlight.style'] === 'function') {
431
- (prop['chart.highlight.style'])(shape);
432
- } else {
433
- pa2(co,
434
- 'b r % % % % f % s %',
435
- prop['chart.gutter.left'],
436
- prop['chart.gutter.top'],
437
- ca.width - prop['chart.gutter.left'] - prop['chart.gutter.right'],
438
- ca.height - prop['chart.gutter.top'] - prop['chart.gutter.bottom'],
439
- prop['chart.highlight.fill'],
440
- prop['chart.highlight.stroke']
441
- );
442
- }
443
- }
444
- };
445
-
446
-
447
-
448
-
449
- /**
450
- * This allows for easy specification of gradients
451
- */
452
- this.parseColors = function ()
453
- {
454
- // Save the original colors so that they can be restored when the canvas is reset
455
- if (this.original_colors.length === 0) {
456
- this.original_colors['chart.strokestyle'] = RG.arrayClone(prop['chart.strokestyle']);
457
- this.original_colors['chart.highlight.stroke'] = RG.arrayClone(prop['chart.highlight.stroke']);
458
- this.original_colors['chart.highlight.fill'] = RG.arrayClone(prop['chart.highlight.fill']);
459
- }
460
-
461
-
462
-
463
-
464
-
465
- /**
466
- * Parse various properties for colors
467
- */
468
- prop['chart.strokestyle'] = this.parseSingleColorForGradient(prop['chart.strokestyle']);
469
- prop['chart.highlight.stroke'] = this.parseSingleColorForGradient(prop['chart.highlight.stroke']);
470
- prop['chart.highlight.fill'] = this.parseSingleColorForGradient(prop['chart.highlight.fill']);
471
- };
472
-
473
-
474
-
475
-
476
- /**
477
- * Use this function to reset the object to the post-constructor state. Eg reset colors if
478
- * need be etc
479
- */
480
- this.reset = function ()
481
- {
482
- };
483
-
484
-
485
-
486
-
487
- /**
488
- * This parses a single color value
489
- */
490
- this.parseSingleColorForGradient = function (color)
491
- {
492
- if (!color) {
493
- return color;
494
- }
495
-
496
- if (typeof color === 'string' && color.match(/^gradient\((.*)\)$/i)) {
497
-
498
- // Split and create the gradient
499
- var parts = RegExp.$1.split(':'),
500
- grad = co.createLinearGradient(
501
- this.gutterLeft,
502
- this.gutterTop,
503
- ca.width - this.gutterRight,
504
- ca.height - this.gutterRight
505
- ),
506
- diff = 1 / (parts.length - 1);
507
-
508
- //grad.addColorStop(0, RG.trim(parts[0]));
509
-
510
- for (var j=0; j<parts.length; j+=1) {
511
- grad.addColorStop(j * diff, RG.trim(parts[j]));
512
- }
513
- }
514
-
515
- return grad ? grad : color;
516
- };
517
-
518
-
519
-
520
-
521
- /**
522
- * Using a function to add events makes it easier to facilitate method chaining
523
- *
524
- * @param string type The type of even to add
525
- * @param function func
526
- */
527
- this.on = function (type, func)
528
- {
529
- if (type.substr(0,2) !== 'on') {
530
- type = 'on' + type;
531
- }
532
-
533
- if (typeof this[type] !== 'function') {
534
- this[type] = func;
535
- } else {
536
- RG.addCustomEventListener(this, type, func);
537
- }
538
-
539
- return this;
540
- };
541
-
542
-
543
-
544
-
545
- /**
546
- * This function runs once only
547
- * (put at the end of the file (before any effects))
548
- */
549
- this.firstDrawFunc = function ()
550
- {
551
- };
552
-
553
-
554
-
555
-
556
- /**
557
- * Objects are now always registered so that the chart is redrawn if need be.
558
- */
559
- RG.register(this);
560
-
561
-
562
-
563
-
564
- /**
565
- * This is the 'end' of the constructor so if the first argument
566
- * contains configuration data - handle that.
567
- */
568
- if (parseConfObjectForOptions) {
569
- RG.parseObjectStyleConfig(this, conf.options);
570
- }
571
- };
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.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.barcolor1':'rgba(0,0,0,0)','chart.background.barcolor2':'rgba(0,0,0,0)','chart.background.grid':true,'chart.background.grid.color':'#ddd','chart.background.grid.width':1,'chart.background.grid.vlines':true,'chart.background.grid.hlines':true,'chart.background.grid.border':true,'chart.background.grid.autofit':true,'chart.background.grid.autofit.numhlines':5,'chart.background.grid.autofit.numvlines':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.gutter.left':25,'chart.gutter.right':25,'chart.gutter.top':25,'chart.gutter.bottom':25,'chart.text.color':'black','chart.text.size':12,'chart.text.font':'Segoe UI, Arial, Verdana, sans-serif','chart.text.accessible':true,'chart.text.accessible.overflow':'visible','chart.text.accessible.pointerevents':true,'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.size':null,'chart.title.font':null,'chart.title.background':null,'chart.title.hpos':null,'chart.title.vpos':null,'chart.title.bold':true,'chart.title.color':'black','chart.title.x':null,'chart.title.y':null,'chart.title.halign':null,'chart.title.valign':null,'chart.title.xaxis':'','chart.title.xaxis.bold':true,'chart.title.xaxis.size':null,'chart.title.xaxis.font':null,'chart.title.xaxis.x':null,'chart.title.xaxis.y':null,'chart.title.xaxis.pos':null,'chart.title.yaxis':'','chart.title.yaxis.bold':true,'chart.title.yaxis.size':null,'chart.title.yaxis.font':null,'chart.title.yaxis.color':'black','chart.title.yaxis.x':null,'chart.title.yaxis.y':null,'chart.title.yaxis.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.gutterLeft=prop['chart.gutter.left'];this.gutterRight=prop['chart.gutter.right'];this.gutterTop=prop['chart.gutter.top'];this.gutterBottom=prop['chart.gutter.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.gutterLeft&&mouseX<=(ca.width-this.gutterRight)&&mouseY>=this.gutterTop&&mouseY<=(ca.height-this.gutterBottom)){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.gutter.left'],prop['chart.gutter.top'],ca.width-prop['chart.gutter.left']-prop['chart.gutter.right'],ca.height-prop['chart.gutter.top']-prop['chart.gutter.bottom'],prop['chart.highlight.fill'],prop['chart.highlight.stroke']);}}};this.parseColors=function()
26
+ {if(this.original_colors.length===0){this.original_colors['chart.strokestyle']=RG.arrayClone(prop['chart.strokestyle']);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.strokestyle']=this.parseSingleColorForGradient(prop['chart.strokestyle']);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)){var parts=RegExp.$1.split(':'),grad=co.createLinearGradient(this.gutterLeft,this.gutterTop,ca.width-this.gutterRight,ca.height-this.gutterRight),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);}};