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,274 +1,23 @@
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,isRGraphSVG: true};
14
- RGraph.SVG = RGraph.SVG || {};
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
- * This is used in two functions, hence it's here
27
- */
28
- RG.SVG.tooltips = {};
29
- RG.SVG.tooltips.style = {
30
- display: 'inline-block',
31
- position: 'absolute',
32
- padding: '6px',
33
- fontFamily: 'Arial',
34
- fontSize: '12pt',
35
- fontWeight: 'normal',
36
- textAlign: 'center',
37
- left: 0,
38
- top: 0,
39
- backgroundColor: 'rgb(255,255,239)',
40
- color: 'black',
41
- visibility: 'visible',
42
- zIndex: 3,
43
- borderRadius: '5px',
44
- boxShadow: 'rgba(96,96,96,0.5) 0 0 5px',
45
- transition: 'left ease-out .25s, top ease-out .25s'
46
- };
47
-
48
-
49
- //
50
- // Shows a tooltip
51
- //
52
- // @param obj The chart object
53
- // @param opt The options
54
- //
55
- RG.SVG.tooltip = function (opt)
56
- {
57
- var obj = opt.object;
58
-
59
- // Fire the beforetooltip event
60
- RG.SVG.fireCustomEvent(obj, 'onbeforetooltip');
61
-
62
-
63
- if (!opt.text || typeof opt.text === 'undefined' || RG.SVG.trim(opt.text).length === 0) {
64
- return;
65
- }
66
-
67
-
68
-
69
- var prop = obj.properties;
70
-
71
-
72
-
73
- /**
74
- * chart.tooltip.override allows you to totally take control of rendering the tooltip yourself
75
- */
76
- if (typeof prop.tooltipsOverride === 'function') {
77
- return (prop.tooltipsOverride)(obj, opt);
78
- }
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
- // Create the tooltip DIV element
88
- if (!RG.SVG.REG.get('tooltip')) {
89
-
90
- var tooltipObj = document.createElement('DIV');
91
- tooltipObj.className = prop.tooltipsCssClass;
92
-
93
-
94
-
95
-
96
- // Add the default CSS to the tooltip
97
- for (var i in RG.SVG.tooltips.style) {
98
- if (typeof i === 'string') {
99
- tooltipObj.style[i] = RG.SVG.tooltips.style[i];
100
- }
101
- }
102
-
103
-
104
-
105
-
106
-
107
- // Reuse an existing tooltip
108
- } else {
109
- var tooltipObj = RG.SVG.REG.get('tooltip');
110
- tooltipObj.__object__.removeHighlight();
111
-
112
- // This prevents the object from continuously growing
113
- tooltipObj.style.width = '';
114
- }
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
- if (RG.SVG.REG.get('tooltip-lasty')) {
133
- tooltipObj.style.left = RG.SVG.REG.get('tooltip-lastx') + 'px';
134
- tooltipObj.style.top = RG.SVG.REG.get('tooltip-lasty') + 'px';
135
- }
136
-
137
- tooltipObj.innerHTML = opt.text;
138
- tooltipObj.__text__ = opt.text; // This is set because the innerHTML can change when it's set
139
- tooltipObj.id = '__rgraph_tooltip_' + obj.id + '_' + obj.uid + '_'+ opt.index;
140
- tooltipObj.__event__ = prop.tooltipsEvent || 'click';
141
- tooltipObj.__object__ = obj;
142
-
143
- // Add the index
144
- if (typeof opt.index === 'number') {
145
- tooltipObj.__index__ = opt.index;
146
- }
147
-
148
- // Add the dataset
149
- if (typeof opt.dataset === 'number') {
150
- tooltipObj.__dataset__ = opt.dataset;
151
- }
152
-
153
- // Add the group
154
- if (typeof opt.group === 'number' || RG.SVG.isNull(opt.group)) {
155
- tooltipObj.__group__ = opt.group;
156
- }
157
-
158
- // Add the sequentialIndex
159
- if (typeof opt.sequentialIndex === 'number') {
160
- tooltipObj.__sequentialIndex__ = opt.sequentialIndex;
161
- }
162
-
163
-
164
-
165
-
166
- // Add the tooltip to the document
167
- document.body.appendChild(tooltipObj);
168
-
169
-
170
- var width = tooltipObj.offsetWidth,
171
- height = tooltipObj.offsetHeight;
172
-
173
- // Move the tooltip into position
174
- tooltipObj.style.left = opt.event.pageX - (width / 2) + 'px';
175
- tooltipObj.style.top = opt.event.pageY - height - 15 + 'px';
176
-
177
-
178
-
179
-
180
- /**
181
- * Set the width on the tooltip so it doesn't resize if the window is resized
182
- */
183
- tooltipObj.style.width = width + 'px';
184
-
185
- // Fade the tooltip in if the tooltip is not the first view
186
- if (!RG.SVG.REG.get('tooltip-lastx')) {
187
- for (var i=0; i<=30; ++i) {
188
- (function (idx)
189
- {
190
- setTimeout(function ()
191
- {
192
- tooltipObj.style.opacity = (idx / 30) * 1;
193
- }, (idx / 30) * 200);
194
- })(i);
195
- }
196
- }
197
-
198
-
199
-
200
-
201
- // If the left is less than zero - set it to 5
202
- if (parseFloat(tooltipObj.style.left) <= 5) {
203
- tooltipObj.style.left = '5px';
204
- }
205
-
206
- // If the tooltip goes over the right hand edge then
207
- // adjust the positioning
208
- if (parseFloat(tooltipObj.style.left) + parseFloat(tooltipObj.style.width) > window.innerWidth) {
209
- tooltipObj.style.left = ''
210
- tooltipObj.style.right = '5px'
211
- }
212
-
213
-
214
-
215
-
216
- // If the canvas has fixed positioning then set the tooltip position to
217
- // fixed too
218
- if (RG.SVG.isFixed(obj.svg)) {
219
- var scrollTop = window.scrollY || document.documentElement.scrollTop;
220
-
221
- tooltipObj.style.position = 'fixed';
222
- tooltipObj.style.top = opt.event.pageY - scrollTop - height - 10 + 'px';
223
- }
224
-
225
-
226
-
227
- // Cancel the mousedown event
228
- tooltipObj.onmousedown = function (e)
229
- {
230
- e.stopPropagation();
231
- };
232
-
233
- // Cancel the mouseup event
234
- tooltipObj.onmouseup = function (e)
235
- {
236
- e.stopPropagation();
237
- };
238
-
239
- // Cancel the click event
240
- tooltipObj.onclick = function (e)
241
- {
242
- if (e.button == 0) {
243
- e.stopPropagation();
244
- }
245
- };
246
-
247
- // Add the body click handler that clears the tooltip
248
- document.body.addEventListener('mouseup', function (e)
249
- {
250
- RG.SVG.hideTooltip();
251
- }, false);
252
-
253
-
254
-
255
-
256
-
257
- /**
258
- * Keep a reference to the tooltip in the registry
259
- */
260
- RG.SVG.REG.set('tooltip', tooltipObj);
261
- RG.SVG.REG.set('tooltip-lastx', parseFloat(tooltipObj.style.left));
262
- RG.SVG.REG.set('tooltip-lasty', parseFloat(tooltipObj.style.top));
263
-
264
-
265
- //
266
- // Fire the tooltip event
267
- //
268
- RG.SVG.fireCustomEvent(obj, 'ontooltip');
269
- };
270
-
271
-
272
-
273
- // End module pattern
274
- })(window, document);
2
+ RGraph=window.RGraph||{isRGraph:true,isRGraphSVG:true};RGraph.SVG=RGraph.SVG||{};(function(win,doc,undefined)
3
+ {var RG=RGraph,ua=navigator.userAgent,ma=Math;RG.SVG.tooltips={};RG.SVG.tooltips.style={display:'inline-block',position:'absolute',padding:'6px',fontFamily:'Arial',fontSize:'12pt',fontWeight:'normal',textAlign:'center',left:0,top:0,backgroundColor:'rgb(255,255,239)',color:'black',visibility:'visible',zIndex:3,borderRadius:'5px',boxShadow:'rgba(96,96,96,0.5) 0 0 5px',transition:'left ease-out .25s, top ease-out .25s'};RG.SVG.tooltip=function(opt)
4
+ {var obj=opt.object;RG.SVG.fireCustomEvent(obj,'onbeforetooltip');if(!opt.text||typeof opt.text==='undefined'||RG.SVG.trim(opt.text).length===0){return;}
5
+ var prop=obj.properties;if(typeof prop.tooltipsOverride==='function'){return(prop.tooltipsOverride)(obj,opt);}
6
+ if(!RG.SVG.REG.get('tooltip')){var tooltipObj=document.createElement('DIV');tooltipObj.className=prop.tooltipsCssClass;for(var i in RG.SVG.tooltips.style){if(typeof i==='string'){tooltipObj.style[i]=RG.SVG.tooltips.style[i];}}}else{var tooltipObj=RG.SVG.REG.get('tooltip');tooltipObj.__object__.removeHighlight();tooltipObj.style.width='';}
7
+ if(RG.SVG.REG.get('tooltip-lasty')){tooltipObj.style.left=RG.SVG.REG.get('tooltip-lastx')+'px';tooltipObj.style.top=RG.SVG.REG.get('tooltip-lasty')+'px';}
8
+ tooltipObj.innerHTML=opt.text;tooltipObj.__text__=opt.text;tooltipObj.id='__rgraph_tooltip_'+obj.id+'_'+obj.uid+'_'+opt.index;tooltipObj.__event__=prop.tooltipsEvent||'click';tooltipObj.__object__=obj;if(typeof opt.index==='number'){tooltipObj.__index__=opt.index;}
9
+ if(typeof opt.dataset==='number'){tooltipObj.__dataset__=opt.dataset;}
10
+ if(typeof opt.group==='number'||RG.SVG.isNull(opt.group)){tooltipObj.__group__=opt.group;}
11
+ if(typeof opt.sequentialIndex==='number'){tooltipObj.__sequentialIndex__=opt.sequentialIndex;}
12
+ document.body.appendChild(tooltipObj);var width=tooltipObj.offsetWidth,height=tooltipObj.offsetHeight;tooltipObj.style.left=opt.event.pageX-(width/2)+'px';tooltipObj.style.top=opt.event.pageY-height-15+'px';tooltipObj.style.width=width+'px';if(!RG.SVG.REG.get('tooltip-lastx')){for(var i=0;i<=30;++i){(function(idx)
13
+ {setTimeout(function()
14
+ {tooltipObj.style.opacity=(idx/30)*1;},(idx/30)*200);})(i);}}
15
+ if(parseFloat(tooltipObj.style.left)<=5){tooltipObj.style.left='5px';}
16
+ if(parseFloat(tooltipObj.style.left)+parseFloat(tooltipObj.style.width)>window.innerWidth){tooltipObj.style.left=''
17
+ tooltipObj.style.right='5px'}
18
+ if(RG.SVG.isFixed(obj.svg)){var scrollTop=window.scrollY||document.documentElement.scrollTop;tooltipObj.style.position='fixed';tooltipObj.style.top=opt.event.pageY-scrollTop-height-10+'px';}
19
+ tooltipObj.onmousedown=function(e)
20
+ {e.stopPropagation();};tooltipObj.onmouseup=function(e)
21
+ {e.stopPropagation();};tooltipObj.onclick=function(e)
22
+ {if(e.button==0){e.stopPropagation();}};document.body.addEventListener('mouseup',function(e)
23
+ {RG.SVG.hideTooltip();},false);RG.SVG.REG.set('tooltip',tooltipObj);RG.SVG.REG.set('tooltip-lastx',parseFloat(tooltipObj.style.left));RG.SVG.REG.set('tooltip-lasty',parseFloat(tooltipObj.style.top));RG.SVG.fireCustomEvent(obj,'ontooltip');};})(window,document);
@@ -0,0 +1,32 @@
1
+
2
+ RGraph=window.RGraph||{isRGraph:true};RGraph.SVG=RGraph.SVG||{};(function(win,doc,undefined)
3
+ {var RG=RGraph,ua=navigator.userAgent,ma=Math,win=window,doc=document;RG.SVG.Funnel=function(conf)
4
+ {this.set=function(name,value)
5
+ {if(arguments.length===1&&typeof name==='object'){for(i in arguments[0]){if(typeof i==='string'){var ret=RG.SVG.commonSetter({object:this,name:i,value:arguments[0][i]});name=ret.name;value=ret.value;this.set(name,value);}}}else{var ret=RG.SVG.commonSetter({object:this,name:name,value:value});name=ret.name;value=ret.value;this.properties[name]=value;if(name==='colors'){this.originalColors=RG.SVG.arrayClone(value);this.colorsParsed=false;}}
6
+ return this;};this.id=conf.id;this.uid=RG.SVG.createUID();this.container=document.getElementById(this.id);this.layers={};this.svg=RG.SVG.createSVG({object:this,container:this.container});this.isRGraph=true;this.width=Number(this.svg.getAttribute('width'));this.height=Number(this.svg.getAttribute('height'));this.data=RG.SVG.arrayClone(conf.data);this.originalData=RG.SVG.arrayClone(conf.data);this.type='funnel';this.coords=[];this.colorsParsed=false;this.originalColors={};this.gradientCounter=1;this.nodes=[];this.shadowNodes=[];this.max=0;this.redraw=false;this.highlight_node=null;RG.SVG.OR.add(this);this.container.style.display='inline-block';var obj=this;this.data.forEach(function(val,key,arr)
7
+ {obj.max=ma.max(obj.max,val);});this.properties={gutterLeft:35,gutterRight:35,gutterTop:35,gutterBottom:35,backgroundbars:false,backgroundBarsOpacity:0.25,backgroundBarsColors:null,strokestyle:'white',colors:['red','black','orange','green','#6ff','#ccc','pink','orange','cyan','maroon','olive','teal'],colorsOpacity:1,textColor:'black',textFont:'sans-serif',textSize:12,textBold:false,textItalic:false,labels:[],labelsFont:null,labelsSize:null,labelsColor:null,labelsBold:null,labelsItalic:null,labelsBackground:null,labelsAlign:'center',labelsPosition:'section',linewidth:1,tooltips:null,tooltipsOverride:null,tooltipsEffect:'fade',tooltipsCssClass:'RGraph_tooltip',tooltipsEvent:'click',highlightStroke:'rgba(0,0,0,0)',highlightFill:'rgba(255,255,255,0.3)',highlightLinewidth:1,title:'',titleSize:16,titleX:null,titleY:null,titleHalign:'center',titleValign:null,titleColor:'black',titleFont:null,titleBold:false,titleItalic:false,titleSubtitle:'',titleSubtitleSize:10,titleSubtitleX:null,titleSubtitleY:null,titleSubtitleHalign:'center',titleSubtitleValign:null,titleSubtitleColor:'#aaa',titleSubtitleFont:null,titleSubtitleBold:false,titleSubtitleItalic:false,shadow:false,shadowOffsetx:2,shadowOffsety:2,shadowBlur:2,shadowOpacity:0.25,key:null,keyColors:null,keyOffsetx:0,keyOffsety:0,keyTextOffsetx:0,keyTextOffsety:-1,keyTextSize:null,keyTextBold:null,keyTextItalic:null};RG.SVG.getGlobals(this);if(RG.SVG.FX&&typeof RG.SVG.FX.decorate==='function'){RG.SVG.FX.decorate(this);}
8
+ var prop=this.properties;this.draw=function()
9
+ {RG.SVG.fireCustomEvent(this,'onbeforedraw');this.data=RG.SVG.arrayClone(this.originalData);this.coords=[];RG.SVG.createDefs(this);this.graphWidth=this.width-prop.gutterLeft-prop.gutterRight;this.graphHeight=this.height-prop.gutterTop-prop.gutterBottom;for(var i=0,len=this.data.length;i<len;++i){if(typeof this.data[i]==='string'){this.data[i]=RG.SVG.stringsToNumbers(this.data[i]);}}
10
+ RG.SVG.resetColorsToOriginalValues({object:this});this.parseColors();this.drawFunnel();this.drawBackgroundBars();this.drawLabels();RG.SVG.drawTitle(this);if(typeof prop.key!==null&&RG.SVG.drawKey){RG.SVG.drawKey(this);}else if(!RGraph.SVG.isNull(prop.key)){alert('The drawKey() function does not exist - have you forgotten to include the key library?');}
11
+ var obj=this;doc.body.addEventListener('mousedown',function(e)
12
+ {obj.hideHighlight(obj);},false);RG.SVG.fireCustomEvent(this,'ondraw');return this;};this.drawFunnel=function(opt)
13
+ {var centerx=prop.gutterLeft+(this.graphWidth/2);for(var i=0;i<(this.data.length-1);++i){var value=this.data[i],nextValue=this.data[i+1],maxWidth=this.graphWidth,width=(value/this.max)*this.graphWidth,height=this.graphHeight/(this.data.length-1),nextWidth=(nextValue/this.max)*this.graphWidth,nextHeight=height;var x1=centerx-(width/2),y1=prop.gutterTop+(height*i),x2=centerx+(width/2),y2=prop.gutterTop+(height*i);x3=centerx+(nextWidth/2),y3=prop.gutterTop+(height*(i+1)),x4=centerx-(nextWidth/2),y4=prop.gutterTop+(height*(i+1));this.coords.push({x1:x1,y1:y1,x2:x2,y2:y2,x3:x3,y3:y3,x4:x4,y4:y4,widthTop:x2-x1,widthBottom:x3-x4,height:y3-y2});}
14
+ for(var i=0,len=this.coords.length,sequentialIndex=0;i<len;++i,++sequentialIndex){if(i<len){var coords=this.coords[i];var path=RG.SVG.create({svg:this.svg,type:'path',parent:this.svg.all,attr:{d:'M {1} {2} L {3} {4} L {5} {6} L {7} {8} z'.format(coords.x1,coords.y1,coords.x2,coords.y2,coords.x3,coords.y3,coords.x4,coords.y4),stroke:prop.strokestyle,fill:prop.colors[i],'stroke-width':prop.linewidth}});coords.object=path;if(!RG.SVG.isNull(prop.tooltips)&&prop.tooltips[i]){var obj=this;(function(idx,seq)
15
+ {path.addEventListener(prop.tooltipsEvent.replace(/^on/,''),function(e)
16
+ {obj.removeHighlight();RG.SVG.tooltip({object:obj,index:idx,group:null,sequentialIndex:seq,text:prop.tooltips[seq],event:e});obj.highlight(e.target);},false);path.addEventListener('mousemove',function(e)
17
+ {e.target.style.cursor='pointer'},false);})(i,sequentialIndex);}}}};this.redrawFunnel=function()
18
+ {};this.drawBackgroundBars=function()
19
+ {if(prop.backgroundBars){for(var i=0;i<this.coords.length;++i){var coords=this.coords[i];RG.SVG.create({svg:this.svg,type:'rect',parent:this.layers.background1,attr:{x:0,y:coords.y1,width:this.width,height:coords.y3-coords.y2,fill:prop.backgroundBarsColors&&typeof prop.backgroundBarsColors==='object'&&typeof prop.backgroundBarsColors[i]==='string'?prop.backgroundBarsColors[i]:prop.colors[i],'fill-opacity':prop.backgroundBarsOpacity}});}}};this.drawLabels=function()
20
+ {var labelsGroup=RG.SVG.create({svg:this.svg,parent:this.svg.all,type:'g'});if(prop.labelsHalign==='left'){var x=15;var halign='left';}else if(prop.labelsHalign==='right'){var x=this.width-15;var halign='right';}else{var x=this.width/2;var halign='center';}
21
+ if(prop.labels&&prop.labels.length){if(prop.labelsPosition==='section'){var sectionHeight=this.graphHeight/prop.labels.length;for(var i=0;i<prop.labels.length;++i){RG.SVG.text({object:this,svg:this.svg,parent:labelsGroup,text:typeof prop.labels[i]==='string'||prop.labels[i]==='number'?prop.labels[i].toString():'',size:parseInt(prop.labelsSize),x:x,y:prop.gutterTop+(sectionHeight/2)+(i*sectionHeight),halign:halign,valign:'center',background:prop.labelsBackground||'rgba(255,255,255,0.5)',padding:2,color:prop.labelsColor||prop.textColor||'black',bold:RG.SVG.isNull(prop.labelsBold)?prop.textBold:prop.labelsBold,italic:RG.SVG.isNull(prop.labelsItalic)?prop.labelsItalic:prop.textItalic,font:prop.labelsFont||prop.textFont});}}else{for(var i=0;i<prop.labels.length;++i){RG.SVG.text({object:this,svg:this.svg,parent:labelsGroup,text:typeof prop.labels[i]==='string'||prop.labels[i]==='number'?prop.labels[i].toString():'',size:parseInt(prop.labelsSize),x:x,y:prop.gutterTop+((this.graphHeight/(prop.labels.length-1))*i),halign:halign,valign:'center',background:prop.labelsBackground||'rgba(255,255,255,0.5)',padding:2,color:prop.labelsColor||prop.textColor||'black',bold:RG.SVG.isNull(prop.labelsBold)?prop.textBold:prop.labelsBold,italic:RG.SVG.isNull(prop.labelsItalic)?prop.labelsItalic:prop.textItalic,font:prop.labelsFont||prop.textFont});}}}};this.highlight=function(path)
22
+ {var path=path.getAttribute('d');var highlight=RG.SVG.create({svg:this.svg,parent:this.svg.all,type:'path',attr:{d:path,fill:prop.highlightFill,stroke:prop.highlightStroke,'stroke-width':prop.highlightLinewidth}});if(prop.tooltipsEvent==='mousemove'){highlight.addEventListener('mouseout',function(e)
23
+ {highlight.parentNode.removeChild(highlight);RG.SVG.hideTooltip();RG.SVG.REG.set('highlight',null);},false);}
24
+ RG.SVG.REG.set('highlight',highlight);};this.parseColors=function()
25
+ {if(!Object.keys(this.originalColors).length){this.originalColors={colors:RG.SVG.arrayClone(prop.colors),highlightFill:RG.SVG.arrayClone(prop.highlightFill),backgroundBarsColors:RG.SVG.arrayClone(prop.backgroundBarsColors)}}
26
+ var colors=prop.colors;if(colors){for(var i=0;i<colors.length;++i){colors[i]=RG.SVG.parseColorLinear({object:this,color:colors[i],direction:'horizontal'});}}
27
+ if(prop.backgroundBarsColors&&prop.backgroundBarsColors.length){for(var i=0;i<prop.backgroundBarsColors.length;++i){prop.backgroundBarsColors[i]=RG.SVG.parseColorLinear({object:this,color:prop.backgroundBarsColors[i],direction:'horizontal'});}}
28
+ prop.highlightFill=RG.SVG.parseColorLinear({object:this,color:prop.highlightFill});};this.on=function(type,func)
29
+ {if(type.substr(0,2)!=='on'){type='on'+type;}
30
+ RG.SVG.addCustomEventListener(this,type,func);return this;};this.exec=function(func)
31
+ {func(this);return this;};this.removeHighlight=this.hideHighlight=function()
32
+ {var highlight=RG.SVG.REG.get('highlight');if(highlight&&this.highlight_node){this.highlight_node.setAttribute('fill','transparent');this.highlight_node.setAttribute('stroke','transparent');RG.SVG.REG.set('highlight',null);}};for(i in conf.options){if(typeof i==='string'){this.set(i,conf.options[i]);}}};return this;})(window,document);
@@ -1,1401 +1,60 @@
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
- RGraph.SVG = RGraph.SVG || {};
15
-
16
- // Module pattern
17
- (function (win, doc, undefined)
18
- {
19
- var RG = RGraph,
20
- ua = navigator.userAgent,
21
- ma = Math,
22
- win = window,
23
- doc = document;
24
-
25
-
26
-
27
- RG.SVG.HBar = function (conf)
28
- {
29
- //
30
- // A setter that the constructor uses (at the end)
31
- // to set all of the properties
32
- //
33
- // @param string name The name of the property to set
34
- // @param string value The value to set the property to
35
- //
36
- this.set = function (name, value)
37
- {
38
- if (arguments.length === 1 && typeof name === 'object') {
39
- for (i in arguments[0]) {
40
- if (typeof i === 'string') {
41
-
42
- var ret = RG.SVG.commonSetter({
43
- object: this,
44
- name: i,
45
- value: arguments[0][i]
46
- });
47
-
48
- name = ret.name;
49
- value = ret.value;
50
-
51
- this.set(name, value);
52
- }
53
- }
54
- } else {
55
-
56
- var ret = RG.SVG.commonSetter({
57
- object: this,
58
- name: name,
59
- value: value
60
- });
61
-
62
- name = ret.name;
63
- value = ret.value;
64
-
65
- this.properties[name] = value;
66
- }
67
-
68
- return this;
69
- };
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
- this.id = conf.id;
79
- this.uid = RG.SVG.createUID();
80
- this.container = document.getElementById(this.id);
81
- this.svg = RG.SVG.createSVG({container: this.container});
82
- this.isRGraph = true;
83
- this.width = Number(this.svg.getAttribute('width'));
84
- this.height = Number(this.svg.getAttribute('height'));
85
- this.data = conf.data;
86
- this.type = 'hbar';
87
- this.coords = [];
88
- this.stackedBackfaces = [];
89
- this.colorsParsed = false;
90
- this.originalColors = {};
91
- this.gradientCounter = 1;
92
-
93
- // Add this object to the ObjectRegistry
94
- RG.SVG.OR.add(this);
95
-
96
- this.container.style.display = 'inline-block';
97
-
98
- this.properties =
99
- {
100
- gutterLeft: 100,
101
- gutterRight: 35,
102
- gutterTop: 35,
103
- gutterBottom: 35,
104
- gutterLeftAutosize: true,
105
-
106
- backgroundColor: null,
107
- backgroundImage: null,
108
- backgroundImageAspect: 'none',
109
- backgroundImageStretch: true,
110
- backgroundImageOpacity: null,
111
- backgroundImageX: null,
112
- backgroundImageY: null,
113
- backgroundImageW: null,
114
- backgroundImageH: null,
115
- backgroundGrid: true,
116
- backgroundGridColor: '#ddd',
117
- backgroundGridLinewidth: 1,
118
- backgroundGridHlines: true,
119
- backgroundGridHlinesCount: null,
120
- backgroundGridVlines: true,
121
- backgroundGridVlinesCount: null,
122
- backgroundGridBorder: true,
123
-
124
- // 20 colors. If you need more you need to set the colors property
125
- colors: [
126
- 'red', '#0f0', '#00f', '#ff0', '#0ff', '#0f0','pink','orange','gray','black',
127
- 'red', '#0f0', '#00f', '#ff0', '#0ff', '#0f0','pink','orange','gray','black'
128
- ],
129
- colorsSequential: false,
130
- strokestyle: 'rgba(0,0,0,0)',
131
-
132
- vmargin: 3,
133
- vmarginGrouped: 2,
134
- vmarginTop: 0,
135
- vmarginBottom: 0,
136
-
137
- xaxis: true,
138
- xaxisTickmarks: true,
139
- xaxisTickmarksLength: 5,
140
- xaxisColor: 'black',
141
- xaxisLabels: [],
142
- xaxisLabelsOffsetx: 0,
143
- xaxisLabelsOffsety: 0,
144
- xaxisLabelsCount: 5,
145
- xaxisScale: true,
146
- xaxisUnitsPre: '',
147
- xaxisUnitsPost: '',
148
- xaxisStrict: false,
149
- xaxisDecimals: 0,
150
- xaxisPoint: '.',
151
- xaxisThousand: ',',
152
- xaxisRound: false,
153
- xaxisMax: null,
154
- xaxisMin: 0,
155
- xaxisFormatter: null,
156
- xaxisLabelsPositionEdgeTickmarksCount: null,
157
- xaxisTextColor: null,
158
- xaxisTextBold: null,
159
- xaxisTextItalic: null,
160
- xaxisTextFont: null,
161
- xaxisTextSize: null,
162
-
163
- yaxis: true,
164
- yaxisTickmarks: true,
165
- yaxisTickmarksLength: 3,
166
- yaxisLabels: [],
167
- yaxisLabelsPosition: 'section',
168
- yaxisLabelsOffsetx: 0,
169
- yaxisLabelsOffsety: 0,
170
- yaxisScale: false,
171
- yaxisLabelsPositionEdgeTickmarksCount: null,
172
- yaxisColor: 'black',
173
- yaxisTextFont: null,
174
- yaxisTextSize: null,
175
- yaxisTextColor: null,
176
- yaxisTextBold: null,
177
- yaxisTextItalic: null,
178
-
179
- textColor: 'black',
180
- textFont: 'sans-serif',
181
- textSize: 12,
182
- textBold: false,
183
- textItalic: false,
184
-
185
- labelsAbove: false,
186
- labelsAboveFont: null,
187
- labelsAboveSize: null,
188
- labelsAboveBold: null,
189
- labelsAboveItalic: null,
190
- labelsAboveColor: null,
191
- labelsAboveBackground: null,
192
- labelsAboveBackgroundPadding: 0,
193
- labelsAboveUnitsPre: null,
194
- labelsAboveUnitsPost: null,
195
- labelsAbovePoint: null,
196
- labelsAboveThousand: null,
197
- labelsAboveFormatter: null,
198
- labelsAboveDecimals: null,
199
- labelsAboveOffsetx: 0,
200
- labelsAboveOffsety: 0,
201
- labelsAboveHalign: 'left',
202
- labelsAboveValign: 'center',
203
- labelsAboveSpecific: null,
204
-
205
- linewidth: 1,
206
- grouping: 'grouped',
207
-
208
- tooltips: null,
209
- tooltipsOverride: null,
210
- tooltipsEffect: 'fade',
211
- tooltipsCssClass: 'RGraph_tooltip',
212
- tooltipsEvent: 'click',
213
-
214
- highlightStroke: 'rgba(0,0,0,0)',
215
- highlightFill: 'rgba(255,255,255,0.7)',
216
- highlightLinewidth: 1,
217
-
218
- title: '',
219
- titleSize: 16,
220
- titleX: null,
221
- titleY: null,
222
- titleHalign: 'center',
223
- titleValign: null,
224
- titleColor: 'black',
225
- titleFont: null,
226
- titleBold: false,
227
- titleItalic: false,
228
-
229
- titleSubtitle: '',
230
- titleSubtitleX: null,
231
- titleSubtitleY: null,
232
- titleSubtitleHalign: 'center',
233
- titleSubtitleValign: null,
234
- titleSubtitleColor: '#aaa',
235
- titleSubtitleSize: 10,
236
- titleSubtitleFont: null,
237
- titleSubtitleBold: false,
238
- titleSubtitleItalic: false,
239
-
240
- shadow: false,
241
- shadowOffsetx: 2,
242
- shadowOffsety: 2,
243
- shadowBlur: 2,
244
- shadowOpacity: 0.25,
245
-
246
-
247
-
248
- key: null,
249
- keyColors: null,
250
- keyOffsetx: 0,
251
- keyOffsety: 0,
252
- keyTextOffsetx: 0,
253
- keyTextOffsety: -1,
254
- keyTextSize: null,
255
- keyTextBold: null,
256
- keyTextItalic: null,
257
-
258
- attribution: true,
259
- attributionX: null,
260
- attributionY: null,
261
- attributionHref: null,// Default is set in RGraph.svg.common.core.js
262
- attributionHalign: 'right',
263
- attributionValign: 'bottom',
264
- attributionSize: 7,
265
- attributionColor: 'gray',
266
- attributionFont: 'sans-serif',
267
- attributionItalic: false,
268
- attributionBold: false
269
- };
270
-
271
-
272
-
273
-
274
-
275
- /**
276
- * "Decorate" the object with the generic effects if the effects library has been included
277
- */
278
- if (RG.SVG.FX && typeof RG.SVG.FX.decorate === 'function') {
279
- RG.SVG.FX.decorate(this);
280
- }
281
-
282
-
283
-
284
-
285
- var prop = this.properties;
286
-
287
-
288
-
289
-
290
-
291
-
292
-
293
-
294
- //
295
- // The draw method draws the Bar chart
296
- //
297
- this.draw = function ()
298
- {
299
- // Fire the beforedraw event
300
- RG.SVG.fireCustomEvent(this, 'onbeforedraw');
301
-
302
-
303
-
304
-
305
- // Create the defs tag if necessary
306
- RG.SVG.createDefs(this);
307
-
308
-
309
-
310
- //
311
- // Handle the gutterLeft autosizing
312
- //
313
- if (prop.gutterLeftAutosize) {
314
- for (var i=0,len=prop.yaxisLabels.length,maxLength=0; i<len; ++i) {
315
- var sizes = RG.SVG.measureText({
316
- text: prop.yaxisLabels[i],
317
- bold: prop.yaxisTextBold || prop.textBold,
318
- size: prop.yaxisTextSize || prop.textSize,
319
- font: prop.yaxisTextFont || prop.textFont
320
- });
321
-
322
- maxLength = ma.max(maxLength, sizes[0]);
323
- }
324
-
325
- prop.gutterLeft = maxLength + 15;
326
- }
327
-
328
-
329
-
330
-
331
- this.graphWidth = this.width - prop.gutterLeft - prop.gutterRight;
332
- this.graphHeight = this.height - prop.gutterTop - prop.gutterBottom;
333
-
334
-
335
-
336
- // Parse the colors for gradients
337
- RG.SVG.resetColorsToOriginalValues({object:this});
338
- this.parseColors();
339
-
340
-
341
-
342
- // Go through the data and work out the maximum value
343
- var values = [];
344
-
345
- for (var i=0,max=0; i<this.data.length; ++i) {
346
- if (typeof this.data[i] === 'number') {
347
- values.push(this.data[i]);
348
-
349
- } else if (RG.SVG.isArray(this.data[i]) && prop.grouping === 'grouped') {
350
- values.push(RG.SVG.arrayMax(this.data[i]));
351
-
352
- } else if (RG.SVG.isArray(this.data[i]) && prop.grouping === 'stacked') {
353
- values.push(RG.SVG.arraySum(this.data[i]));
354
- }
355
- }
356
- var max = RG.SVG.arrayMax(values);
357
-
358
- // A custom, user-specified maximum value
359
- if (typeof prop.xaxisMax === 'number') {
360
- max = prop.xaxisMax;
361
- }
362
-
363
- // Set the ymin to zero if it's set to mirror
364
- if (prop.xaxisMin === 'mirror' || prop.xaxisMin === 'middle' || prop.xaxisMin === 'center') {
365
- var mirrorScale = true;
366
- prop.xaxisMin = prop.xaxisMax * -1;
367
- }
368
-
369
-
370
- //
371
- // Generate an appropiate scale
372
- //
373
- this.scale = RG.SVG.getScale({
374
- object: this,
375
- numlabels: prop.xaxisLabelsCount,
376
- unitsPre: prop.xaxisUnitsPre,
377
- unitsPost: prop.xaxisUnitsPost,
378
- max: max,
379
- min: prop.xaxisMin,
380
- point: prop.xaxisPoint,
381
- round: prop.xaxisRound,
382
- thousand: prop.xaxisThousand,
383
- decimals: prop.xaxisDecimals,
384
- strict: typeof prop.xaxisMax === 'number',
385
- formatter: prop.xaxisFormatter
386
- });
387
-
388
-
389
-
390
- //
391
- // Get the scale a second time if the xmin should be mirored
392
- //
393
- // Set the xmin to zero if it's set mirror
394
- if (mirrorScale) {
395
- this.scale = RG.SVG.getScale({
396
- object: this,
397
- numlabels: prop.xaxisLabelsCount,
398
- unitsPre: prop.xaxisUnitsPre,
399
- unitsPost: prop.xaxisUnitsPost,
400
- max: this.scale.max,
401
- min: this.scale.max * -1,
402
- point: prop.xaxisPoint,
403
- round: false,
404
- thousand: prop.xaxisThousand,
405
- decimals: prop.xaxisDecimals,
406
- strict: typeof prop.xaxisMax === 'number',
407
- formatter: prop.xaxisFormatter
408
- });
409
- }
410
-
411
- // Now the scale has been generated adopt its max value
412
- this.max = this.scale.max;
413
- prop.xaxisMax = this.scale.max;
414
-
415
- this.min = this.scale.min;
416
- prop.xaxisMin = this.scale.min;
417
-
418
-
419
-
420
-
421
- // Draw the background first
422
- RG.SVG.drawBackground(this);
423
-
424
- // Draw the bars
425
- this.drawBars();
426
-
427
-
428
- // Draw the axes over the bars
429
- RG.SVG.drawXAxis(this);
430
- RG.SVG.drawYAxis(this);
431
-
432
-
433
- // Draw the labelsAbove
434
- this.drawLabelsAbove();
435
-
436
-
437
-
438
-
439
-
440
-
441
- // Draw the key
442
- if (typeof prop.key !== null && RG.SVG.drawKey) {
443
- RG.SVG.drawKey(this);
444
- } else if (!RGraph.SVG.isNull(prop.key)) {
445
- alert('The drawKey() function does not exist - have you forgotten to include the key library?');
446
- }
447
-
448
-
449
-
450
-
451
-
452
-
453
- // Add the attribution link. If you're adding this elsewhere on your page/site
454
- // and you don't want it displayed then there are options available to not
455
- // show it.
456
- RG.SVG.attribution(this);
457
-
458
-
459
-
460
- // Add the event listener that clears the highlight rect if
461
- // there is any. Must be MOUSEDOWN (ie before the click event)
462
- var obj = this;
463
- document.body.addEventListener('mousedown', function (e)
464
- {
465
- RG.SVG.removeHighlight(obj);
466
-
467
- }, false);
468
-
469
-
470
-
471
- // Fire the draw event
472
- RG.SVG.fireCustomEvent(this, 'ondraw');
473
-
474
-
475
-
476
-
477
- return this;
478
- };
479
-
480
-
481
-
482
-
483
-
484
-
485
-
486
-
487
- //
488
- // Draws the bars
489
- //
490
- this.drawBars = function ()
491
- {
492
- if (prop.shadow) {
493
- RG.SVG.setShadow({
494
- object: this,
495
- offsetx: prop.shadowOffsetx,
496
- offsety: prop.shadowOffsety,
497
- blur: prop.shadowBlur,
498
- opacity: prop.shadowOpacity,
499
- id: 'dropShadow'
500
- });
501
- }
502
-
503
- // Go through the bars
504
- for (var i=0,sequentialIndex=0; i<this.data.length; ++i,++sequentialIndex) {
505
-
506
- //
507
- // NORMAL bars
508
- //
509
- if (typeof this.data[i] === 'number') {
510
-
511
- var outerSegment = (this.graphHeight - prop.vmarginTop - prop.vmarginBottom) / this.data.length,
512
- width = this.getWidth(this.data[i]),
513
- height = ( (this.graphHeight - prop.vmarginTop - prop.vmarginBottom) / this.data.length) - prop.vmargin - prop.vmargin,
514
- x = this.getXCoord(
515
- (this.scale.min < 0 && this.scale.max < 0) || (this.scale.min > 0 && this.scale.max > 0) ? this.scale.min : 0
516
- ) - (this.data[i] < 0 ? width : 0),
517
- y = prop.gutterTop + prop.vmarginTop + prop.vmargin + (outerSegment * i);
518
-
519
- // If theres a min set but both the min and max are below
520
- // zero the the bars should be aligned to the right hand
521
- // side
522
- if (this.scale.min < 0 && this.scale.max < 0) {
523
- x = this.width - prop.gutterRight - width;
524
- }
525
-
526
- var rect = RG.SVG.create({
527
- svg: this.svg,
528
- parent: this.svg.all,
529
- type: 'rect',
530
- attr: {
531
- stroke: prop.strokestyle,
532
- fill: prop.colorsSequential ? (prop.colors[sequentialIndex] ? prop.colors[sequentialIndex] : prop.colors[prop.colors.length - 1]) : prop.colors[0],
533
- x: x,
534
- y: y,
535
- width: width,
536
- height: height,
537
- 'stroke-width': prop.linewidth,
538
- 'data-tooltip': (!RG.SVG.isNull(prop.tooltips) && prop.tooltips.length) ? prop.tooltips[i] : '',
539
- 'data-index': i,
540
- 'data-original-width': width,
541
- 'data-original-height': height,
542
- 'data-sequential-index': sequentialIndex,
543
- 'data-value': this.data[i],
544
- filter: prop.shadow ? 'url(#dropShadow)' : ''
545
- }
546
- });
547
-
548
- this.coords.push({
549
- object: rect,
550
- x: x,
551
- y: y - (this.data[i] > 0 ? height : 0),
552
- width: width,
553
- height: height
554
- });
555
-
556
-
557
-
558
-
559
-
560
- // Add toooltips if necessary
561
- if (!RG.SVG.isNull(prop.tooltips) && prop.tooltips[sequentialIndex]) {
562
-
563
- var obj = this;
564
-
565
- //
566
- // Add tooltip event listeners
567
- //
568
- (function (idx, seq)
569
- {
570
- rect.addEventListener(prop.tooltipsEvent.replace(/^on/, ''), function (e)
571
- {
572
- obj.removeHighlight();
573
-
574
- // Show the tooltip
575
- RG.SVG.tooltip({
576
- object: obj,
577
- index: idx,
578
- group: null,
579
- sequentialIndex: seq,
580
- text: prop.tooltips[seq],
581
- event: e
582
- });
583
-
584
- // Highlight the rect that has been clicked on
585
- obj.highlight(e.target);
586
- }, false);
587
-
588
- rect.addEventListener('mousemove', function (e)
589
- {
590
- e.target.style.cursor = 'pointer';
591
- }, false);
592
- })(i, sequentialIndex);
593
- }
594
-
595
-
596
-
597
-
598
- //
599
- // GROUPED charts
600
- //
601
- } else if (RG.SVG.isArray(this.data[i]) && prop.grouping === 'grouped') {
602
-
603
- var outerSegment = ( (this.graphHeight - prop.vmarginTop - prop.vmarginBottom) / this.data.length),
604
- innerSegment = outerSegment - (2 * prop.vmargin);
605
-
606
- // Loop through the group
607
- for (var j=0; j<this.data[i].length; ++j,++sequentialIndex) {
608
-
609
- var width = ma.abs((this.data[i][j] / (this.max - this.min)) * this.graphWidth),
610
- height = ( (innerSegment - ((this.data[i].length - 1) * prop.vmarginGrouped)) / this.data[i].length),
611
- y = prop.gutterTop + prop.vmargin + prop.vmarginTop + (outerSegment * i) + (j * height) + (j * prop.vmarginGrouped),
612
- x = this.getXCoord(0) - (this.data[i][j] < 0 ? width : 0);
613
-
614
-
615
-
616
-
617
-
618
-
619
-
620
-
621
-
622
- // Work out some coordinates for the width and X coords ///////////////////////
623
- if (this.scale.max < 0 && this.scale.min < this.scale.max) {
624
- var x1 = this.getXCoord(this.data[i][j]);
625
- var x2 = this.getXCoord(this.scale.max);
626
- x = x1;
627
- width = x2 - x1;
628
-
629
- } else if (this.scale.min > 0 && this.scale.max > this.scale.min) {
630
- var x1 = this.getXCoord(this.data[i][j]);
631
- var x2 = this.getXCoord(this.scale.min);
632
- x = this.getXCoord(this.scale.min);
633
- width = x1 - x2;
634
-
635
- }
636
- //////////////////////////////////////////////////////////////////////////////
637
-
638
-
639
-
640
-
641
-
642
-
643
-
644
-
645
-
646
-
647
- var rect = RG.SVG.create({
648
- svg: this.svg,
649
- type: 'rect',
650
- parent: this.svg.all,
651
- attr: {
652
- stroke: prop['strokestyle'],
653
- fill: (prop.colorsSequential && prop.colors[sequentialIndex]) ? prop.colors[sequentialIndex] : (prop.colors[j] ? prop.colors[j] : prop.colors[prop.colors.length - 1]),
654
- x: x,
655
- y: y,
656
- width: width,
657
- height: height,
658
- 'stroke-width': prop.linewidth,
659
- 'data-index': i,
660
- 'data-original-width': width,
661
- 'data-sequential-index': sequentialIndex,
662
- 'data-tooltip': (!RG.SVG.isNull(prop.tooltips) && prop.tooltips.length) ? prop.tooltips[sequentialIndex] : '',
663
- 'data-value': this.data[i][j],
664
- filter: prop.shadow ? 'url(#dropShadow)' : ''
665
- }
666
- });
667
-
668
- this.coords.push({
669
- object: rect,
670
- x: x,
671
- y: y - (this.data[i][j] > 0 ? height : 0),
672
- width: width,
673
- height: height
674
- });
675
-
676
-
677
- // Add the tooltip data- attribute
678
- if (!RG.SVG.isNull(prop.tooltips) && prop.tooltips[sequentialIndex]) {
679
-
680
- var obj = this;
681
-
682
-
683
- //
684
- // Add tooltip event listeners
685
- //
686
- (function (idx, seq)
687
- {
688
- var indexes = RG.SVG.sequentialIndexToGrouped(seq, obj.data);
689
-
690
- rect.addEventListener(prop.tooltipsEvent.replace(/^on/, ''), function (e)
691
- {
692
- obj.removeHighlight();
693
-
694
- // Show the tooltip
695
- RG.SVG.tooltip({
696
- object: obj,
697
- group: idx,
698
- index: indexes[1],
699
- sequentialIndex: seq,
700
- text: prop.tooltips[seq],
701
- event: e
702
- });
703
-
704
- // Highlight the rect that has been clicked on
705
- obj.highlight(e.target);
706
-
707
- }, false);
708
-
709
- rect.addEventListener('mousemove', function (e)
710
- {
711
- e.target.style.cursor = 'pointer'
712
- }, false);
713
- })(i, sequentialIndex);
714
- }
715
- }
716
-
717
- --sequentialIndex;
718
-
719
-
720
-
721
- //
722
- // Stacked charts
723
- //
724
- } else if (RG.SVG.isArray(this.data[i]) && prop.grouping === 'stacked') {
725
-
726
- // This is each bars "segment" of the chart
727
- var section = ( (this.graphHeight - prop.vmarginTop - prop.vmarginBottom) / this.data.length);
728
-
729
-
730
- // Intialise the X and Y coordinates
731
- var x = this.getXCoord(0);
732
-
733
-
734
-
735
- // Loop through the stack
736
- for (var j=0; j<this.data[i].length; ++j,++sequentialIndex) {
737
-
738
- var outerHeight = (this.graphHeight - prop.vmarginTop - prop.vmarginBottom) / this.data.length,
739
- width = ma.abs((this.data[i][j] / (this.max - this.min)) * this.graphWidth),
740
- height = outerHeight - (2 * prop.vmargin),
741
- y = prop.gutterTop + prop.vmargin + prop.vmarginTop + (outerHeight * i);
742
-
743
- // If this is the first iteration of the loop and a shadow
744
- // is requested draw a rect here to create it.
745
- if (j === 0 && prop.shadow) {
746
-
747
- var fullWidth = ma.abs((RG.SVG.arraySum(this.data[i]) / (this.max - this.min)) * this.graphWidth);
748
-
749
- var rect = RG.SVG.create({
750
- svg: this.svg,
751
- parent: this.svg.all,
752
- type: 'rect',
753
- attr: {
754
- x: x,
755
- y: y,
756
- width: fullWidth,
757
- height: height,
758
- fill: 'white',
759
- 'stroke-width': 0,
760
- 'data-index': i,
761
- filter: 'url(#dropShadow)'
762
- }
763
- });
764
-
765
- this.stackedBackfaces[i] = rect;
766
- }
767
-
768
-
769
-
770
- // Create the visible bar
771
- var rect = RG.SVG.create({
772
- svg: this.svg,
773
- type: 'rect',
774
- parent: this.svg.all,
775
- attr: {
776
- stroke: prop['strokestyle'],
777
- fill: prop.colorsSequential ? (prop.colors[sequentialIndex] ? prop.colors[sequentialIndex] : prop.colors[prop.colors.length - 1]) : (prop.colors[j] ? prop.colors[j] : prop.colors[prop.colors.length - 1]),
778
- x: x,
779
- y: y,
780
- width: width,
781
- height: height,
782
- 'stroke-width': prop.linewidth,
783
- 'data-original-width': width,
784
- 'data-original-height': height,
785
- 'data-original-x': x,
786
- 'data-original-y': y,
787
- 'data-index': i,
788
- 'data-sequential-index': sequentialIndex,
789
- 'data-tooltip': (!RG.SVG.isNull(prop.tooltips) && prop.tooltips.length) ? prop.tooltips[sequentialIndex] : '',
790
- 'data-value': this.data[i][j]
791
- }
792
- });
793
-
794
-
795
- this.coords.push({
796
- object: rect,
797
- x: x,
798
- y: y,
799
- width: width,
800
- height: height
801
- });
802
-
803
-
804
-
805
- // Add the tooltips
806
- if (!RG.SVG.isNull(prop.tooltips) && prop.tooltips[sequentialIndex]) {
807
-
808
- var obj = this;
809
-
810
-
811
- //
812
- // Add tooltip event listeners
813
- //
814
- (function (idx, seq)
815
- {
816
- rect.addEventListener(prop.tooltipsEvent.replace(/^on/, ''), function (e)
817
- {
818
- obj.removeHighlight();
819
-
820
- var indexes = RG.SVG.sequentialIndexToGrouped(seq, obj.data);
821
-
822
- // Show the tooltip
823
- RG.SVG.tooltip({
824
- object: obj,
825
- index: indexes[1],
826
- group: idx,
827
- sequentialIndex: seq,
828
- text: prop.tooltips[seq],
829
- event: e
830
- });
831
-
832
- // Highlight the rect that has been clicked on
833
- obj.highlight(e.target);
834
- }, false);
835
-
836
- rect.addEventListener('mousemove', function (e)
837
- {
838
- e.target.style.cursor = 'pointer'
839
- }, false);
840
- })(i, sequentialIndex);
841
- }
842
-
843
- x += width;
844
- }
845
-
846
- --sequentialIndex;
847
- }
848
- }
849
-
850
- };
851
-
852
-
853
-
854
-
855
-
856
-
857
-
858
-
859
-
860
- /**
861
- * This function can be used to retrieve the relevant X coordinate for a
862
- * particular value.
863
- *
864
- * @param int value The value to get the X coordinate for
865
- */
866
- this.getXCoord = function (value)
867
- {
868
- var prop = this.properties;
869
-
870
- if (value > this.scale.max) {
871
- return null;
872
- }
873
-
874
- var x;
875
-
876
- if (value < this.scale.min) {
877
- return null;
878
- }
879
-
880
- x = ((value - this.scale.min) / (this.scale.max - this.scale.min));
881
- x *= this.graphWidth;
882
- x += prop.gutterLeft;
883
-
884
- return x;
885
- };
886
-
887
-
888
-
889
-
890
-
891
-
892
-
893
-
894
-
895
- /**
896
- * This function can be used to retrieve the relevant X coordinate for a
897
- * particular value.
898
- *
899
- * @param int value The value to get the X coordinate for
900
- */
901
- this.getWidth = function (value)
902
- {
903
- if (this.scale.max <= 0 && this.scale.min < this.scale.max) {
904
- var x1 = this.getXCoord(this.scale.max);
905
- var x2 = this.getXCoord(value);
906
-
907
- } else if (this.scale.min > 0 && this.scale.max > this.scale.min) {
908
- var x1 = this.getXCoord(this.scale.min);
909
- var x2 = this.getXCoord(value);
910
-
911
- } else {
912
- var x1 = this.getXCoord(0);
913
- var x2 = this.getXCoord(value);
914
- }
915
-
916
- return ma.abs(x1 - x2);
917
- };
918
-
919
- //ma.abs(((this.data[i] - this.scale.min) / (this.max - this.scale.min)) * this.graphWidth)
920
-
921
-
922
-
923
-
924
-
925
-
926
-
927
-
928
- /**
929
- * This function can be used to highlight a bar on the chart
930
- *
931
- * @param object rect The rectangle to highlight
932
- */
933
- this.highlight = function (rect)
934
- {
935
- var x = rect.getAttribute('x'),
936
- y = rect.getAttribute('y'),
937
- width = rect.getAttribute('width'),
938
- height = rect.getAttribute('height');
939
-
940
- var highlight = RG.SVG.create({
941
- svg: this.svg,
942
- type: 'rect',
943
- parent: this.svg.all,
944
- attr: {
945
- stroke: prop.highlightStroke,
946
- fill: prop.highlightFill,
947
- x: x,
948
- y: y,
949
- width: width,
950
- height: height,
951
- 'stroke-width': prop.highlightLinewidth
952
- }
953
- });
954
-
955
-
956
- //if (prop.tooltipsEvent === 'mousemove') {
957
- // highlight.addEventListener('mouseout', function (e)
958
- // {
959
- // highlight.parentNode.removeChild(highlight);
960
- // RG.SVG.hideTooltip();
961
-
962
- // RG.SVG.REG.set('highlight', null);
963
- // }, false);
964
- //}
965
-
966
-
967
- // Store the highlight rect in the rebistry so
968
- // it can be cleared later
969
- RG.SVG.REG.set('highlight', highlight);
970
- };
971
-
972
-
973
-
974
-
975
-
976
-
977
-
978
-
979
- /**
980
- * This allows for easy specification of gradients
981
- */
982
- this.parseColors = function ()
983
- {
984
- // Save the original colors so that they can be restored when
985
- // the canvas is cleared
986
- if (!Object.keys(this.originalColors).length) {
987
- this.originalColors = {
988
- colors: RG.SVG.arrayClone(prop.colors),
989
- backgroundGridColor: RG.SVG.arrayClone(prop.backgroundGridColor),
990
- highlightFill: RG.SVG.arrayClone(prop.highlightFill),
991
- backgroundColor: RG.SVG.arrayClone(prop.backgroundColor)
992
- }
993
- }
994
-
995
-
996
- // colors
997
- var colors = prop.colors;
998
-
999
- if (colors) {
1000
- for (var i=0; i<colors.length; ++i) {
1001
- colors[i] = RG.SVG.parseColorLinear({
1002
- object: this,
1003
- color: colors[i],
1004
- direction: 'horizontal',
1005
- start: prop.gutterLeft,
1006
- end: this.width - prop.gutterRight
1007
- });
1008
- }
1009
- }
1010
-
1011
- prop.backgroundGridColor = RG.SVG.parseColorLinear({object: this, color: prop.backgroundGridColor, direction: 'horizontal',start: prop.gutterLeft,end: this.width - prop.gutterRight});
1012
- prop.highlightFill = RG.SVG.parseColorLinear({object: this, color: prop.highlightFill, direction: 'horizontal',start: prop.gutterLeft,end: this.width - prop.gutterRight});
1013
- prop.backgroundColor = RG.SVG.parseColorLinear({object: this, color: prop.backgroundColor});
1014
- };
1015
-
1016
-
1017
-
1018
-
1019
-
1020
-
1021
-
1022
-
1023
- //
1024
- // Draws the labelsAbove
1025
- //
1026
- this.drawLabelsAbove = function ()
1027
- {
1028
- // Go through the above labels
1029
- if (prop.labelsAbove) {
1030
-
1031
- var data = RG.SVG.arrayLinearize(this.data);
1032
-
1033
- for (var i=0; i<this.coords.length; ++i) {
1034
-
1035
- var value = data[i].toFixed(typeof prop.labelsAboveDecimals === 'number' ? prop.labelsAboveDecimals : prop.xaxisDecimals);
1036
- var indexes = RG.SVG.sequentialIndexToGrouped(i, this.data);
1037
-
1038
-
1039
-
1040
- if (RG.SVG.isArray(this.data[indexes[0]]) && prop.grouping === 'stacked') {
1041
- if ((indexes[1] +1) === this.data[indexes[0]].length) {
1042
- value = RG.SVG.arraySum(this.data[indexes[0]]);
1043
- value = value.toFixed(typeof prop.labelsAboveDecimals === 'number' ? prop.labelsAboveDecimals : prop.xaxisDecimals);
1044
- } else {
1045
- continue;
1046
- }
1047
- }
1048
-
1049
-
1050
- var str = prop.labelsAboveSpecific ? prop.labelsAboveSpecific[i].toString() : RG.SVG.numberFormat({
1051
- object: this,
1052
- num: value,
1053
- prepend: typeof prop.labelsAboveUnitsPre === 'string' ? prop.labelsAboveUnitsPre : null,
1054
- append: typeof prop.labelsAboveUnitsPost === 'string' ? prop.labelsAboveUnitsPost : null,
1055
- point: typeof prop.labelsAbovePoint === 'string' ? prop.labelsAbovePoint : null,
1056
- thousand: typeof prop.labelsAboveThousand === 'string' ? prop.labelsAboveThousand : null,
1057
- formatter: typeof prop.labelsAboveFormatter === 'function' ? prop.labelsAboveFormatter : null
1058
- });
1059
-
1060
- var bold = typeof prop.labelsAboveBold === 'boolean' ? prop.labelsAboveBold : prop.textBold,
1061
- italic = typeof prop.labelsAboveItalic === 'boolean' ? prop.labelsAboveItalic : prop.textItalic,
1062
- size = prop.labelsAboveSize || prop.textSize,
1063
- font = prop.labelsAboveFont || prop.textFont,
1064
- halign = prop.labelsAboveHalign,
1065
- valign = prop.labelsAboveValign;
1066
-
1067
- var dimensions = RG.SVG.measureText({
1068
- text: str,
1069
- bold: bold,
1070
- font: font,
1071
- size: size
1072
- });
1073
-
1074
- var x = (value >= 0)
1075
- ? (parseFloat(this.coords[i].object.getAttribute('x')) + parseFloat(this.coords[i].object.getAttribute('width')) + 7 + prop.labelsAboveOffsetx)
1076
- : parseFloat(this.coords[i].object.getAttribute('x') - 7 - prop.labelsAboveOffsetx),
1077
- y = parseFloat(this.coords[i].object.getAttribute('y')) + parseFloat(this.coords[i].object.getAttribute('height') / 2) + prop.labelsAboveOffsety,
1078
- width = dimensions[0],
1079
- height = dimensions[1],
1080
- halign = (value >= 0) ? 'left': 'right';
1081
-
1082
- if (x + width > this.width && value > 0) {
1083
- halign = 'right';
1084
- x = this.width - 5;
1085
- prop.labelsAboveBackground = prop.labelsAboveBackground || 'rgba(255,255,255,0.95)';
1086
- }
1087
-
1088
-
1089
- var text = RG.SVG.text({
1090
- object: this,
1091
- parent: this.svg.all,
1092
- text: str,
1093
- x: x,
1094
- y: y,
1095
- halign: halign,
1096
- valign: valign,
1097
- font: font,
1098
- size: size,
1099
- bold: bold,
1100
- italic: italic,
1101
- color: prop.labelsAboveColor || prop.textColor,
1102
- background: prop.labelsAboveBackground || null,
1103
- padding: prop.labelsAboveBackgroundPadding || 0
1104
- });
1105
- }
1106
- }
1107
- };
1108
-
1109
-
1110
-
1111
-
1112
-
1113
-
1114
-
1115
-
1116
- /**
1117
- * Using a function to add events makes it easier to facilitate method
1118
- * chaining
1119
- *
1120
- * @param string type The type of even to add
1121
- * @param function func
1122
- */
1123
- this.on = function (type, func)
1124
- {
1125
- if (type.substr(0,2) !== 'on') {
1126
- type = 'on' + type;
1127
- }
1128
-
1129
- RG.SVG.addCustomEventListener(this, type, func);
1130
-
1131
- return this;
1132
- };
1133
-
1134
-
1135
-
1136
-
1137
-
1138
-
1139
-
1140
-
1141
- //
1142
- // Used in chaining. Runs a function there and then - not waiting for
1143
- // the events to fire (eg the onbeforedraw event)
1144
- //
1145
- // @param function func The function to execute
1146
- //
1147
- this.exec = function (func)
1148
- {
1149
- func(this);
1150
-
1151
- return this;
1152
- };
1153
-
1154
-
1155
-
1156
-
1157
-
1158
-
1159
-
1160
-
1161
- //
1162
- // Remove highlight from the chart (tooltips)
1163
- //
1164
- this.removeHighlight = function ()
1165
- {
1166
- var highlight = RG.SVG.REG.get('highlight');
1167
- if (highlight && highlight.parentNode) {
1168
- highlight.parentNode.removeChild(highlight);
1169
- }
1170
-
1171
- RG.SVG.REG.set('highlight', null);
1172
- };
1173
-
1174
-
1175
-
1176
-
1177
-
1178
-
1179
-
1180
-
1181
- //
1182
- // The Bar chart grow effect
1183
- //
1184
- this.grow = function ()
1185
- {
1186
- var opt = arguments[0] || {},
1187
- frames = opt.frames || 30,
1188
- frame = 0,
1189
- obj = this,
1190
- data = [],
1191
- height = null,
1192
- seq = 0;
1193
-
1194
- //
1195
- // Copy the data
1196
- //
1197
- data = RG.SVG.arrayClone(this.data);
1198
-
1199
- this.draw();
1200
-
1201
- var iterate = function ()
1202
- {
1203
- for (var i=0,seq=0,len=obj.coords.length; i<len; ++i, ++seq) {
1204
-
1205
- var multiplier = (frame / frames)
1206
- * RG.SVG.FX.getEasingMultiplier(frames, frame)
1207
- * RG.SVG.FX.getEasingMultiplier(frames, frame);
1208
-
1209
-
1210
-
1211
-
1212
- // TODO Go through the data and update the value according to
1213
- // the frame number
1214
- if (typeof data[i] === 'number') {
1215
-
1216
- width = ma.abs(obj.getXCoord(data[i]) - obj.getXCoord(0));
1217
- obj.data[i] = data[i] * multiplier;
1218
- width = multiplier * width;
1219
-
1220
- // Set the new width on the rect
1221
- obj.coords[seq].object.setAttribute(
1222
- 'width',
1223
- width
1224
- );
1225
-
1226
- // Set the correct Y coord on the object
1227
- obj.coords[seq].object.setAttribute(
1228
- 'x',
1229
- data[i] > 0 ? obj.getXCoord(0) : obj.getXCoord(0) - width
1230
- );
1231
-
1232
- } else if (typeof data[i] === 'object') {
1233
-
1234
- var accumulativeWidth = 0;
1235
-
1236
- for (var j=0,len2=data[i].length; j<len2; ++j, ++seq) {
1237
-
1238
- width = ma.abs(obj.getXCoord(data[i][j]) - obj.getXCoord(0));
1239
- width = multiplier * width;
1240
- obj.data[i][j] = data[i][j] * multiplier;
1241
-
1242
- obj.coords[seq].object.setAttribute(
1243
- 'width',
1244
- width
1245
- );
1246
-
1247
- obj.coords[seq].object.setAttribute(
1248
- 'x',
1249
- data[i][j] > 0 ? (obj.getXCoord(0) + accumulativeWidth) : (obj.getXCoord(0) - width - accumulativeWidth)
1250
- );
1251
-
1252
- accumulativeWidth += (prop.grouping === 'stacked' ? width : 0);
1253
- }
1254
-
1255
- //
1256
- // Set the height and Y cooord of the backfaces if necessary
1257
- //
1258
- if (obj.stackedBackfaces[i]) {
1259
- obj.stackedBackfaces[i].setAttribute(
1260
- 'width',
1261
- accumulativeWidth
1262
- );
1263
-
1264
- obj.stackedBackfaces[i].setAttribute(
1265
- 'x',
1266
- prop.gutterLeft
1267
- );
1268
- }
1269
-
1270
- // Decrease seq by one so that it's not incremented twice
1271
- --seq;
1272
- }
1273
- }
1274
-
1275
- if (frame++ < frames) {
1276
- //setTimeout(iterate, frame > 1 ? opt.delay : 200);
1277
- RG.SVG.FX.update(iterate);
1278
- } else if (opt.callback) {
1279
- (opt.callback)(obj);
1280
- }
1281
- };
1282
-
1283
- iterate();
1284
-
1285
- return this;
1286
- };
1287
-
1288
-
1289
-
1290
-
1291
-
1292
-
1293
-
1294
-
1295
- /**
1296
- * HBar chart Wave effect.
1297
- *
1298
- * @param object OPTIONAL An object map of options. You specify 'frames'
1299
- * here to give the number of frames in the effect
1300
- * and also callback to specify a callback function
1301
- * thats called at the end of the effect
1302
- */
1303
- this.wave = function ()
1304
- {
1305
- // First draw the chart
1306
- this.draw();
1307
-
1308
-
1309
- var obj = this,
1310
- opt = arguments[0] || {};
1311
-
1312
- opt.frames = opt.frames || 60;
1313
- opt.startFrames = [];
1314
- opt.counters = [];
1315
-
1316
- var framesperbar = opt.frames / 3,
1317
- frame = -1,
1318
- callback = opt.callback || function () {},
1319
- width;
1320
-
1321
- for (var i=0,len=this.coords.length; i<len; i+=1) {
1322
- opt.startFrames[i] = ((opt.frames / 2) / (obj.coords.length - 1)) * i;
1323
- opt.counters[i] = 0;
1324
-
1325
- // Now zero the width of the bar
1326
- this.coords[i].object.setAttribute('width', 0);
1327
- }
1328
-
1329
-
1330
- function iterator ()
1331
- {
1332
- ++frame;
1333
-
1334
- for (var i=0,len=obj.coords.length; i<len; i+=1) {
1335
- if (frame > opt.startFrames[i]) {
1336
-
1337
- var originalWidth = obj.coords[i].object.getAttribute('data-original-width'),
1338
- value = parseFloat(obj.coords[i].object.getAttribute('data-value'));
1339
-
1340
- obj.coords[i].object.setAttribute(
1341
- 'width',
1342
- width = ma.min(
1343
- ((frame - opt.startFrames[i]) / framesperbar) * originalWidth,
1344
- originalWidth
1345
- )
1346
- );
1347
-
1348
- obj.coords[i].object.setAttribute(
1349
- 'x',
1350
- value >=0 ? obj.getXCoord(0) : obj.getXCoord(0) - width
1351
- );
1352
-
1353
-
1354
- if (prop.grouping === 'stacked') {
1355
- var seq = obj.coords[i].object.getAttribute('data-sequential-index');
1356
- var indexes = RG.SVG.sequentialIndexToGrouped(seq, obj.data);
1357
-
1358
- if (indexes[1] > 0) {
1359
- obj.coords[i].object.setAttribute(
1360
- 'x',
1361
- parseInt(obj.coords[i - 1].object.getAttribute('x')) + parseInt(obj.coords[i - 1].object.getAttribute('width'))
1362
- );
1363
- }
1364
- }
1365
- }
1366
- }
1367
-
1368
-
1369
- if (frame >= opt.frames) {
1370
- callback(obj);
1371
- } else {
1372
- RG.SVG.FX.update(iterator);
1373
- }
1374
- }
1375
-
1376
- iterator();
1377
-
1378
- return this;
1379
- };
1380
-
1381
-
1382
-
1383
-
1384
-
1385
-
1386
-
1387
-
1388
- //
1389
- // Set the options that the user has provided
1390
- //
1391
- for (i in conf.options) {
1392
- if (typeof i === 'string') {
1393
- this.set(i, conf.options[i]);
1394
- }
1395
- }
1396
- };
1397
-
1398
- return this;
1399
-
1400
- // End module pattern
1401
- })(window, document);
2
+ RGraph=window.RGraph||{isRGraph:true};RGraph.SVG=RGraph.SVG||{};(function(win,doc,undefined)
3
+ {var RG=RGraph,ua=navigator.userAgent,ma=Math,win=window,doc=document;RG.SVG.HBar=function(conf)
4
+ {this.set=function(name,value)
5
+ {if(arguments.length===1&&typeof name==='object'){for(i in arguments[0]){if(typeof i==='string'){var ret=RG.SVG.commonSetter({object:this,name:i,value:arguments[0][i]});name=ret.name;value=ret.value;this.set(name,value);}}}else{var ret=RG.SVG.commonSetter({object:this,name:name,value:value});name=ret.name;value=ret.value;this.properties[name]=value;if(name==='colors'){this.originalColors=RG.SVG.arrayClone(value);this.colorsParsed=false;}}
6
+ return this;};this.id=conf.id;this.uid=RG.SVG.createUID();this.container=document.getElementById(this.id);this.layers={};this.svg=RG.SVG.createSVG({object:this,container:this.container});this.isRGraph=true;this.width=Number(this.svg.getAttribute('width'));this.height=Number(this.svg.getAttribute('height'));this.data=conf.data;this.type='hbar';this.coords=[];this.stackedBackfaces=[];this.colorsParsed=false;this.originalColors={};this.gradientCounter=1;RG.SVG.OR.add(this);this.container.style.display='inline-block';this.properties={gutterLeft:100,gutterRight:35,gutterTop:35,gutterBottom:35,gutterLeftAutosize:true,backgroundColor:null,backgroundImage:null,backgroundImageAspect:'none',backgroundImageStretch:true,backgroundImageOpacity:null,backgroundImageX:null,backgroundImageY:null,backgroundImageW:null,backgroundImageH:null,backgroundGrid:true,backgroundGridColor:'#ddd',backgroundGridLinewidth:1,backgroundGridHlines:true,backgroundGridHlinesCount:null,backgroundGridVlines:true,backgroundGridVlinesCount:null,backgroundGridBorder:true,backgroundGridDashed:false,backgroundGridDotted:false,backgroundGridDashArray:null,colors:['red','#0f0','#00f','#ff0','#0ff','#0f0','pink','orange','gray','black','red','#0f0','#00f','#ff0','#0ff','#0f0','pink','orange','gray','black'],colorsSequential:false,strokestyle:'rgba(0,0,0,0)',vmargin:3,vmarginGrouped:2,vmarginTop:0,vmarginBottom:0,xaxis:true,xaxisTickmarks:true,xaxisTickmarksLength:5,xaxisColor:'black',xaxisLabels:[],xaxisLabelsOffsetx:0,xaxisLabelsOffsety:0,xaxisLabelsCount:5,xaxisScale:true,xaxisUnitsPre:'',xaxisUnitsPost:'',xaxisStrict:false,xaxisDecimals:0,xaxisPoint:'.',xaxisThousand:',',xaxisRound:false,xaxisMax:null,xaxisMin:0,xaxisFormatter:null,xaxisLabelsPositionEdgeTickmarksCount:null,xaxisTextColor:null,xaxisTextBold:null,xaxisTextItalic:null,xaxisTextFont:null,xaxisTextSize:null,yaxis:true,yaxisTickmarks:true,yaxisTickmarksLength:3,yaxisLabels:[],yaxisLabelsPosition:'section',yaxisLabelsOffsetx:0,yaxisLabelsOffsety:0,yaxisScale:false,yaxisLabelsPositionSectionTickmarksCount:null,yaxisColor:'black',yaxisTextFont:null,yaxisTextSize:null,yaxisTextColor:null,yaxisTextBold:null,yaxisTextItalic:null,textColor:'black',textFont:'sans-serif',textSize:12,textBold:false,textItalic:false,labelsAbove:false,labelsAboveFont:null,labelsAboveSize:null,labelsAboveBold:null,labelsAboveItalic:null,labelsAboveColor:null,labelsAboveBackground:null,labelsAboveBackgroundPadding:0,labelsAboveUnitsPre:null,labelsAboveUnitsPost:null,labelsAbovePoint:null,labelsAboveThousand:null,labelsAboveFormatter:null,labelsAboveDecimals:null,labelsAboveOffsetx:0,labelsAboveOffsety:0,labelsAboveHalign:'left',labelsAboveValign:'center',labelsAboveSpecific:null,linewidth:1,grouping:'grouped',tooltips:null,tooltipsOverride:null,tooltipsEffect:'fade',tooltipsCssClass:'RGraph_tooltip',tooltipsEvent:'click',highlightStroke:'rgba(0,0,0,0)',highlightFill:'rgba(255,255,255,0.7)',highlightLinewidth:1,title:'',titleSize:16,titleX:null,titleY:null,titleHalign:'center',titleValign:null,titleColor:'black',titleFont:null,titleBold:false,titleItalic:false,titleSubtitle:'',titleSubtitleX:null,titleSubtitleY:null,titleSubtitleHalign:'center',titleSubtitleValign:null,titleSubtitleColor:'#aaa',titleSubtitleSize:10,titleSubtitleFont:null,titleSubtitleBold:false,titleSubtitleItalic:false,shadow:false,shadowOffsetx:2,shadowOffsety:2,shadowBlur:2,shadowOpacity:0.25,key:null,keyColors:null,keyOffsetx:0,keyOffsety:0,keyTextOffsetx:0,keyTextOffsety:-1,keyTextSize:null,keyTextBold:null,keyTextItalic:null};RG.SVG.getGlobals(this);if(RG.SVG.FX&&typeof RG.SVG.FX.decorate==='function'){RG.SVG.FX.decorate(this);}
7
+ var prop=this.properties;this.draw=function()
8
+ {RG.SVG.fireCustomEvent(this,'onbeforedraw');RG.SVG.createDefs(this);if(prop.gutterLeftAutosize){for(var i=0,len=prop.yaxisLabels.length,maxLength=0;i<len;++i){var sizes=RG.SVG.measureText({text:prop.yaxisLabels[i],bold:prop.yaxisTextBold||prop.textBold,size:prop.yaxisTextSize||prop.textSize,font:prop.yaxisTextFont||prop.textFont});maxLength=ma.max(maxLength,sizes[0]);}
9
+ prop.gutterLeft=maxLength+15;}
10
+ this.graphWidth=this.width-prop.gutterLeft-prop.gutterRight;this.graphHeight=this.height-prop.gutterTop-prop.gutterBottom;RG.SVG.resetColorsToOriginalValues({object:this});this.parseColors();var values=[];for(var i=0,max=0;i<this.data.length;++i){if(typeof this.data[i]==='number'){values.push(this.data[i]);}else if(RG.SVG.isArray(this.data[i])&&prop.grouping==='grouped'){values.push(RG.SVG.arrayMax(this.data[i]));}else if(RG.SVG.isArray(this.data[i])&&prop.grouping==='stacked'){values.push(RG.SVG.arraySum(this.data[i]));}}
11
+ var max=RG.SVG.arrayMax(values);if(typeof prop.xaxisMax==='number'){max=prop.xaxisMax;}
12
+ if(prop.xaxisMin==='mirror'||prop.xaxisMin==='middle'||prop.xaxisMin==='center'){var mirrorScale=true;prop.xaxisMin=prop.xaxisMax* -1;}
13
+ this.scale=RG.SVG.getScale({object:this,numlabels:prop.xaxisLabelsCount,unitsPre:prop.xaxisUnitsPre,unitsPost:prop.xaxisUnitsPost,max:max,min:prop.xaxisMin,point:prop.xaxisPoint,round:prop.xaxisRound,thousand:prop.xaxisThousand,decimals:prop.xaxisDecimals,strict:typeof prop.xaxisMax==='number',formatter:prop.xaxisFormatter});if(mirrorScale){this.scale=RG.SVG.getScale({object:this,numlabels:prop.xaxisLabelsCount,unitsPre:prop.xaxisUnitsPre,unitsPost:prop.xaxisUnitsPost,max:this.scale.max,min:this.scale.max* -1,point:prop.xaxisPoint,round:false,thousand:prop.xaxisThousand,decimals:prop.xaxisDecimals,strict:typeof prop.xaxisMax==='number',formatter:prop.xaxisFormatter});}
14
+ this.max=this.scale.max;prop.xaxisMax=this.scale.max;this.min=this.scale.min;prop.xaxisMin=this.scale.min;RG.SVG.drawBackground(this);this.drawBars();RG.SVG.drawXAxis(this);RG.SVG.drawYAxis(this);this.drawLabelsAbove();if(typeof prop.key!==null&&RG.SVG.drawKey){RG.SVG.drawKey(this);}else if(!RGraph.SVG.isNull(prop.key)){alert('The drawKey() function does not exist - have you forgotten to include the key library?');}
15
+ RG.SVG.attribution(this);var obj=this;document.body.addEventListener('mousedown',function(e)
16
+ {RG.SVG.removeHighlight(obj);},false);RG.SVG.fireCustomEvent(this,'ondraw');return this;};this.drawBars=function()
17
+ {if(prop.shadow){RG.SVG.setShadow({object:this,offsetx:prop.shadowOffsetx,offsety:prop.shadowOffsety,blur:prop.shadowBlur,opacity:prop.shadowOpacity,id:'dropShadow'});}
18
+ for(var i=0,sequentialIndex=0;i<this.data.length;++i,++sequentialIndex){if(typeof this.data[i]==='number'){var outerSegment=(this.graphHeight-prop.vmarginTop-prop.vmarginBottom)/this.data.length,width=this.getWidth(this.data[i]),height=((this.graphHeight-prop.vmarginTop-prop.vmarginBottom)/this.data.length)-prop.vmargin-prop.vmargin,x=this.getXCoord((this.scale.min<0&&this.scale.max<0)||(this.scale.min>0&&this.scale.max>0)?this.scale.min:0)-(this.data[i]<0?width:0),y=prop.gutterTop+prop.vmarginTop+prop.vmargin+(outerSegment*i);if(this.scale.min<0&&this.scale.max<0){x=this.width-prop.gutterRight-width;}
19
+ var rect=RG.SVG.create({svg:this.svg,parent:this.svg.all,type:'rect',attr:{stroke:prop.strokestyle,fill:prop.colorsSequential?(prop.colors[sequentialIndex]?prop.colors[sequentialIndex]:prop.colors[prop.colors.length-1]):prop.colors[0],x:x,y:y,width:width,height:height,'stroke-width':prop.linewidth,'data-tooltip':(!RG.SVG.isNull(prop.tooltips)&&prop.tooltips.length)?prop.tooltips[i]:'','data-index':i,'data-original-width':width,'data-original-height':height,'data-sequential-index':sequentialIndex,'data-value':this.data[i],filter:prop.shadow?'url(#dropShadow)':''}});this.coords.push({object:rect,x:x,y:y-(this.data[i]>0?height:0),width:width,height:height});if(!RG.SVG.isNull(prop.tooltips)&&prop.tooltips[sequentialIndex]){var obj=this;(function(idx,seq)
20
+ {rect.addEventListener(prop.tooltipsEvent.replace(/^on/,''),function(e)
21
+ {obj.removeHighlight();RG.SVG.tooltip({object:obj,index:idx,group:null,sequentialIndex:seq,text:prop.tooltips[seq],event:e});obj.highlight(e.target);},false);rect.addEventListener('mousemove',function(e)
22
+ {e.target.style.cursor='pointer';},false);})(i,sequentialIndex);}}else if(RG.SVG.isArray(this.data[i])&&prop.grouping==='grouped'){var outerSegment=((this.graphHeight-prop.vmarginTop-prop.vmarginBottom)/this.data.length),innerSegment=outerSegment-(2*prop.vmargin);for(var j=0;j<this.data[i].length;++j,++sequentialIndex){var width=ma.abs((this.data[i][j]/(this.max-this.min))*this.graphWidth),height=((innerSegment-((this.data[i].length-1)*prop.vmarginGrouped))/this.data[i].length),y=prop.gutterTop+prop.vmargin+prop.vmarginTop+(outerSegment*i)+(j*height)+(j*prop.vmarginGrouped),x=this.getXCoord(0)-(this.data[i][j]<0?width:0);if(this.scale.max<0&&this.scale.min<this.scale.max){var x1=this.getXCoord(this.data[i][j]);var x2=this.getXCoord(this.scale.max);x=x1;width=x2-x1;}else if(this.scale.min>0&&this.scale.max>this.scale.min){var x1=this.getXCoord(this.data[i][j]);var x2=this.getXCoord(this.scale.min);x=this.getXCoord(this.scale.min);width=x1-x2;}
23
+ var rect=RG.SVG.create({svg:this.svg,type:'rect',parent:this.svg.all,attr:{stroke:prop['strokestyle'],fill:(prop.colorsSequential&&prop.colors[sequentialIndex])?prop.colors[sequentialIndex]:(prop.colors[j]?prop.colors[j]:prop.colors[prop.colors.length-1]),x:x,y:y,width:width,height:height,'stroke-width':prop.linewidth,'data-index':i,'data-original-width':width,'data-sequential-index':sequentialIndex,'data-tooltip':(!RG.SVG.isNull(prop.tooltips)&&prop.tooltips.length)?prop.tooltips[sequentialIndex]:'','data-value':this.data[i][j],filter:prop.shadow?'url(#dropShadow)':''}});this.coords.push({object:rect,x:x,y:y-(this.data[i][j]>0?height:0),width:width,height:height});if(!RG.SVG.isNull(prop.tooltips)&&prop.tooltips[sequentialIndex]){var obj=this;(function(idx,seq)
24
+ {var indexes=RG.SVG.sequentialIndexToGrouped(seq,obj.data);rect.addEventListener(prop.tooltipsEvent.replace(/^on/,''),function(e)
25
+ {obj.removeHighlight();RG.SVG.tooltip({object:obj,group:idx,index:indexes[1],sequentialIndex:seq,text:prop.tooltips[seq],event:e});obj.highlight(e.target);},false);rect.addEventListener('mousemove',function(e)
26
+ {e.target.style.cursor='pointer'},false);})(i,sequentialIndex);}}
27
+ --sequentialIndex;}else if(RG.SVG.isArray(this.data[i])&&prop.grouping==='stacked'){var section=((this.graphHeight-prop.vmarginTop-prop.vmarginBottom)/this.data.length);var x=this.getXCoord(0);for(var j=0;j<this.data[i].length;++j,++sequentialIndex){var outerHeight=(this.graphHeight-prop.vmarginTop-prop.vmarginBottom)/this.data.length,width=ma.abs((this.data[i][j]/(this.max-this.min))*this.graphWidth),height=outerHeight-(2*prop.vmargin),y=prop.gutterTop+prop.vmargin+prop.vmarginTop+(outerHeight*i);if(j===0&&prop.shadow){var fullWidth=ma.abs((RG.SVG.arraySum(this.data[i])/(this.max-this.min))*this.graphWidth);var rect=RG.SVG.create({svg:this.svg,parent:this.svg.all,type:'rect',attr:{x:x,y:y,width:fullWidth,height:height,fill:'white','stroke-width':0,'data-index':i,filter:'url(#dropShadow)'}});this.stackedBackfaces[i]=rect;}
28
+ var rect=RG.SVG.create({svg:this.svg,type:'rect',parent:this.svg.all,attr:{stroke:prop['strokestyle'],fill:prop.colorsSequential?(prop.colors[sequentialIndex]?prop.colors[sequentialIndex]:prop.colors[prop.colors.length-1]):(prop.colors[j]?prop.colors[j]:prop.colors[prop.colors.length-1]),x:x,y:y,width:width,height:height,'stroke-width':prop.linewidth,'data-original-width':width,'data-original-height':height,'data-original-x':x,'data-original-y':y,'data-index':i,'data-sequential-index':sequentialIndex,'data-tooltip':(!RG.SVG.isNull(prop.tooltips)&&prop.tooltips.length)?prop.tooltips[sequentialIndex]:'','data-value':this.data[i][j]}});this.coords.push({object:rect,x:x,y:y,width:width,height:height});if(!RG.SVG.isNull(prop.tooltips)&&prop.tooltips[sequentialIndex]){var obj=this;(function(idx,seq)
29
+ {rect.addEventListener(prop.tooltipsEvent.replace(/^on/,''),function(e)
30
+ {obj.removeHighlight();var indexes=RG.SVG.sequentialIndexToGrouped(seq,obj.data);RG.SVG.tooltip({object:obj,index:indexes[1],group:idx,sequentialIndex:seq,text:prop.tooltips[seq],event:e});obj.highlight(e.target);},false);rect.addEventListener('mousemove',function(e)
31
+ {e.target.style.cursor='pointer'},false);})(i,sequentialIndex);}
32
+ x+=width;}
33
+ --sequentialIndex;}}};this.getXCoord=function(value)
34
+ {var prop=this.properties;if(value>this.scale.max){return null;}
35
+ var x;if(value<this.scale.min){return null;}
36
+ x=((value-this.scale.min)/(this.scale.max-this.scale.min));x*=this.graphWidth;x+=prop.gutterLeft;return x;};this.getWidth=function(value)
37
+ {if(this.scale.max<=0&&this.scale.min<this.scale.max){var x1=this.getXCoord(this.scale.max);var x2=this.getXCoord(value);}else if(this.scale.min>0&&this.scale.max>this.scale.min){var x1=this.getXCoord(this.scale.min);var x2=this.getXCoord(value);}else{var x1=this.getXCoord(0);var x2=this.getXCoord(value);}
38
+ return ma.abs(x1-x2);};this.highlight=function(rect)
39
+ {var x=rect.getAttribute('x'),y=rect.getAttribute('y'),width=rect.getAttribute('width'),height=rect.getAttribute('height');var highlight=RG.SVG.create({svg:this.svg,type:'rect',parent:this.svg.all,attr:{stroke:prop.highlightStroke,fill:prop.highlightFill,x:x,y:y,width:width,height:height,'stroke-width':prop.highlightLinewidth}});RG.SVG.REG.set('highlight',highlight);};this.parseColors=function()
40
+ {if(!Object.keys(this.originalColors).length){this.originalColors={colors:RG.SVG.arrayClone(prop.colors),backgroundGridColor:RG.SVG.arrayClone(prop.backgroundGridColor),highlightFill:RG.SVG.arrayClone(prop.highlightFill),backgroundColor:RG.SVG.arrayClone(prop.backgroundColor)}}
41
+ var colors=prop.colors;if(colors){for(var i=0;i<colors.length;++i){colors[i]=RG.SVG.parseColorLinear({object:this,color:colors[i],direction:'horizontal',start:prop.gutterLeft,end:this.width-prop.gutterRight});}}
42
+ prop.backgroundGridColor=RG.SVG.parseColorLinear({object:this,color:prop.backgroundGridColor,direction:'horizontal',start:prop.gutterLeft,end:this.width-prop.gutterRight});prop.highlightFill=RG.SVG.parseColorLinear({object:this,color:prop.highlightFill,direction:'horizontal',start:prop.gutterLeft,end:this.width-prop.gutterRight});prop.backgroundColor=RG.SVG.parseColorLinear({object:this,color:prop.backgroundColor});};this.drawLabelsAbove=function()
43
+ {if(prop.labelsAbove){var data=RG.SVG.arrayLinearize(this.data);for(var i=0;i<this.coords.length;++i){var value=data[i].toFixed(typeof prop.labelsAboveDecimals==='number'?prop.labelsAboveDecimals:prop.xaxisDecimals);var indexes=RG.SVG.sequentialIndexToGrouped(i,this.data);if(RG.SVG.isArray(this.data[indexes[0]])&&prop.grouping==='stacked'){if((indexes[1]+1)===this.data[indexes[0]].length){value=RG.SVG.arraySum(this.data[indexes[0]]);value=value.toFixed(typeof prop.labelsAboveDecimals==='number'?prop.labelsAboveDecimals:prop.xaxisDecimals);}else{continue;}}
44
+ var str=prop.labelsAboveSpecific?prop.labelsAboveSpecific[i].toString():RG.SVG.numberFormat({object:this,num:value,prepend:typeof prop.labelsAboveUnitsPre==='string'?prop.labelsAboveUnitsPre:null,append:typeof prop.labelsAboveUnitsPost==='string'?prop.labelsAboveUnitsPost:null,point:typeof prop.labelsAbovePoint==='string'?prop.labelsAbovePoint:null,thousand:typeof prop.labelsAboveThousand==='string'?prop.labelsAboveThousand:null,formatter:typeof prop.labelsAboveFormatter==='function'?prop.labelsAboveFormatter:null});var bold=typeof prop.labelsAboveBold==='boolean'?prop.labelsAboveBold:prop.textBold,italic=typeof prop.labelsAboveItalic==='boolean'?prop.labelsAboveItalic:prop.textItalic,size=prop.labelsAboveSize||prop.textSize,font=prop.labelsAboveFont||prop.textFont,halign=prop.labelsAboveHalign,valign=prop.labelsAboveValign;var dimensions=RG.SVG.measureText({text:str,bold:bold,font:font,size:size});var x=(value>=0)?(parseFloat(this.coords[i].object.getAttribute('x'))+parseFloat(this.coords[i].object.getAttribute('width'))+7+prop.labelsAboveOffsetx):parseFloat(this.coords[i].object.getAttribute('x')-7-prop.labelsAboveOffsetx),y=parseFloat(this.coords[i].object.getAttribute('y'))+parseFloat(this.coords[i].object.getAttribute('height')/2)+prop.labelsAboveOffsety,width=dimensions[0],height=dimensions[1],halign=(value>=0)?'left':'right';if(x+width>this.width&&value>0){halign='right';x=this.width-5;prop.labelsAboveBackground=prop.labelsAboveBackground||'rgba(255,255,255,0.95)';}
45
+ var text=RG.SVG.text({object:this,parent:this.svg.all,text:str,x:x,y:y,halign:halign,valign:valign,font:font,size:size,bold:bold,italic:italic,color:prop.labelsAboveColor||prop.textColor,background:prop.labelsAboveBackground||null,padding:prop.labelsAboveBackgroundPadding||0});}}};this.on=function(type,func)
46
+ {if(type.substr(0,2)!=='on'){type='on'+type;}
47
+ RG.SVG.addCustomEventListener(this,type,func);return this;};this.exec=function(func)
48
+ {func(this);return this;};this.removeHighlight=function()
49
+ {var highlight=RG.SVG.REG.get('highlight');if(highlight&&highlight.parentNode){highlight.parentNode.removeChild(highlight);}
50
+ RG.SVG.REG.set('highlight',null);};this.grow=function()
51
+ {var opt=arguments[0]||{},frames=opt.frames||30,frame=0,obj=this,data=[],height=null,seq=0;data=RG.SVG.arrayClone(this.data);this.draw();var iterate=function()
52
+ {for(var i=0,seq=0,len=obj.coords.length;i<len;++i,++seq){var multiplier=(frame/frames)*RG.SVG.FX.getEasingMultiplier(frames,frame)*RG.SVG.FX.getEasingMultiplier(frames,frame);if(typeof data[i]==='number'){width=ma.abs(obj.getXCoord(data[i])-obj.getXCoord(0));obj.data[i]=data[i]*multiplier;width=multiplier*width;obj.coords[seq].object.setAttribute('width',width);obj.coords[seq].object.setAttribute('x',data[i]>0?obj.getXCoord(0):obj.getXCoord(0)-width);}else if(typeof data[i]==='object'){var accumulativeWidth=0;for(var j=0,len2=data[i].length;j<len2;++j,++seq){width=ma.abs(obj.getXCoord(data[i][j])-obj.getXCoord(0));width=multiplier*width;obj.data[i][j]=data[i][j]*multiplier;obj.coords[seq].object.setAttribute('width',width);obj.coords[seq].object.setAttribute('x',data[i][j]>0?(obj.getXCoord(0)+accumulativeWidth):(obj.getXCoord(0)-width-accumulativeWidth));accumulativeWidth+=(prop.grouping==='stacked'?width:0);}
53
+ if(obj.stackedBackfaces[i]){obj.stackedBackfaces[i].setAttribute('width',accumulativeWidth);obj.stackedBackfaces[i].setAttribute('x',prop.gutterLeft);}
54
+ --seq;}}
55
+ if(frame++<frames){RG.SVG.FX.update(iterate);}else if(opt.callback){(opt.callback)(obj);}};iterate();return this;};this.wave=function()
56
+ {this.draw();var obj=this,opt=arguments[0]||{};opt.frames=opt.frames||60;opt.startFrames=[];opt.counters=[];var framesperbar=opt.frames/3,frame=-1,callback=opt.callback||function(){},width;for(var i=0,len=this.coords.length;i<len;i+=1){opt.startFrames[i]=((opt.frames/2)/(obj.coords.length-1))*i;opt.counters[i]=0;this.coords[i].object.setAttribute('width',0);}
57
+ function iterator()
58
+ {++frame;for(var i=0,len=obj.coords.length;i<len;i+=1){if(frame>opt.startFrames[i]){var originalWidth=obj.coords[i].object.getAttribute('data-original-width'),value=parseFloat(obj.coords[i].object.getAttribute('data-value'));obj.coords[i].object.setAttribute('width',width=ma.min(((frame-opt.startFrames[i])/framesperbar)*originalWidth,originalWidth));obj.coords[i].object.setAttribute('x',value>=0?obj.getXCoord(0):obj.getXCoord(0)-width);if(prop.grouping==='stacked'){var seq=obj.coords[i].object.getAttribute('data-sequential-index');var indexes=RG.SVG.sequentialIndexToGrouped(seq,obj.data);if(indexes[1]>0){obj.coords[i].object.setAttribute('x',parseInt(obj.coords[i-1].object.getAttribute('x'))+parseInt(obj.coords[i-1].object.getAttribute('width')));}}}}
59
+ if(frame>=opt.frames){callback(obj);}else{RG.SVG.FX.update(iterator);}}
60
+ iterator();return this;};for(i in conf.options){if(typeof i==='string'){this.set(i,conf.options[i]);}}};return this;})(window,document);