rgraph-rails 5.00 → 6.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/publish-geml.yaml +46 -0
  3. data/.gitignore +1 -0
  4. data/README.md +4 -5
  5. data/lib/rgraph-rails/version.rb +1 -1
  6. data/rgraph-rails.gemspec +4 -4
  7. data/vendor/assets/javascripts/RGraph.activity.js +1691 -0
  8. data/vendor/assets/javascripts/RGraph.bar.js +4253 -236
  9. data/vendor/assets/javascripts/RGraph.bipolar.js +3958 -162
  10. data/vendor/assets/javascripts/RGraph.common.annotate.js +414 -35
  11. data/vendor/assets/javascripts/RGraph.common.context.js +635 -30
  12. data/vendor/assets/javascripts/RGraph.common.core.js +10485 -419
  13. data/vendor/assets/javascripts/RGraph.common.csv.js +508 -27
  14. data/vendor/assets/javascripts/RGraph.common.dynamic.js +1693 -90
  15. data/vendor/assets/javascripts/RGraph.common.effects.js +1629 -89
  16. data/vendor/assets/javascripts/RGraph.common.key.js +1003 -53
  17. data/vendor/assets/javascripts/RGraph.common.moment.js +5670 -0
  18. data/vendor/assets/javascripts/RGraph.common.sheets.js +541 -31
  19. data/vendor/assets/javascripts/RGraph.common.sheets.php +351 -0
  20. data/vendor/assets/javascripts/RGraph.common.starburst.js +382 -0
  21. data/vendor/assets/javascripts/RGraph.common.table.js +386 -0
  22. data/vendor/assets/javascripts/RGraph.common.tooltips.js +1433 -32
  23. data/vendor/assets/javascripts/RGraph.drawing.background.js +660 -35
  24. data/vendor/assets/javascripts/RGraph.drawing.circle.js +618 -34
  25. data/vendor/assets/javascripts/RGraph.drawing.image.js +857 -52
  26. data/vendor/assets/javascripts/RGraph.drawing.line.js +712 -0
  27. data/vendor/assets/javascripts/RGraph.drawing.marker1.js +760 -38
  28. data/vendor/assets/javascripts/RGraph.drawing.marker2.js +740 -37
  29. data/vendor/assets/javascripts/RGraph.drawing.marker3.js +573 -36
  30. data/vendor/assets/javascripts/RGraph.drawing.poly.js +667 -36
  31. data/vendor/assets/javascripts/RGraph.drawing.rect.js +638 -34
  32. data/vendor/assets/javascripts/RGraph.drawing.text.js +672 -37
  33. data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +653 -52
  34. data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +714 -51
  35. data/vendor/assets/javascripts/RGraph.fuel.js +1149 -59
  36. data/vendor/assets/javascripts/RGraph.funnel.js +1277 -56
  37. data/vendor/assets/javascripts/RGraph.gantt.js +1646 -82
  38. data/vendor/assets/javascripts/RGraph.gauge.js +1773 -89
  39. data/vendor/assets/javascripts/RGraph.hbar.js +3869 -159
  40. data/vendor/assets/javascripts/RGraph.horseshoe.js +970 -0
  41. data/vendor/assets/javascripts/RGraph.hprogress.js +1829 -81
  42. data/vendor/assets/javascripts/RGraph.line.js +5293 -244
  43. data/vendor/assets/javascripts/RGraph.meter.js +1570 -77
  44. data/vendor/assets/javascripts/RGraph.modaldialog.js +300 -19
  45. data/vendor/assets/javascripts/RGraph.odo.js +1553 -68
  46. data/vendor/assets/javascripts/RGraph.pie.js +3273 -129
  47. data/vendor/assets/javascripts/RGraph.radar.js +2333 -108
  48. data/vendor/assets/javascripts/RGraph.rose.js +2685 -114
  49. data/vendor/assets/javascripts/RGraph.rscatter.js +1920 -80
  50. data/vendor/assets/javascripts/RGraph.scatter.js +4215 -171
  51. data/vendor/assets/javascripts/RGraph.segmented.js +1006 -0
  52. data/vendor/assets/javascripts/RGraph.semicircularprogress.js +1980 -59
  53. data/vendor/assets/javascripts/RGraph.svg.activity.js +1696 -0
  54. data/vendor/assets/javascripts/RGraph.svg.bar.js +2575 -77
  55. data/vendor/assets/javascripts/RGraph.svg.bipolar.js +3533 -106
  56. data/vendor/assets/javascripts/RGraph.svg.common.ajax.js +240 -21
  57. data/vendor/assets/javascripts/RGraph.svg.common.core.js +7105 -299
  58. data/vendor/assets/javascripts/RGraph.svg.common.csv.js +408 -28
  59. data/vendor/assets/javascripts/RGraph.svg.common.fx.js +1291 -68
  60. data/vendor/assets/javascripts/RGraph.svg.common.key.js +451 -20
  61. data/vendor/assets/javascripts/RGraph.svg.common.sheets.js +543 -31
  62. data/vendor/assets/javascripts/RGraph.svg.common.table.js +391 -0
  63. data/vendor/assets/javascripts/RGraph.svg.common.tooltips.js +1072 -23
  64. data/vendor/assets/javascripts/RGraph.svg.funnel.js +1151 -32
  65. data/vendor/assets/javascripts/RGraph.svg.gauge.js +1429 -34
  66. data/vendor/assets/javascripts/RGraph.svg.hbar.js +2692 -65
  67. data/vendor/assets/javascripts/RGraph.svg.horseshoe.js +969 -0
  68. data/vendor/assets/javascripts/RGraph.svg.line.js +2855 -86
  69. data/vendor/assets/javascripts/RGraph.svg.pie.js +1630 -58
  70. data/vendor/assets/javascripts/RGraph.svg.radar.js +1772 -58
  71. data/vendor/assets/javascripts/RGraph.svg.rose.js +2419 -83
  72. data/vendor/assets/javascripts/RGraph.svg.scatter.js +2280 -65
  73. data/vendor/assets/javascripts/RGraph.svg.segmented.js +930 -0
  74. data/vendor/assets/javascripts/RGraph.svg.semicircularprogress.js +1612 -29
  75. data/vendor/assets/javascripts/RGraph.svg.waterfall.js +1525 -50
  76. data/vendor/assets/javascripts/RGraph.thermometer.js +1411 -64
  77. data/vendor/assets/javascripts/RGraph.vprogress.js +1915 -81
  78. data/vendor/assets/javascripts/RGraph.waterfall.js +1896 -89
  79. data/vendor/assets/javascripts/financial-data.js +1067 -0
  80. metadata +37 -16
  81. data/.travis.yml +0 -11
  82. data/vendor/assets/javascripts/RGraph.common.deprecated.js +0 -35
  83. data/vendor/assets/javascripts/RGraph.common.resizing.js +0 -38
  84. data/vendor/assets/javascripts/RGraph.common.zoom.js +0 -15
  85. data/vendor/assets/javascripts/RGraph.cornergauge.js +0 -71
@@ -1,33 +1,1152 @@
1
+ 'version:2023-09-16 (6.14)';
2
+ //
3
+ // o--------------------------------------------------------------------------------o
4
+ // | This file is part of the RGraph package - you can learn more at: |
5
+ // | |
6
+ // | https://www.rgraph.net |
7
+ // | |
8
+ // | RGraph is licensed under the Open Source MIT license. That means that it's |
9
+ // | totally free to use and there are no restrictions on what you can do with it! |
10
+ // o--------------------------------------------------------------------------------o
1
11
 
2
- RGraph=window.RGraph||{isRGraph:true};RGraph.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'){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.get=function(name)
7
- {return this.properties[name];};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;this.propertyNameAliases={};RG.SVG.OR.add(this);this.container.style.display='inline-block';var obj=this;this.data.forEach(function(val,key,arr)
8
- {obj.max=ma.max(obj.max,val);});this.properties={marginLeft:35,marginRight:35,marginTop:35,marginBottom:35,backgroundbars:false,backgroundBarsOpacity:0.25,backgroundBarsColors:null,colorsStroke:'white',colors:['red','black','orange','green','#6ff','#ccc','pink','orange','cyan','maroon','olive','teal'],textColor:'black',textFont:'Arial, Verdana, sans-serif',textSize:12,textBold:false,textItalic:false,labels:[],labelsFont:null,labelsSize:null,labelsColor:null,labelsBold:null,labelsItalic:null,labelsBackground:null,labelsHalign:'center',labelsPosition:'section',linewidth:1,tooltips:null,tooltipsOverride:null,tooltipsEffect:'fade',tooltipsCssClass:'RGraph_tooltip',tooltipsEvent:'click',highlightStroke:'rgba(0,0,0,0)',highlightStroke:'rgba(0,0,0,0)',highlightFill:'rgba(255,255,255,0.7)',highlightLinewidth:1,title:'',titleX:null,titleY:null,titleHalign:'center',titleValign:null,titleSize:null,titleColor:null,titleFont:null,titleBold:null,titleItalic:null,titleSubtitle:null,titleSubtitleX:null,titleSubtitleY:null,titleSubtitleHalign:'center',titleSubtitleValign:null,titleSubtitleSize:null,titleSubtitleColor:'#aaa',titleSubtitleFont:null,titleSubtitleBold:null,titleSubtitleItalic:null,shadow:false,shadowOffsetx:2,shadowOffsety:2,shadowBlur:2,shadowOpacity:0.25,key:null,keyColors:null,keyOffsetx:0,keyOffsety:0,keyLabelsOffsetx:0,keyLabelsOffsety:-1,keyLabelsFont:null,keyLabelsSize:null,keyLabelsColor:null,keyLabelsBold:null,keyLabelsItalic:null};RG.SVG.getGlobals(this);if(RG.SVG.FX&&typeof RG.SVG.FX.decorate==='function'){RG.SVG.FX.decorate(this);}
9
- var prop=this.properties;this.draw=function()
10
- {RG.SVG.fireCustomEvent(this,'onbeforedraw');this.width=Number(this.svg.getAttribute('width'));this.height=Number(this.svg.getAttribute('height'));this.data=RG.SVG.arrayClone(this.originalData);this.coords=[];RG.SVG.createDefs(this);this.graphWidth=this.width-prop.marginLeft-prop.marginRight;this.graphHeight=this.height-prop.marginTop-prop.marginBottom;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]);}}
11
- 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?');}
12
- var obj=this;doc.body.addEventListener('mousedown',function(e)
13
- {obj.hideHighlight(obj);},false);RG.SVG.fireCustomEvent(this,'ondraw');return this;};this.drawFunnel=function(opt)
14
- {var centerx=prop.marginLeft+(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.marginTop+(height*i),x2=centerx+(width/2),y2=prop.marginTop+(height*i);x3=centerx+(nextWidth/2),y3=prop.marginTop+(height*(i+1)),x4=centerx-(nextWidth/2),y4=prop.marginTop+(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,object:this});}
15
- 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.colorsStroke,fill:prop.colors[i],'stroke-width':prop.linewidth,'data-value':this.data[i],'data-index':i}});coords.element=path;if(!RG.SVG.isNull(prop.tooltips)&&prop.tooltips[i]){var obj=this;(function(idx,seq)
16
- {path.addEventListener(prop.tooltipsEvent.replace(/^on/,''),function(e)
17
- {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)
18
- {e.target.style.cursor='pointer'},false);})(i,sequentialIndex);}}}};this.redrawFunnel=function()
19
- {};this.drawBackgroundBars=function()
20
- {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()
21
- {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';}
22
- 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,tag:'labels',text:typeof prop.labels[i]==='string'||prop.labels[i]==='number'?prop.labels[i].toString():'',x:x,y:prop.marginTop+(sectionHeight/2)+(i*sectionHeight),halign:halign,valign:'center',background:prop.labelsBackground||'rgba(255,255,255,0.5)',padding:2,color:prop.labelsColor||prop.textColor,size:typeof prop.labelsSize==='number'?prop.labelsSize:prop.textSize,bold:typeof prop.labelsBold==='boolean'?prop.labelsBold:prop.textBold,italic:typeof prop.labelsItalic==='boolean'?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,tag:'labels',text:typeof prop.labels[i]==='string'||prop.labels[i]==='number'?prop.labels[i].toString():'',x:x,y:prop.marginTop+((this.graphHeight/(prop.labels.length-1))*i),halign:halign,valign:'center',background:prop.labelsBackground||'rgba(255,255,255,0.5)',padding:2,size:typeof prop.labelsSize==='number'?prop.labelsSize:prop.textSize,bold:typeof prop.labelsBold==='boolean'?prop.labelsBold:prop.textBold,italic:typeof prop.labelsItalic==='boolean'?prop.labelsItalic:prop.textItalic,color:prop.labelsColor||prop.textColor||'black',font:prop.labelsFont||prop.textFont});}}}};this.highlight=function(path)
23
- {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},style:{pointerEvents:'none'}});if(prop.tooltipsEvent==='mousemove'){highlight.addEventListener('mouseout',function(e)
24
- {highlight.parentNode.removeChild(highlight);RG.SVG.hideTooltip();RG.SVG.REG.set('highlight',null);},false);}
25
- RG.SVG.REG.set('highlight',highlight);};this.parseColors=function()
26
- {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)}}
27
- 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'});}}
28
- 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'});}}
29
- prop.highlightFill=RG.SVG.parseColorLinear({object:this,color:prop.highlightFill});};this.on=function(type,func)
30
- {if(type.substr(0,2)!=='on'){type='on'+type;}
31
- RG.SVG.addCustomEventListener(this,type,func);return this;};this.exec=function(func)
32
- {func(this);return this;};this.removeHighlight=this.hideHighlight=function()
33
- {var highlight=RG.SVG.REG.get('highlight');if(highlight){highlight.setAttribute('fill','transparent');highlight.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);
12
+ RGraph = window.RGraph || {isrgraph:true,isRGraph:true,rgraph:true};
13
+ RGraph.SVG = RGraph.SVG || {};
14
+
15
+ // Module pattern
16
+ (function (win, doc, undefined)
17
+ {
18
+ RGraph.SVG.Funnel = function (conf)
19
+ {
20
+ //
21
+ // A setter that the constructor uses (at the end)
22
+ // to set all of the properties
23
+ //
24
+ // @param string name The name of the property to set
25
+ // @param string value The value to set the property to
26
+ //
27
+ this.set = function (name, value)
28
+ {
29
+ if (arguments.length === 1 && typeof name === 'object') {
30
+ for (i in arguments[0]) {
31
+ if (typeof i === 'string') {
32
+
33
+ name = ret.name;
34
+ value = ret.value;
35
+
36
+ this.set(name, value);
37
+ }
38
+ }
39
+
40
+ } else {
41
+
42
+ var ret = RGraph.SVG.commonSetter({
43
+ object: this,
44
+ name: name,
45
+ value: value
46
+ });
47
+
48
+ name = ret.name;
49
+ value = ret.value;
50
+
51
+ this.properties[name] = value;
52
+
53
+ // If setting the colors, update the originalColors
54
+ // property too
55
+ if (name === 'colors') {
56
+ this.originalColors = RGraph.SVG.arrayClone(value);
57
+ this.colorsParsed = false;
58
+ }
59
+ }
60
+
61
+ return this;
62
+ };
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+ //
72
+ // A getter.
73
+ //
74
+ // @param name string The name of the property to get
75
+ //
76
+ this.get = function (name)
77
+ {
78
+ return this.properties[name];
79
+ };
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+ // Convert strings to numbers
92
+ conf.data = RGraph.SVG.stringsToNumbers(conf.data);
93
+ //if (typeof conf.data === 'string') {
94
+ // conf.data = conf.data.split(/,|\|/);
95
+ //}
96
+
97
+ //for (var i=0; i<conf.data.length; ++i) {
98
+ // if (typeof conf.data[i] === 'string') {
99
+ // conf.data[i] = parseFloat(conf.data[i]);
100
+ // }
101
+ //}
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+ this.id = conf.id;
115
+ this.uid = RGraph.SVG.createUID();
116
+ this.container = document.getElementById(this.id);
117
+ this.layers = {}; // MUST be before the SVG element is created!
118
+ this.svg = RGraph.SVG.createSVG({object: this,container: this.container});
119
+ this.isRGraph = true;
120
+ this.isrgraph = true;
121
+ this.rgraph = true;
122
+ this.width = Number(this.svg.getAttribute('width'));
123
+ this.height = Number(this.svg.getAttribute('height'));
124
+ this.data = RGraph.SVG.arrayClone(conf.data);
125
+ this.originalData = RGraph.SVG.arrayClone(conf.data);
126
+ this.type = 'funnel';
127
+ this.coords = [];
128
+ this.colorsParsed = false;
129
+ this.originalColors = {};
130
+ this.gradientCounter = 1;
131
+ this.nodes = [];
132
+ this.shadowNodes = [];
133
+ this.max = 0;
134
+ this.redraw = false;
135
+ this.highlight_node = null;
136
+ this.firstDraw = true; // After the first draw this will be false
137
+
138
+
139
+
140
+
141
+
142
+
143
+ // Add this object to the ObjectRegistry
144
+ RGraph.SVG.OR.add(this);
145
+
146
+ // Set the DIV container to be inline-block
147
+ this.container.style.display = 'inline-block';
148
+
149
+ // Determine the maximum value by going thru the data
150
+ var obj = this;
151
+ this.data.forEach(function (val, key, arr)
152
+ {
153
+ obj.max = Math.max(obj.max, val);
154
+ });
155
+
156
+
157
+
158
+
159
+
160
+
161
+ this.properties =
162
+ {
163
+ marginLeft: 35,
164
+ marginRight: 35,
165
+ marginTop: 35,
166
+ marginBottom: 35,
167
+
168
+ backgroundBars: false,
169
+ backgroundBarsOpacity: 0.25,
170
+ backgroundBarsColors: null,
171
+
172
+ colorsStroke: 'white',
173
+ colors: ['red', 'black', 'orange', 'green', '#6ff', '#ccc', 'pink', 'orange', 'cyan', 'maroon', 'olive', 'teal'],
174
+
175
+ textColor: 'black',
176
+ textFont: 'Arial, Verdana, sans-serif',
177
+ textSize: 12,
178
+ textBold: false,
179
+ textItalic: false,
180
+ text: null,
181
+
182
+ labels: [],
183
+ labelsFont: null,
184
+ labelsSize: null,
185
+ labelsColor: null,
186
+ labelsBold: null,
187
+ labelsItalic: null,
188
+ labelsBackground: null,
189
+ labelsHalign: 'center',
190
+ labelsPosition: 'section', // This can be section or edge
191
+ labelsFormattedDecimals: 0,
192
+ labelsFormattedPoint: '.',
193
+ labelsFormattedThousand: ',',
194
+ labelsFormattedUnitsPre: '',
195
+ labelsFormattedUnitsPost: '',
196
+
197
+ linewidth: 1,
198
+
199
+ tooltips: null,
200
+ tooltipsOverride: null,
201
+ tooltipsEffect: 'fade',
202
+ tooltipsCssClass: 'RGraph_tooltip',
203
+ tooltipsCss: null,
204
+ tooltipsEvent: 'click',
205
+ tooltipsFormattedThousand: ',',
206
+ tooltipsFormattedPoint: '.',
207
+ tooltipsFormattedDecimals: 0,
208
+ tooltipsFormattedUnitsPre: '',
209
+ tooltipsFormattedUnitsPost: '',
210
+ tooltipsFormattedKeyColors: null,
211
+ tooltipsFormattedKeyColorsShape: 'square',
212
+ tooltipsFormattedKeyLabels: [],
213
+ tooltipsFormattedTableHeaders: null,
214
+ tooltipsFormattedTableData: null,
215
+ tooltipsPointer: true,
216
+ tooltipsPointerOffsetx: 0,
217
+ tooltipsPointerOffsety: 0,
218
+ tooltipsPositionStatic: true,
219
+
220
+ highlightStroke: 'rgba(0,0,0,0)',
221
+ // Lighter than usual because the backgroundBars option can
222
+ // mean highlight segments fade into the background
223
+ highlightStroke: 'rgba(0,0,0,0)',
224
+ highlightFill: 'rgba(255,255,255,0.7)',
225
+ highlightLinewidth: 1,
226
+
227
+ title: '',
228
+ titleX: null,
229
+ titleY: null,
230
+ titleHalign: 'center',
231
+ titleValign: null,
232
+ titleSize: null,
233
+ titleColor: null,
234
+ titleFont: null,
235
+ titleBold: null,
236
+ titleItalic: null,
237
+
238
+ titleSubtitle: null,
239
+ titleSubtitleSize: null,
240
+ titleSubtitleColor: '#aaa',
241
+ titleSubtitleFont: null,
242
+ titleSubtitleBold: null,
243
+ titleSubtitleItalic: null,
244
+
245
+ key: null,
246
+ keyColors: null,
247
+ keyOffsetx: 0,
248
+ keyOffsety: 0,
249
+ keyLabelsOffsetx: 0,
250
+ keyLabelsOffsety: -1,
251
+ keyLabelsFont: null,
252
+ keyLabelsSize: null,
253
+ keyLabelsColor: null,
254
+ keyLabelsBold: null,
255
+ keyLabelsItalic: null
256
+ };
257
+
258
+
259
+
260
+
261
+ //
262
+ // Copy the global object properties to this instance
263
+ //
264
+ RGraph.SVG.getGlobals(this);
265
+
266
+
267
+
268
+
269
+
270
+
271
+ //
272
+ // "Decorate" the object with the generic effects if the effects library has been included
273
+ //
274
+ if (RGraph.SVG.FX && typeof RGraph.SVG.FX.decorate === 'function') {
275
+ RGraph.SVG.FX.decorate(this);
276
+ }
277
+
278
+
279
+
280
+
281
+
282
+ // Add the responsive function to the object
283
+ this.responsive = RGraph.SVG.responsive;
284
+
285
+
286
+
287
+
288
+
289
+
290
+ var properties = this.properties;
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+ //
300
+ // The draw method draws the Bar chart
301
+ //
302
+ this.draw = function ()
303
+ {
304
+ // Fire the beforedraw event
305
+ RGraph.SVG.fireCustomEvent(this, 'onbeforedraw');
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+ // Should the first thing that's done inthe.draw() function
316
+ // except for the onbeforedraw event
317
+ this.width = Number(this.svg.getAttribute('width'));
318
+ this.height = Number(this.svg.getAttribute('height'));
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+ // Reset the data back to the original values
332
+ this.data = RGraph.SVG.arrayClone(this.originalData);
333
+
334
+
335
+
336
+ // Reset the coords array to stop it growing
337
+ this.coords = [];
338
+
339
+
340
+
341
+
342
+
343
+ // Create the defs tag if necessary
344
+ RGraph.SVG.createDefs(this);
345
+
346
+
347
+
348
+ this.graphWidth = this.width - properties.marginLeft - properties.marginRight;
349
+ this.graphHeight = this.height - properties.marginTop - properties.marginBottom;
350
+
351
+ //
352
+ // Add the data to the .originalData array and work out the max value
353
+ //
354
+ // 2/5/14 Now also use this loop to ensure that the data pieces
355
+ // are numbers
356
+ //
357
+
358
+ // Convert strings to numbers
359
+ for (var i=0,len=this.data.length; i<len; ++i) {
360
+ if (typeof this.data[i] === 'string') {
361
+ this.data[i] = RGraph.SVG.stringsToNumbers(this.data[i]);
362
+ }
363
+ }
364
+
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+ // Parse the colors for gradients
377
+ RGraph.SVG.resetColorsToOriginalValues({object:this});
378
+ this.parseColors();
379
+
380
+
381
+
382
+
383
+ // Draw the chart
384
+ this.drawFunnel();
385
+
386
+
387
+
388
+ // Draw the background bars
389
+ this.drawBackgroundBars();
390
+
391
+
392
+
393
+
394
+
395
+
396
+ // Draw the labels
397
+ this.drawLabels();
398
+
399
+
400
+
401
+ // Draw the title and subtitle
402
+ RGraph.SVG.drawTitle(this);
403
+
404
+
405
+
406
+
407
+
408
+
409
+ // Draw the key
410
+ if (typeof properties.key !== null && RGraph.SVG.drawKey) {
411
+ RGraph.SVG.drawKey(this);
412
+ } else if (!RGraph.SVG.isNull(properties.key)) {
413
+ alert('The drawKey() function does not exist - have you forgotten to include the key library?');
414
+ }
415
+
416
+
417
+
418
+ // Create the shadow definition if needed
419
+ //if (properties.shadow) {
420
+ // RGraph.SVG.setShadow({
421
+ // object: this,
422
+ // offsetx: properties.shadowOffsetx,
423
+ // offsety: properties.shadowOffsety,
424
+ // blur: properties.shadowBlur,
425
+ // color: properties.shadowColor,
426
+ // id: 'dropShadow'
427
+ // });
428
+ //}
429
+
430
+
431
+
432
+ // Add the event listener that clears the highlight if
433
+ // there is any. Must be MOUSEDOWN (ie before the click event)
434
+ var obj = this;
435
+ document.body.addEventListener('mousedown', function (e)
436
+ {
437
+ obj.hideHighlight(obj);
438
+ }, false);
439
+
440
+
441
+
442
+
443
+
444
+
445
+
446
+
447
+ //
448
+ // Allow the addition of custom text via the
449
+ // text: property.
450
+ //
451
+ RGraph.SVG.addCustomText(this);
452
+
453
+
454
+
455
+
456
+
457
+
458
+
459
+
460
+
461
+
462
+
463
+
464
+
465
+ //
466
+ // Fire the onfirstdraw event
467
+ //
468
+ if (this.firstDraw) {
469
+ this.firstDraw = false;
470
+ RGraph.SVG.fireCustomEvent(this, 'onfirstdraw');
471
+ }
472
+
473
+
474
+
475
+
476
+
477
+ // Fire the draw event
478
+ RGraph.SVG.fireCustomEvent(this, 'ondraw');
479
+
480
+
481
+
482
+
483
+
484
+
485
+
486
+ //
487
+ // Install any inline responsive configuration. This
488
+ // should be last in the draw function - even after
489
+ // the draw events.
490
+ //
491
+ RGraph.SVG.installInlineResponsive(this);
492
+
493
+
494
+
495
+
496
+
497
+
498
+
499
+
500
+
501
+
502
+
503
+ return this;
504
+ };
505
+
506
+
507
+
508
+
509
+
510
+
511
+
512
+
513
+ //
514
+ // New create() shortcut function
515
+ // For example:
516
+ // this.create('rect,x:0,y:0,width:100,height:100'[,parent]);
517
+ //
518
+ // @param str string The tag definition to parse and create
519
+ // @param object The (optional) parent element
520
+ // @return object The new tag
521
+ //
522
+ this.create = function (str)
523
+ {
524
+ var def = RGraph.SVG.create.parseStr(this, str);
525
+ def.svg = this.svg;
526
+
527
+ // By default the parent is the SVG tag - but if
528
+ // requested then change it to the tag that has
529
+ // been given
530
+ if (arguments[1]) {
531
+ def.parent = arguments[1];
532
+ }
533
+
534
+ return RGraph.SVG.create(def);
535
+ };
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+
544
+ //
545
+ // Draws the radar.
546
+ //
547
+ //@param opt object Options for the function (if any)
548
+ //
549
+ this.drawFunnel = function (opt)
550
+ {
551
+ // This is the center of the Funnel ONLY - not the whole chart
552
+ var centerx = properties.marginLeft + (this.graphWidth / 2);
553
+
554
+ // This first loop calculates the coordinates only - it DOES NOT
555
+ // draw the Funnel on to the scene
556
+ for (var i=0; i<(this.data.length - 1); ++i) {
557
+
558
+ var value = this.data[i],
559
+ nextValue = this.data[i+1],
560
+ maxWidth = this.graphWidth,
561
+ width = (value / this.max) * this.graphWidth,
562
+ height = this.graphHeight / (this.data.length - 1), // The heights are equal
563
+ nextWidth = (nextValue / this.max) * this.graphWidth,
564
+ nextHeight = height;
565
+
566
+ // The coordinates
567
+ var x1 = centerx - (width / 2),
568
+ y1 = properties.marginTop + (height * i),
569
+ x2 = centerx + (width / 2),
570
+ y2 = properties.marginTop + (height * i);
571
+ x3 = centerx + (nextWidth / 2),
572
+ y3 = properties.marginTop + (height * (i+1)),
573
+ x4 = centerx - (nextWidth / 2),
574
+ y4 = properties.marginTop + (height * (i+1));
575
+
576
+ // Store the coords
577
+ this.coords.push({
578
+ x1: x1,
579
+ y1: y1,
580
+ x2: x2,
581
+ y2: y2,
582
+ x3: x3,
583
+ y3: y3,
584
+ x4: x4,
585
+ y4: y4,
586
+ widthTop: x2 - x1,
587
+ widthBottom: x3 - x4,
588
+ height: y3 - y2,
589
+ object: this
590
+
591
+ });
592
+ }
593
+
594
+
595
+
596
+
597
+ // Now go thru the coods and draw the shapes
598
+ for (var i=0,len=this.coords.length,sequentialIndex=0; i<len; ++i,++sequentialIndex) {
599
+
600
+ if (i < len) {
601
+ var coords = this.coords[i];
602
+
603
+ var path = RGraph.SVG.create({
604
+ svg: this.svg,
605
+ type: 'path',
606
+ parent: this.svg.all,
607
+ attr: {
608
+ d: 'M {1} {2} L {3} {4} L {5} {6} L {7} {8} z'.format(
609
+ coords.x1,
610
+ coords.y1,
611
+ coords.x2,
612
+ coords.y2,
613
+ coords.x3,
614
+ coords.y3,
615
+ coords.x4,
616
+ coords.y4
617
+ ),
618
+ stroke: properties.colorsStroke,
619
+ fill: properties.colors[i],
620
+ 'stroke-width': properties.linewidth,
621
+ 'data-value': this.data[i],
622
+ 'data-index': i
623
+ }
624
+ });
625
+
626
+
627
+
628
+
629
+
630
+ // Store a reference to the SVG path object just created
631
+ coords.element = path;
632
+
633
+
634
+
635
+
636
+
637
+
638
+
639
+
640
+
641
+
642
+
643
+
644
+ // Install tooltips event listener
645
+
646
+ // Add the tooltip data- attribute
647
+ if (!RGraph.SVG.isNull(properties.tooltips) && (properties.tooltips[i] || typeof properties.tooltips === 'string') ) {
648
+
649
+ var obj = this;
650
+
651
+ //
652
+ // Add tooltip event listeners
653
+ //
654
+ (function (idx, seq)
655
+ {
656
+ path.addEventListener(properties.tooltipsEvent.replace(/^on/, ''), function (e)
657
+ {
658
+ obj.removeHighlight();
659
+
660
+ // Show the tooltip
661
+ RGraph.SVG.tooltip({
662
+ object: obj,
663
+ index: idx,
664
+ group: null,
665
+ sequentialIndex: seq,
666
+ text: typeof properties.tooltips === 'string' ? properties.tooltips : properties.tooltips[seq],
667
+ event: e
668
+ });
669
+
670
+ // Highlight the rect that has been clicked on
671
+ obj.highlight(e.target);
672
+ }, false);
673
+
674
+ path.addEventListener('mousemove', function (e)
675
+ {
676
+ e.target.style.cursor = 'pointer'
677
+ }, false);
678
+ })(i, sequentialIndex);
679
+
680
+ } // end if
681
+ } // end if
682
+ } // end for
683
+ };
684
+
685
+
686
+
687
+
688
+
689
+
690
+
691
+
692
+ //
693
+ // Redraws the chart if required
694
+ //
695
+ this.redrawFunnel = function ()
696
+ {
697
+ };
698
+
699
+ //
700
+ // Draws the background bars. This is called AFTER the .draw() function
701
+ // and manages to draw the background bars behind the funnel by utilising
702
+ // the background layers (or one of them at least)
703
+ //
704
+ this.drawBackgroundBars = function ()
705
+ {
706
+ if (properties.backgroundBars) {
707
+
708
+ for (var i=0; i<this.coords.length; ++i) {
709
+
710
+ var coords = this.coords[i];
711
+
712
+ RGraph.SVG.create({
713
+ svg: this.svg,
714
+ type: 'rect',
715
+ parent: this.layers.background1,
716
+ attr: {
717
+ x: 0,
718
+ y: coords.y1,
719
+ width: this.width,
720
+ height: coords.y3 - coords.y2,
721
+ fill: properties.backgroundBarsColors && typeof properties.backgroundBarsColors === 'object' && typeof properties.backgroundBarsColors[i] === 'string' ? properties.backgroundBarsColors[i] : properties.colors[i],
722
+ 'fill-opacity': properties.backgroundBarsOpacity
723
+ }
724
+ });
725
+ }
726
+ }
727
+ };
728
+
729
+
730
+
731
+
732
+
733
+
734
+
735
+
736
+ //
737
+ // Draw the labels
738
+ //
739
+ this.drawLabels = function ()
740
+ {
741
+
742
+
743
+
744
+ if (properties.labels && properties.labels.length) {
745
+ //
746
+ // If the labels option is a string then turn it
747
+ // into an array.
748
+ //
749
+ if (typeof properties.labels === 'string') {
750
+ properties.labels = RGraph.SVG.arrayPad({
751
+ array: [],
752
+ length: this.coords.length + 1,
753
+ value: properties.labels
754
+ });
755
+ }
756
+
757
+ //
758
+ // Label substitution
759
+ //
760
+ for (var i=0; i<properties.labels.length; ++i) {
761
+ properties.labels[i] = RGraph.SVG.labelSubstitution({
762
+ object: this,
763
+ text: properties.labels[i],
764
+ index: i,
765
+ value: this.data[i],
766
+ decimals: properties.labelsFormattedDecimals || 0,
767
+ unitsPre: properties.labelsFormattedUnitsPre || '',
768
+ unitsPost: properties.labelsFormattedUnitsPost || '',
769
+ thousand: properties.labelsFormattedThousand || ',',
770
+ point: properties.labelsFormattedPoint || '.'
771
+ });
772
+ }
773
+ }
774
+
775
+
776
+
777
+
778
+
779
+
780
+ // Create the group that the labels are added to
781
+ var labelsGroup = RGraph.SVG.create({
782
+ svg: this.svg,
783
+ parent: this.svg.all,
784
+ type: 'g'
785
+ });
786
+
787
+ // Get the text configuration for the labels
788
+ var textConf = RGraph.SVG.getTextConf({
789
+ object: this,
790
+ prefix: 'labels'
791
+ });
792
+
793
+ // Determine the alignment
794
+ if (properties.labelsHalign === 'left') {
795
+ var x = 15;
796
+ var halign = 'left';
797
+
798
+ } else if (properties.labelsHalign === 'right') {
799
+ var x = this.width - 15;
800
+ var halign = 'right';
801
+
802
+ } else {
803
+ var x = this.width / 2;
804
+ var halign = 'center';
805
+ }
806
+
807
+
808
+ if (properties.labels && properties.labels.length) {
809
+ if (properties.labelsPosition === 'section') {
810
+
811
+ var sectionHeight = this.graphHeight / properties.labels.length;
812
+
813
+ for (var i=0; i<properties.labels.length; ++i) {
814
+
815
+ RGraph.SVG.text({
816
+
817
+ object: this,
818
+ svg: this.svg,
819
+ parent: labelsGroup,
820
+ tag: 'labels',
821
+
822
+ text: typeof properties.labels[i] === 'string' || properties.labels[i] === 'number' ? properties.labels[i].toString() : '',
823
+
824
+ x: x,
825
+ y: properties.marginTop + (sectionHeight / 2) + (i * sectionHeight),
826
+
827
+ halign: halign,
828
+ valign: 'center',
829
+
830
+ background: properties.labelsBackground || 'rgba(255,255,255,0.5)',
831
+ padding: 2,
832
+
833
+ color: textConf.color,
834
+ size: textConf.size,
835
+ bold: textConf.bold,
836
+ italic: textConf.italic,
837
+ font: textConf.font
838
+ });
839
+ }
840
+
841
+ // edge Positioning
842
+ } else {
843
+
844
+ for (var i=0; i<properties.labels.length; ++i) {
845
+ RGraph.SVG.text({
846
+
847
+ object: this,
848
+ svg: this.svg,
849
+ parent: labelsGroup,
850
+ tag: 'labels',
851
+
852
+ text: typeof properties.labels[i] === 'string' || properties.labels[i] === 'number' ? properties.labels[i].toString() : '',
853
+
854
+ x: x,
855
+ y: properties.marginTop + ((this.graphHeight / (properties.labels.length - 1) ) * i),
856
+
857
+ halign: halign,
858
+ valign: 'center',
859
+
860
+ background: properties.labelsBackground || 'rgba(255,255,255,0.5)',
861
+ padding: 2,
862
+
863
+ size: textConf.size,
864
+ bold: textConf.bold,
865
+ italic: textConf.italic,
866
+ color: textConf.color,
867
+ font: textConf.font
868
+ });
869
+ }
870
+ }
871
+ }
872
+ };
873
+
874
+
875
+
876
+
877
+
878
+
879
+
880
+
881
+ //
882
+ // This function can be used to highlight a segment on the chart
883
+ //
884
+ // @param object circle The circle to highlight
885
+ //
886
+ this.highlight = function (path)
887
+ {
888
+ var path = path.getAttribute('d');
889
+
890
+ var highlight = RGraph.SVG.create({
891
+ svg: this.svg,
892
+ parent: this.svg.all,
893
+ type: 'path',
894
+ attr: {
895
+ d: path,
896
+ fill: properties.highlightFill,
897
+ stroke: properties.highlightStroke,
898
+ 'stroke-width': properties.highlightLinewidth
899
+ },
900
+ style: {
901
+ pointerEvents: 'none'
902
+ }
903
+ });
904
+
905
+
906
+ if (properties.tooltipsEvent === 'mousemove') {
907
+ highlight.addEventListener('mouseout', function (e)
908
+ {
909
+ highlight.parentNode.removeChild(highlight);
910
+ RGraph.SVG.hideTooltip();
911
+
912
+ RGraph.SVG.REG.set('highlight', null);
913
+ }, false);
914
+ }
915
+
916
+
917
+ // Store the highlight rect in the registry so
918
+ // it can be cleared later
919
+ RGraph.SVG.REG.set('highlight', highlight);
920
+
921
+ };
922
+
923
+
924
+
925
+
926
+
927
+
928
+
929
+
930
+ //
931
+ // This allows for easy specification of gradients
932
+ //
933
+ this.parseColors = function ()
934
+ {
935
+ // Save the original colors so that they can be restored when the canvas is reset
936
+ if (!Object.keys(this.originalColors).length) {
937
+ this.originalColors = {
938
+ colors: RGraph.SVG.arrayClone(properties.colors),
939
+ highlightFill: RGraph.SVG.arrayClone(properties.highlightFill),
940
+ backgroundBarsColors: RGraph.SVG.arrayClone(properties.backgroundBarsColors)
941
+ }
942
+ }
943
+
944
+
945
+ // colors
946
+ var colors = properties.colors;
947
+
948
+ if (colors) {
949
+ for (var i=0; i<colors.length; ++i) {
950
+ colors[i] = RGraph.SVG.parseColorLinear({
951
+ object: this,
952
+ color: colors[i],
953
+ direction:'horizontal'
954
+ });
955
+ }
956
+ }
957
+
958
+ // backgroundBarsColors
959
+ if (properties.backgroundBarsColors && properties.backgroundBarsColors.length) {
960
+ for (var i=0; i<properties.backgroundBarsColors.length; ++i) {
961
+ properties.backgroundBarsColors[i] = RGraph.SVG.parseColorLinear({
962
+ object: this,
963
+ color: properties.backgroundBarsColors[i],
964
+ direction:'horizontal'
965
+ });
966
+ }
967
+ }
968
+
969
+ // Highlight fill
970
+ properties.highlightFill = RGraph.SVG.parseColorLinear({
971
+ object: this,
972
+ color: properties.highlightFill
973
+ });
974
+ };
975
+
976
+
977
+
978
+
979
+
980
+
981
+
982
+
983
+ //
984
+ // Using a function to add events makes it easier to facilitate method
985
+ // chaining
986
+ //
987
+ // @param string type The type of even to add
988
+ // @param function func
989
+ //
990
+ this.on = function (type, func)
991
+ {
992
+ if (type.substr(0,2) !== 'on') {
993
+ type = 'on' + type;
994
+ }
995
+
996
+ RGraph.SVG.addCustomEventListener(this, type, func);
997
+
998
+ return this;
999
+ };
1000
+
1001
+
1002
+
1003
+
1004
+
1005
+
1006
+
1007
+
1008
+ //
1009
+ // Used in chaining. Runs a function there and then - not waiting for
1010
+ // the events to fire (eg the onbeforedraw event)
1011
+ //
1012
+ // @param function func The function to execute
1013
+ //
1014
+ this.exec = function (func)
1015
+ {
1016
+ func(this);
1017
+
1018
+ return this;
1019
+ };
1020
+
1021
+
1022
+
1023
+
1024
+
1025
+
1026
+
1027
+
1028
+ //
1029
+ // Removes the tooltip highlight from the chart
1030
+ //
1031
+ this.removeHighlight =
1032
+ this.hideHighlight = function ()
1033
+ {
1034
+
1035
+ //var highlight = RGraph.SVG.REG.get('highlight');
1036
+
1037
+ //if (highlight) {
1038
+ // highlight.setAttribute('fill','transparent');
1039
+ // highlight.setAttribute('stroke','transparent');
1040
+ //
1041
+ // RGraph.SVG.REG.set('highlight', null);
1042
+ //}
1043
+
1044
+ RGraph.SVG.removeHighlight();
1045
+ };
1046
+
1047
+
1048
+
1049
+
1050
+
1051
+
1052
+
1053
+
1054
+ //
1055
+ // A worker function that handles Bar chart specific tooltip substitutions
1056
+ //
1057
+ this.tooltipSubstitutions = function (opt)
1058
+ {
1059
+ return {
1060
+ index: opt.index,
1061
+ dataset: 0,
1062
+ sequentialIndex: opt.index,
1063
+ value: this.data[opt.index],
1064
+ values: [this.data[opt.index]]
1065
+ };
1066
+ };
1067
+
1068
+
1069
+
1070
+
1071
+
1072
+
1073
+
1074
+
1075
+ //
1076
+ // A worker function that returns the correct color/label/value
1077
+ //
1078
+ // @param object specific The indexes that are applicable
1079
+ // @param number index The appropriate index
1080
+ //
1081
+ this.tooltipsFormattedCustom = function (specific, index, colors)
1082
+ {
1083
+ var color = colors[specific.index];
1084
+ var label = ( (typeof properties.tooltipsFormattedKeyLabels === 'object' && typeof properties.tooltipsFormattedKeyLabels[specific.index] === 'string') ? properties.tooltipsFormattedKeyLabels[specific.index] : '');
1085
+
1086
+ return {
1087
+ label: label,
1088
+ color: color
1089
+ };
1090
+ };
1091
+
1092
+
1093
+
1094
+
1095
+
1096
+
1097
+
1098
+
1099
+ //
1100
+ // This allows for static tooltip positioning
1101
+ //
1102
+ this.positionTooltipStatic = function (args)
1103
+ {
1104
+ var obj = args.object,
1105
+ e = args.event,
1106
+ tooltip = args.tooltip,
1107
+ index = args.index,
1108
+ svgXY = RGraph.SVG.getSVGXY(obj.svg),
1109
+ coords = this.coords[args.index];
1110
+
1111
+ // Position the tooltip in the X direction
1112
+ args.tooltip.style.left = (
1113
+ svgXY[0] // The X coordinate of the canvas
1114
+ + coords.x1 // The first X coordinate of the segment on the chart
1115
+ - (tooltip.offsetWidth / 2) // Subtract half of the tooltip width
1116
+ + ((coords.x2 - coords.x1) / 2)
1117
+ ) + 'px';
1118
+
1119
+ args.tooltip.style.top = (
1120
+ svgXY[1] // The Y coordinate of the canvas
1121
+ + coords.y1 // The Y coordinate of the bar on the chart
1122
+ - tooltip.offsetHeight // The height of the tooltip
1123
+ - 10 // An arbitrary amount
1124
+ ) + 'px';
1125
+ };
1126
+
1127
+
1128
+
1129
+
1130
+
1131
+
1132
+
1133
+
1134
+ //
1135
+ // Set the options that the user has provided
1136
+ //
1137
+ for (i in conf.options) {
1138
+ if (typeof i === 'string') {
1139
+ this.set(i, conf.options[i]);
1140
+ }
1141
+ }
1142
+ };
1143
+
1144
+
1145
+
1146
+ return this;
1147
+
1148
+
1149
+
1150
+
1151
+ // End module pattern
1152
+ })(window, document);