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,60 +1,1981 @@
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.SemiCircularProgress=function(conf)
3
- {if(typeof conf==='object'&&typeof conf.id==='string'){var parseConfObjectForOptions=true;}else{var conf={id:arguments[0],min:arguments[1],max:arguments[2],value:arguments[3]}}
4
- this.id=conf.id;this.canvas=document.getElementById(this.id);this.context=this.canvas.getContext('2d');this.canvas.__object__=this;this.min=RGraph.stringsToNumbers(conf.min);this.max=RGraph.stringsToNumbers(conf.max);this.value=RGraph.stringsToNumbers(conf.value);this.type='semicircularprogress';this.coords=[];this.isRGraph=true;this.currentValue=null;this.uid=RGraph.createUID();this.canvas.uid=this.canvas.uid?this.canvas.uid:RGraph.CreateUID();this.colorsParsed=false;this.coordsText=[];this.original_colors=[];this.firstDraw=true;this.propertyNameAliases={};this.properties={'chart.background.color':'rgba(0,0,0,0)','chart.colors':['#0c0'],'chart.linewidth':2,'chart.colors.stroke':'#666','chart.margin.left':25,'chart.margin.right':25,'chart.margin.top':25,'chart.margin.bottom':35,'chart.radius':null,'chart.centerx':null,'chart.centery':null,'chart.width':null,'chart.angles.start':Math.PI,'chart.angles.end':(2*Math.PI),'chart.scale.decimals':0,'chart.scale.point':'.','chart.scale.thousand':',','chart.scale.formatter':null,'chart.scale.round':false,'chart.scale.units.pre':'','chart.scale.units.post':'','chart.shadow':false,'chart.shadow.color':'rgba(220,220,220,1)','chart.shadow.blur':2,'chart.shadow.offsetx':2,'chart.shadow.offsety':2,'chart.labels.center':true,'chart.labels.center.fade':false,'chart.labels.center.size':40,'chart.labels.center.color':null,'chart.labels.center.bold':null,'chart.labels.center.italic':null,'chart.labels.center.font':null,'chart.labels.center.valign':'bottom','chart.labels.min.color':null,'chart.labels.min.font':null,'chart.labels.min.bold':null,'chart.labels.min.size':null,'chart.labels.min.italic':null,'chart.labels.min.offset.angle':0,'chart.labels.min.offsetx':0,'chart.labels.min.offsety':5,'chart.labels.max.color':null,'chart.labels.max.font':null,'chart.labels.max.bold':null,'chart.labels.max.size':null,'chart.labels.max.italic':null,'chart.labels.max.offset.angle':0,'chart.labels.max.offsetx':0,'chart.labels.max.offsety':5,'chart.title':'','chart.title.bold':null,'chart.title.italic':null,'chart.title.font':null,'chart.title.size':null,'chart.title.color':null,'chart.text.size':12,'chart.text.color':'black','chart.text.font':'Arial, Verdana, sans-serif','chart.text.bold':false,'chart.text.italic':false,'chart.text.accessible':true,'chart.text.accessible.overflow':'visible','chart.text.accessible.pointerevents':false,'chart.contextmenu':null,'chart.tooltips':null,'chart.tooltips.effect':'fade','chart.tooltips.css.class':'RGraph_tooltip','chart.tooltips.highlight':true,'chart.tooltips.event':'onclick','chart.tooltips.coords.page':true,'chart.highlight.stroke':'rgba(0,0,0,0)','chart.highlight.fill':'rgba(255,255,255,0.7)','chart.annotatable':false,'chart.annotateble.color':'black','chart.annotateble.linewidth':1,'chart.resizable':false,'chart.resizable.handle.adjust':[0,0],'chart.resizable.handle.background':null,'chart.adjustable':false,'chart.events.click':null,'chart.events.mousemove':null,'chart.clearto':'rgba(0,0,0,0)'}
5
- if(!this.canvas){alert('[SEMICIRCULARPROGRESS] No canvas support');return;}
6
- if(!this.canvas.__rgraph_aa_translated__){this.context.translate(0.5,0.5);this.canvas.__rgraph_aa_translated__=true;}
7
- var RG=RGraph,ca=this.canvas,co=ca.getContext('2d'),prop=this.properties,pa2=RG.path2,win=window,doc=document,ma=Math
8
- if(RG.Effects&&typeof RG.Effects.decorate==='function'){RG.Effects.decorate(this);}
9
- this.set=this.Set=function(name)
10
- {var value=typeof arguments[1]==='undefined'?null:arguments[1];if(arguments.length===1&&typeof name==='object'){RG.parseObjectStyleConfig(this,name);return this;}
11
- if(name.substr(0,6)!='chart.'){name='chart.'+name;}
12
- while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
13
- prop[name.toLowerCase()]=value;return this;};this.get=this.Get=function(name)
14
- {if(name.substr(0,6)!='chart.'){name='chart.'+name;}
15
- while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
16
- return prop[name.toLowerCase()];};this.draw=this.Draw=function()
17
- {RG.fireCustomEvent(this,'onbeforedraw');if(!this.colorsParsed){this.parseColors();this.colorsParsed=true;}
18
- this.currentValue=this.value;this.marginLeft=prop['chart.margin.left'];this.marginRight=prop['chart.margin.right'];this.marginTop=prop['chart.margin.top'];this.marginBottom=prop['chart.margin.bottom'];this.radius=ma.min((ca.width-prop['chart.margin.left']-prop['chart.margin.right'])/2,ca.height-prop['chart.margin.top']-prop['chart.margin.bottom']);this.centerx=((ca.width-this.marginLeft-this.marginRight)/2)+this.marginLeft;this.centery=ca.height-this.marginBottom;this.width=this.radius/3;if(typeof prop['chart.radius']==='number')this.radius=prop['chart.radius'];if(typeof prop['chart.centerx']==='number')this.centerx=prop['chart.centerx'];if(typeof prop['chart.centery']==='number')this.centery=prop['chart.centery'];if(typeof prop['chart.width']==='number')this.width=prop['chart.width'];this.coords=[];this.coordsText=[];this.drawMeter();this.drawLabels();if(prop['chart.contextmenu']){RG.showContext(this);}
19
- RG.installEventListeners(this);if(prop['chart.resizable']){RG.allowResizing(this);}
20
- this.allowAdjusting();if(this.firstDraw){this.firstDraw=false;RG.fireCustomEvent(this,'onfirstdraw');this.firstDrawFunc();}
21
- RG.fireCustomEvent(this,'ondraw');return this;};this.drawMeter=this.DrawMeter=function()
22
- {var start=prop['chart.angles.start'],end=prop['chart.angles.end'];this.scale2=RG.getScale2(this,{'scale.max':this.max,'scale.strict':true,'scale.min':this.min,'scale.thousand':prop['chart.scale.thousand'],'scale.point':prop['chart.scale.point'],'scale.decimals':prop['chart.scale.decimals'],'scale.labels.count':5,'scale.units.pre':prop['chart.scale.units.pre'],'scale.units.post':prop['chart.scale.units.post']});if(prop['chart.background.color']!=='rgba(0,0,0,0)'){pa2(co,'fs % fr % % % %',prop['chart.background.color'],0,0,ca.width,ca.height);}
23
- pa2(co,'lw % b a % % % % % false a % % % % % true c s % f % sx % sy % sc % sb % f % sx 0 sy 0 sb 0 sc rgba(0,0,0,0) lw 1',prop['chart.linewidth'],this.centerx,this.centery,this.radius,start,end,this.centerx,this.centery,this.radius-this.width,end,start,prop['chart.colors.stroke'],typeof prop['chart.colors'][1]!=='undefined'?prop['chart.colors'][1]:prop['chart.colors'][0],prop['chart.shadow.offsetx'],prop['chart.shadow.offsety'],prop['chart.shadow']?prop['chart.shadow.color']:'rgba(0,0,0,0)',prop['chart.shadow.blur'],typeof prop['chart.colors'][1]!=='undefined'?'rgba(0,0,0,0)':'rgba(255,255,255,0.85)');var angle=start+((end-start)*((this.value-this.scale2.min)/(this.max-this.scale2.min)));pa2(co,'b a % % % % % false a % % % % % true c f %',this.centerx,this.centery,this.radius,start,angle,this.centerx,this.centery,this.radius-this.width,start+((end-start)*((this.value-this.scale2.min)/(this.max-this.scale2.min))),start,prop['chart.colors'][0]);this.coords=[[this.centerx,this.centery,this.radius,start,end,this.width,angle]];};this.drawLabels=this.DrawLabels=function()
24
- {var min=RG.numberFormat({object:this,number:this.scale2.min.toFixed(typeof prop['chart.labels.min.decimals']==='number'?prop['chart.labels.min.decimals']:prop['chart.scale.decimals']),unitspre:typeof prop['chart.labels.min.units.pre']==='string'?prop['chart.labels.min.units.pre']:prop['chart.scale.units.pre'],unitspost:typeof prop['chart.labels.min.units.post']==='string'?prop['chart.labels.min.units.post']:prop['chart.scale.units.post'],point:typeof prop['chart.labels.min.point']==='string'?prop['chart.labels.min.point']:prop['chart.scale.point'],thousand:typeof prop['chart.labels.min.thousand']==='string'?prop['chart.labels.min.thousand']:prop['chart.scale.thousand']});var max=RG.numberFormat({object:this,number:this.scale2.max.toFixed(typeof prop['chart.labels.max.decimals']==='number'?prop['chart.labels.max.decimals']:prop['chart.scale.decimals']),unitspre:typeof prop['chart.labels.max.units.pre']==='string'?prop['chart.labels.max.units.pre']:prop['chart.scale.units.pre'],unitspost:typeof prop['chart.labels.max.units.post']==='string'?prop['chart.labels.max.units.post']:prop['chart.scale.units.post'],point:typeof prop['chart.labels.max.point']==='string'?prop['chart.labels.max.point']:prop['chart.scale.point'],thousand:typeof prop['chart.labels.max.thousand']==='string'?prop['chart.labels.max.thousand']:prop['chart.scale.thousand']});if(prop['chart.angles.start']===RGraph.PI){var halign='center';var valign='top';}else if(prop['chart.angles.start']<=RGraph.PI){var halign='left';var valign='center';}else if(prop['chart.angles.start']>=RGraph.PI){var halign='right';var valign='center';}
25
- var xy=RG.getRadiusEndPoint(this.centerx,this.centery,prop['chart.angles.start']+prop['chart.labels.min.offset.angle'],this.radius-(this.width/2));var textConf=RG.getTextConf({object:this,prefix:'chart.labels.min'});RG.text2(this,{font:textConf.font,size:textConf.size,color:textConf.color,bold:textConf.bold,italic:textConf.italic,x:xy[0]+prop['chart.labels.min.offsetx'],y:xy[1]+prop['chart.labels.min.offsety'],valign:valign,halign:halign,text:min});if(prop['chart.angles.end']===RGraph.TWOPI){var halign='center';var valign='top';}else if(prop['chart.angles.end']>=RGraph.TWOPI){var halign='right';var valign='center';}else if(prop['chart.angles.end']<=RGraph.TWOPI){var halign='left';var valign='center';}
26
- var xy=RG.getRadiusEndPoint(this.centerx,this.centery,prop['chart.angles.end']+prop['chart.labels.max.offset.angle'],this.radius-(this.width/2));var textConf=RG.getTextConf({object:this,prefix:'chart.labels.max'});RG.text2(this,{font:textConf.font,size:textConf.size,color:textConf.color,bold:textConf.bold,italic:textConf.italic,x:xy[0]+prop['chart.labels.max.offsetx'],y:xy[1]+prop['chart.labels.max.offsety'],valign:valign,halign:halign,text:max});if(prop['chart.labels.center']){var textConf=RG.getTextConf({object:this,prefix:'chart.labels.center'});var ret=RG.text2(this,{font:textConf.font,size:textConf.size,color:textConf.color,bold:textConf.bold,italic:textConf.italic,x:this.centerx,y:this.centery,valign:prop['chart.labels.center.valign'],halign:'center',text:RG.numberFormat({object:this,number:this.value.toFixed(typeof prop['chart.labels.center.decimals']==='number'?prop['chart.labels.center.decimals']:prop['chart.scale.decimals']),unitspre:typeof prop['chart.labels.center.units.pre']==='string'?prop['chart.labels.center.units.pre']:prop['chart.scale.units.pre'],unitspost:typeof prop['chart.labels.center.units.post']==='string'?prop['chart.labels.center.units.post']:prop['chart.scale.units.post'],point:typeof prop['chart.labels.center.point']==='string'?prop['chart.labels.center.point']:prop['chart.scale.point'],thousand:typeof prop['chart.labels.center.thousand']==='string'?prop['chart.labels.center.thousand']:prop['chart.scale.thousand']})});if(prop['chart.labels.center.fade']&&ret.node){ret.node.style.opacity=0;var delay=25,incr=0.1;for(var i=0;i<10;++i){(function(index)
27
- {setTimeout(function()
28
- {ret.node.style.opacity=incr*index;},delay*(index+1));})(i);}}}
29
- RG.drawTitle(this,prop['chart.title'],this.marginTop,null,prop['chart.title.size']);};this.getShape=function(e)
30
- {var mouseXY=RG.getMouseXY(e),mouseX=mouseXY[0],mouseY=mouseXY[1]
31
- pa2(co,'b a % % % % % false a % % % % % true',this.coords[0][0],this.coords[0][1],this.coords[0][2],this.coords[0][3],this.coords[0][6],this.coords[0][0],this.coords[0][1],this.coords[0][2]-this.coords[0][5],this.coords[0][6],this.coords[0][3]);if(co.isPointInPath(mouseX,mouseY)){return{object:this,0:this,x:this.coords[0][0],1:this.coords[0][0],y:this.coords[0][1],2:this.coords[0][1],radius:this.coords[0][2],3:this.coords[0][2],width:this.coords[0][5],4:this.coords[0][5],start:this.coords[0][3],5:this.coords[0][3],end:this.coords[0][6],6:this.coords[0][6],index:0,tooltip:!RG.isNull(prop['chart.tooltips'])?prop['chart.tooltips'][0]:null};}};this.getValue=function(e)
32
- {var mouseXY=RG.getMouseXY(e),mouseX=mouseXY[0],mouseY=mouseXY[1],angle=RG.getAngleByXY(this.centerx,this.centery,mouseX,mouseY);if(angle&&mouseX>=this.centerx&&mouseY>this.centery){angle+=RGraph.TWOPI;}
33
- if(angle<prop['chart.angles.start']&&mouseX>this.centerx){angle=prop['chart.angles.end'];}
34
- if(angle<prop['chart.angles.start']){angle=prop['chart.angles.start'];}
35
- var value=(((angle-prop['chart.angles.start'])/(prop['chart.angles.end']-prop['chart.angles.start']))*(this.max-this.min))+this.min;value=ma.max(value,this.min);value=ma.min(value,this.max);return value;};this.highlight=this.Highlight=function(shape)
36
- {if(typeof prop['chart.highlight.style']==='function'){(prop['chart.highlight.style'])(shape);}else{pa2(co,'lw 5 b a % % % % % false a % % % % % true c f % s % lw 1',shape.x,shape.y,shape.radius,shape.start,shape.end,shape.x,shape.y,shape.radius-shape.width,shape.end,shape.start,prop['chart.highlight.fill'],prop['chart.highlight.stroke']);}};this.getObjectByXY=function(e)
37
- {var mouseXY=RG.getMouseXY(e);pa2(co,'b a % % % % % false',this.centerx,this.centery,this.radius,prop['chart.angles.start'],prop['chart.angles.end']);pa2(co,'a % % % % % true',this.centerx,this.centery,this.radius-this.width,prop['chart.angles.end'],prop['chart.angles.start']);return co.isPointInPath(mouseXY[0],mouseXY[1])?this:null;};this.allowAdjusting=this.AllowAdjusting=function(){};this.adjusting_mousemove=this.Adjusting_mousemove=function(e)
38
- {if(prop['chart.adjustable']&&RG.Registry.get('chart.adjusting')&&RG.Registry.get('chart.adjusting').uid==this.uid){var value=this.getValue(e);if(typeof value==='number'){RG.fireCustomEvent(this,'onadjust');this.value=Number(value.toFixed(prop['chart.scale.decimals']));RG.redrawCanvas(this.canvas);}}};this.getAngle=function(value)
39
- {if(value>this.max||value<this.min){return null;}
40
- var angle=(value/this.max)*(prop['chart.angles.end']-prop['chart.angles.start'])
41
- angle+=prop['chart.angles.start'];return angle;};this.overChartArea=function(e)
42
- {var mouseXY=RGraph.getMouseXY(e),mouseX=mouseXY[0],mouseY=mouseXY[1]
43
- pa2(co,'b a % % % % % false a % % % % % true',this.coords[0][0],this.coords[0][1],this.coords[0][2],prop['chart.angles.start'],prop['chart.angles.end'],this.coords[0][0],this.coords[0][1],this.coords[0][2]-this.coords[0][5],prop['chart.angles.end'],prop['chart.angles.start']);return co.isPointInPath(mouseX,mouseY);};this.parseColors=function()
44
- {if(this.original_colors.length===0){this.original_colors['chart.background.color']=RG.arrayClone(prop['chart.background.color']);this.original_colors['chart.colors']=RG.arrayClone(prop['chart.colors']);}
45
- prop['chart.colors'][0]=this.parseSingleColorForGradient(prop['chart.colors'][0]);prop['chart.colors'][1]=this.parseSingleColorForGradient(prop['chart.colors'][1]);prop['chart.colors.stroke']=this.parseSingleColorForGradient(prop['chart.colors.stroke']);prop['chart.background.color']=this.parseSingleColorForGradient(prop['chart.background.color']);};this.reset=function()
46
- {};this.parseSingleColorForGradient=function(color)
47
- {if(!color||typeof color!='string'){return color;}
48
- if(color.match(/^gradient\((.*)\)$/i)){if(color.match(/^gradient\(({.*})\)$/i)){return RGraph.parseJSONGradient({object:this,def:RegExp.$1});}
49
- var parts=RegExp.$1.split(':');var grad=co.createLinearGradient(prop['chart.margin.left'],0,ca.width-prop['chart.margin.right'],0);var diff=1/(parts.length-1);grad.addColorStop(0,RG.trim(parts[0]));for(var j=1,len=parts.length;j<len;++j){grad.addColorStop(j*diff,RG.trim(parts[j]));}
50
- return grad?grad:color;}
51
- return grad?grad:color;};this.on=function(type,func)
52
- {if(type.substr(0,2)!=='on'){type='on'+type;}
53
- if(typeof this[type]!=='function'){this[type]=func;}else{RG.addCustomEventListener(this,type,func);}
54
- return this;};this.exec=function(func)
55
- {func(this);return this;};this.firstDrawFunc=function()
56
- {};this.grow=function()
57
- {var obj=this,initial_value=this.currentValue,opt=arguments[0]||{},numFrames=opt.frames||30,frame=0,callback=arguments[1]||function(){},diff=this.value-Number(this.currentValue),increment=diff/numFrames
58
- function iterator()
59
- {frame++;if(frame<=numFrames){obj.value=initial_value+(increment*frame);RG.clear(ca);RG.redrawCanvas(ca);RG.Effects.updateCanvas(iterator);}else{callback();}}
60
- iterator();return this;};RG.register(this);if(parseConfObjectForOptions){RG.parseObjectStyleConfig(this,conf.options);}};
12
+ RGraph = window.RGraph || {isrgraph:true,isRGraph:true,rgraph:true};
13
+
14
+
15
+
16
+
17
+ //
18
+ // The progress bar constructor
19
+ //
20
+ RGraph.SemiCircularProgress = function (conf)
21
+ {
22
+ this.id = conf.id;
23
+ this.canvas = document.getElementById(this.id);
24
+ this.context = this.canvas.getContext('2d');
25
+ this.canvas.__object__ = this;
26
+ this.min = RGraph.stringsToNumbers(conf.min);
27
+ this.max = RGraph.stringsToNumbers(conf.max);
28
+ this.value = RGraph.stringsToNumbers(conf.value);
29
+ this.type = 'semicircularprogress';
30
+ this.coords = [];
31
+ this.isRGraph = true;
32
+ this.isrgraph = true;
33
+ this.rgraph = true;
34
+ this.currentValue = null;
35
+ this.uid = RGraph.createUID();
36
+ this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.createUID();
37
+ this.colorsParsed = false;
38
+ this.coordsText = [];
39
+ this.original_colors = [];
40
+ this.firstDraw = true; // After the first draw this will be false
41
+ this.stopAnimationRequested = false;// Used to control the animations
42
+
43
+
44
+ this.properties =
45
+ {
46
+ backgroundColor: 'rgba(0,0,0,0)',
47
+ backgroundGrid: false,
48
+ backgroundGridMargin: 20,
49
+ backgroundGridColor: '#ddd',
50
+ backgroundGridLinewidth: 1,
51
+ backgroundGridCircles: true,
52
+ backgroundGridRadials: true,
53
+ backgroundGridRadialsCount: 10,
54
+ backgroundBackdrop: true,
55
+
56
+ colors: ['#0c0', '#f66', '#66f', 'yellow', 'pink','#ccc','#cc0','#0cc','#c0c'],
57
+
58
+ linewidth: 2,
59
+
60
+ colorsStroke: '#666',
61
+
62
+ marginLeft: 35,
63
+ marginRight: 35,
64
+ marginTop: 35,
65
+ marginBottom: 35,
66
+
67
+ radius: null,
68
+ centerx: null,
69
+ centery: null,
70
+
71
+ width: null,
72
+
73
+ anglesStart: Math.PI,
74
+ anglesEnd: (2 * Math.PI),
75
+
76
+ scale: false,
77
+ scaleMin: 0,
78
+ scaleMax: null, // Defaults to the charts max value
79
+ scaleDecimals: 0,
80
+ scalePoint: '.',
81
+ scaleThousand: ',',
82
+ scaleFormatter: null,
83
+ scaleUnitsPre: '',
84
+ scaleUnitsPost: '',
85
+ scaleLabelsCount: 10,
86
+ scaleLabelsFont: null,
87
+ scaleLabelsSize: null,
88
+ scaleLabelsColor: null,
89
+ scaleLabelsBold: null,
90
+ scaleLabelsItalic: null,
91
+ scaleLabelsOffsetr: 0,
92
+ scaleLabelsOffsetx: 0,
93
+ scaleLabelsOffsety: 0,
94
+
95
+ shadow: false,
96
+ shadowColor: 'rgba(220,220,220,1)',
97
+ shadowBlur: 2,
98
+ shadowOffsetx: 2,
99
+ shadowOffsety: 2,
100
+
101
+ labelsCenter: true,
102
+ labelsCenterIndex: 0,
103
+ labelsCenterFade: false,
104
+ labelsCenterSize: 40,
105
+ labelsCenterColor: null,
106
+ labelsCenterBold: null,
107
+ labelsCenterItalic: null,
108
+ labelsCenterFont: null,
109
+ labelsCenterValign: 'bottom',
110
+ labelsCenterOffsetx: 0,
111
+ labelsCenterOffsety: 0,
112
+ labelsCenterThousand: ',',
113
+ labelsCenterPoint: '.',
114
+ labelsCenterDecimals: 0,
115
+ labelsCenterUnitsPost: '',
116
+ labelsCenterUnitsPre: '',
117
+ labelsCenterSpecific: null,
118
+
119
+ labelsMin: true,
120
+ labelsMinColor: null,
121
+ labelsMinFont: null,
122
+ labelsMinBold: null,
123
+ labelsMinSize: null,
124
+ labelsMinItalic: null,
125
+ labelsMinOffsetAngle: 0,
126
+ labelsMinOffsetx: 0,
127
+ labelsMinOffsety: 5,
128
+ labelsMinThousand: ',',
129
+ labelsMinPoint: '.',
130
+ labelsMinDecimals: 0,
131
+ labelsMinUnitsPost: '',
132
+ labelsMinUnitsPre: '',
133
+ labelsMinSpecific: null,
134
+
135
+ labelsMax: true,
136
+ labelsMaxColor: null,
137
+ labelsMaxFont: null,
138
+ labelsMaxBold: null,
139
+ labelsMaxSize: null,
140
+ labelsMaxItalic: null,
141
+ labelsMaxOffsetAngle: 0,
142
+ labelsMaxOffsetx: 0,
143
+ labelsMaxOffsety: 5,
144
+ labelsMaxThousand: ',',
145
+ labelsMaxPoint: '.',
146
+ labelsMaxDecimals: 0,
147
+ labelsMaxUnitsPost: '',
148
+ labelsMaxUnitsPre: '',
149
+ labelsMaxSpecific: null,
150
+
151
+ title: '',
152
+ titleBold: null,
153
+ titleItalic: null,
154
+ titleFont: null,
155
+ titleSize: null,
156
+ titleColor: null,
157
+ titleHalign: null,
158
+ titleValign: null,
159
+ titleOffsetx: 0,
160
+ titleOffsety: 0,
161
+ titleSubtitle: '',
162
+ titleSubtitleSize: null,
163
+ titleSubtitleColor: '#aaa',
164
+ titleSubtitleFont: null,
165
+ titleSubtitleBold: null,
166
+ titleSubtitleItalic: null,
167
+ titleSubtitleOffsetx: 0,
168
+ titleSubtitleOffsety: 0,
169
+
170
+ textSize: 12,
171
+ textColor: 'black',
172
+ textFont: 'Arial, Verdana, sans-serif',
173
+ textBold: false,
174
+ textItalic: false,
175
+ textAccessible: false,
176
+ textAccessibleOverflow: 'visible',
177
+ textAccessiblePointerevents:false,
178
+ text: null,
179
+
180
+ contextmenu: null,
181
+
182
+ tooltips: null,
183
+ tooltipsEffect: 'slide',
184
+ tooltipsOverride: null,
185
+ tooltipsCssClass: 'RGraph_tooltip',
186
+ tooltipsCss: null,
187
+ tooltipsEvent: 'onclick',
188
+ tooltipsHighlight: true,
189
+ tooltipsHotspotXonly: false,
190
+ tooltipsFormattedThousand: ',',
191
+ tooltipsFormattedPoint: '.',
192
+ tooltipsFormattedDecimals: 0,
193
+ tooltipsFormattedUnitsPre: '',
194
+ tooltipsFormattedUnitsPost: '',
195
+ tooltipsFormattedKeyColors: null,
196
+ tooltipsFormattedKeyColorsShape: 'square',
197
+ tooltipsFormattedKeyColorsCss: null,
198
+ tooltipsFormattedKeyLabels: [],
199
+ tooltipsFormattedListType: 'ul',
200
+ tooltipsFormattedListItems: null,
201
+ tooltipsFormattedTableHeaders: null,
202
+ tooltipsFormattedTableData: null,
203
+ tooltipsPointer: true,
204
+ tooltipsPointerCss: null,
205
+ tooltipsPointerOffsetx: 0,
206
+ tooltipsPointerOffsety: 0,
207
+ tooltipsPositionStatic: true,
208
+ tooltipsOffsetx: 0,
209
+ tooltipsOffsety: 0,
210
+ tooltipsHotspotIgnore: null,
211
+
212
+ highlightStyle: null,
213
+ highlightStroke: 'rgba(0,0,0,0)',
214
+ highlightFill: 'rgba(255,255,255,0.7)',
215
+
216
+ annotatable: false,
217
+ annotatebleColor: 'black',
218
+ annotatebleLinewidth: 1,
219
+
220
+ key: null,
221
+ keyBackground: 'white',
222
+ keyPosition: 'margin',
223
+ keyHalign: 'right',
224
+ keyShadow: false,
225
+ keyShadowColor: '#666',
226
+ keyShadowBlur: 3,
227
+ keyShadowOffsetx: 2,
228
+ keyShadowOffsety: 2,
229
+ keyPositionMarginBoxed: false,
230
+ keyPositionMarginHSpace: 0,
231
+ keyPositionX: null,
232
+ keyPositionY: null,
233
+ keyColorShape: 'square',
234
+ keyRounded: true,
235
+ keyLinewidth: 1,
236
+ keyColors: null,
237
+ keyInteractive: false,
238
+ keyInteractiveHighlightChartStroke: 'rgba(0,0,0,0)',
239
+ keyInteractiveHighlightChartFill: 'rgba(255,255,255,0.7)',
240
+ keyInteractiveHighlightLabel: 'rgba(255,0,0,0.2)',
241
+ keyLabelsColor: null,
242
+ keyLabelsFont: null,
243
+ keyLabelsSize: null,
244
+ keyLabelsBold: null,
245
+ keyLabelsItalic: null,
246
+ keyLabelsOffsetx: 0,
247
+ keyLabelsOffsety: 0,
248
+ keyFormattedDecimals: 0,
249
+ keyFormattedPoint: '.',
250
+ keyFormattedThousand: ',',
251
+ keyFormattedUnitsPre: '',
252
+ keyFormattedUnitsPost: '',
253
+ keyFormattedValueSpecific: null,
254
+ keyFormattedItemsCount: null,
255
+
256
+ adjustable: false,
257
+
258
+ variant: 'default',
259
+
260
+ clearto: 'rgba(0,0,0,0)'
261
+ }
262
+
263
+ // Check for support
264
+ if (!this.canvas) {
265
+ alert('[SEMICIRCULARPROGRESS] No canvas support');
266
+ return;
267
+ }
268
+
269
+
270
+
271
+
272
+ // Easy access to properties and the path function
273
+ var properties = this.properties;
274
+ this.path = RGraph.pathObjectFunction;
275
+
276
+
277
+
278
+ //
279
+ // "Decorate" the object with the generic effects if the effects library has been included
280
+ //
281
+ if (RGraph.Effects && typeof RGraph.Effects.decorate === 'function') {
282
+ RGraph.Effects.decorate(this);
283
+ }
284
+
285
+
286
+
287
+ // Add the responsive method. This method resides in the common file.
288
+ this.responsive = RGraph.responsive;
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+ //
298
+ // A generic setter
299
+ //
300
+ // @param string name The name of the property to set or it can also be an object containing
301
+ // object style configuration
302
+ //
303
+ this.set = function (name)
304
+ {
305
+ var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
306
+
307
+ // the number of arguments is only one and it's an
308
+ // object - parse it for configuration data and return.
309
+ if (arguments.length === 1 && typeof arguments[0] === 'object') {
310
+ for (i in arguments[0]) {
311
+ if (typeof i === 'string') {
312
+ this.set(i, arguments[0][i]);
313
+ }
314
+ }
315
+
316
+ return this;
317
+ }
318
+
319
+ properties[name] = value;
320
+
321
+ return this;
322
+ };
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+ //
332
+ // A generic getter
333
+ //
334
+ // @param string name The name of the property to get
335
+ //
336
+ this.get = function (name)
337
+ {
338
+ return properties[name];
339
+ };
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+ //
349
+ // Draws the progress bar
350
+ //
351
+ this.draw = function ()
352
+ {
353
+ //
354
+ // Fire the onbeforedraw event
355
+ //
356
+ RGraph.fireCustomEvent(this, 'onbeforedraw');
357
+
358
+
359
+
360
+ // Translate half a pixel for antialiasing purposes - but only if it hasn't been
361
+ // done already
362
+ //
363
+ // MUST be the first thing done!
364
+ //
365
+ if (!this.canvas.__rgraph_aa_translated__) {
366
+ this.context.translate(0.5,0.5);
367
+
368
+ this.canvas.__rgraph_aa_translated__ = true;
369
+ }
370
+
371
+
372
+ //
373
+ // Constrain the value to be within the min and max
374
+ //
375
+ if (this.value > this.max) this.value = this.max;
376
+ if (this.value < this.min) this.value = this.min;
377
+
378
+ if (RGraph.isArray(this.value) && RGraph.arraySum(this.value) > this.max) {
379
+ alert('[SEMI-CIRCULAR PROGRESS] Total value is over the maximum value');
380
+ }
381
+
382
+
383
+
384
+
385
+ //
386
+ // Parse the colors. This allows for simple gradient syntax
387
+ //
388
+ if (!this.colorsParsed) {
389
+
390
+ this.parseColors();
391
+
392
+
393
+ // Don't want to do this again
394
+ this.colorsParsed = true;
395
+ }
396
+
397
+
398
+ //
399
+ // Set the current value
400
+ //
401
+ this.currentValue = this.value;
402
+
403
+
404
+
405
+ //
406
+ // Make the margins easy ro access
407
+ //
408
+ this.marginLeft = properties.marginLeft;
409
+ this.marginRight = properties.marginRight;
410
+ this.marginTop = properties.marginTop;
411
+ this.marginBottom = properties.marginBottom;
412
+
413
+ // Figure out the width and height
414
+ this.radius = Math.min(
415
+ (this.canvas.width - properties.marginLeft - properties.marginRight) / 2,
416
+ this.canvas.height - properties.marginTop - properties.marginBottom
417
+ );
418
+ this.centerx = ((this.canvas.width - this.marginLeft - this.marginRight) / 2) + this.marginLeft;
419
+ this.centery = this.canvas.height - this.marginBottom;
420
+ this.width = this.radius / 3;
421
+
422
+ // User specified centerx/y/radius
423
+ if (typeof properties.radius === 'number') this.radius = properties.radius;
424
+ if (typeof properties.centerx === 'number') this.centerx = properties.centerx;
425
+ if (typeof properties.centery === 'number') this.centery = properties.centery;
426
+ if (typeof properties.width === 'number') this.width = properties.width;
427
+
428
+ // Allow specify the centerx/centery/radius as a string for adjustments
429
+ if (RGraph.isString(properties.centerx)) this.centerx += Number(properties.centerx);
430
+ if (RGraph.isString(properties.centery)) this.centery += Number(properties.centery);
431
+ if (RGraph.isString(properties.radius)) this.radius += Number(properties.radius);
432
+
433
+ this.coords = [];
434
+
435
+
436
+
437
+ //
438
+ // Stop this growing uncontrollably
439
+ //
440
+ this.coordsText = [];
441
+
442
+
443
+
444
+
445
+
446
+ //
447
+ // Draw the meter
448
+ //
449
+ this.drawBackgroundGrid();
450
+ this.drawMeter();
451
+ this.drawLabels();
452
+ this.drawScale();
453
+
454
+
455
+
456
+
457
+ //
458
+ // Setup the context menu if required
459
+ //
460
+ if (properties.contextmenu) {
461
+ RGraph.showContext(this);
462
+ }
463
+
464
+
465
+
466
+
467
+
468
+
469
+ // Draw the key if necessary
470
+ if (properties.key && properties.key.length) {
471
+ RGraph.drawKey(
472
+ this,
473
+ properties.key,
474
+ properties.colors
475
+ );
476
+ }
477
+
478
+
479
+
480
+
481
+
482
+
483
+ //
484
+ // Add custom text thats specified
485
+ //
486
+ RGraph.addCustomText(this);
487
+
488
+
489
+
490
+
491
+
492
+
493
+
494
+
495
+ //
496
+ // This installs the event listeners
497
+ //
498
+ RGraph.installEventListeners(this);
499
+
500
+
501
+ //
502
+ // Instead of using RGraph.common.adjusting.js, handle them here
503
+ //
504
+ this.allowAdjusting();
505
+
506
+
507
+ //
508
+ // Fire the onfirstdraw event
509
+ //
510
+ if (this.firstDraw) {
511
+ this.firstDraw = false;
512
+ RGraph.fireCustomEvent(this, 'onfirstdraw');
513
+ this.firstDrawFunc();
514
+ }
515
+
516
+
517
+
518
+
519
+ //
520
+ // Fire the RGraph draw event
521
+ //
522
+ RGraph.fireCustomEvent(this, 'ondraw');
523
+
524
+
525
+
526
+
527
+
528
+
529
+
530
+
531
+
532
+
533
+ //
534
+ // Install any inline responsive configuration. This
535
+ // should be last in the draw function - even after
536
+ // the draw events.
537
+ //
538
+ RGraph.installInlineResponsive(this);
539
+
540
+
541
+
542
+
543
+
544
+
545
+
546
+
547
+
548
+
549
+
550
+ return this;
551
+ };
552
+
553
+
554
+
555
+
556
+
557
+
558
+
559
+
560
+ //
561
+ // Draw the bar itself
562
+ //
563
+ this.drawMeter = function ()
564
+ {
565
+ // Reset the .coords array
566
+ this.coords = [];
567
+
568
+
569
+
570
+ //
571
+ // The start/end angles
572
+ //
573
+ var start = properties.anglesStart,
574
+ end = properties.anglesEnd;
575
+
576
+ //
577
+ // Calculate a scale
578
+ //
579
+
580
+ this.scale2 = RGraph.getScale({object: this, options: {
581
+ 'scale.max': this.max,
582
+ 'scale.strict': true,
583
+ 'scale.min': this.min,
584
+ 'scale.thousand': properties.scaleThousand,
585
+ 'scale.point': properties.scalePoint,
586
+ 'scale.decimals': properties.scaleDecimals,
587
+ 'scale.labels.count': 5,
588
+ 'scale.units.pre': properties.scaleUnitsPre,
589
+ 'scale.units.post': properties.scaleUnitsPost
590
+ }});
591
+
592
+ // Draw the backgroundColor
593
+ if (properties.backgroundColor !== 'rgba(0,0,0,0)') {
594
+ this.path(
595
+ 'fs % fr % % % %',
596
+ properties.backgroundColor,
597
+ 0,0,this.canvas.width, this.canvas.height
598
+ );
599
+ }
600
+
601
+
602
+
603
+
604
+
605
+
606
+
607
+
608
+ //
609
+ // Draw the background for the bar which is a similar
610
+ // color to the bar - just faded out a bit
611
+ //
612
+ if (properties.backgroundBackdrop) {
613
+ this.path(
614
+ 'lw % b ',
615
+ this.linewidth
616
+ );
617
+
618
+ // Draw the path for the bar
619
+ this.pathBar({
620
+ startValue: 0,
621
+ endValue: this.max
622
+ });
623
+
624
+ // Finish the paths and stroke/fill it
625
+ this.path(
626
+ 'c s % f % sx % sy % sc % sb % f % sx 0 sy 0 sb 0 sc rgba(0,0,0,0) lw 1',
627
+ properties.colorsStroke,
628
+ properties.colors[0],
629
+ properties.shadowOffsetx, properties.shadowOffsety, properties.shadow ? properties.shadowColor : 'rgba(0,0,0,0)', properties.shadowBlur,
630
+ 'rgba(255,255,255,0.85)'
631
+ );
632
+ }
633
+
634
+
635
+
636
+
637
+
638
+
639
+
640
+
641
+
642
+
643
+
644
+
645
+
646
+
647
+
648
+
649
+
650
+ //
651
+ // Draw a single value on the meter
652
+ //
653
+ if (RGraph.isNumber(this.value)) {
654
+
655
+ // Begein anew...
656
+ this.context.beginPath();
657
+
658
+ // Draw the path for the indicator bar (not
659
+ // stroking or filling it just yet)
660
+ this.pathBar({
661
+ startValue: 0,
662
+ endValue: this.value
663
+ });
664
+
665
+ // Close the path and fill the bar with the
666
+ // requested color
667
+ this.path('c f %', properties.colors[0]);
668
+
669
+
670
+ this.coords = [[
671
+ this.centerx,
672
+ this.centery,
673
+ this.radius,
674
+ this.getAngle(0),
675
+ this.getAngle(this.value),
676
+ this.width,
677
+ this.getAngle(this.value) - this.getAngle(0)
678
+ ]];
679
+
680
+ // Draw multiple values on the meter
681
+ } else if (RGraph.isArray(this.value)) {
682
+
683
+ for (var i=0,accValue=0; i<this.value.length; ++i) {
684
+
685
+ this.context.beginPath();
686
+ this.pathBar({
687
+ startValue: accValue,
688
+ endValue: accValue + this.value[i],
689
+ index: i
690
+ });
691
+ this.path('c f %', properties.colors[i]);
692
+
693
+ // Store the coordinates of this segment
694
+ this.coords.push([
695
+ this.centerx,
696
+ this.centery,
697
+ this.radius,
698
+ this.getAngle(accValue),
699
+ this.getAngle(accValue + this.value[i]),
700
+ this.width,
701
+ this.getAngle(accValue + this.value[i]) - this.getAngle(accValue)
702
+ ]);
703
+
704
+ accValue += this.value[i];
705
+ }
706
+ }
707
+ };
708
+
709
+
710
+
711
+
712
+
713
+
714
+
715
+
716
+ //
717
+ // A function to path the bar. This function only
718
+ // PATHs the bar - it does not stroke or fill the
719
+ // bar
720
+ //
721
+ // @param number start The start angle of the segment
722
+ // @param number end The end angle of the segment
723
+ //
724
+ this.pathBar = function (args)
725
+ {
726
+ // If the start value has been given instead of the
727
+ // angle - work out the angle
728
+ if (RGraph.isNumber(args.startValue)) {
729
+ args.startAngle = this.getAngle(args.startValue);
730
+ }
731
+
732
+ // If the end value has been given instead of the
733
+ // angle - work out the angle
734
+ if (RGraph.isNumber(args.endValue)) {
735
+ args.endAngle = this.getAngle(args.endValue);
736
+ }
737
+
738
+
739
+
740
+
741
+
742
+
743
+
744
+
745
+ // Get the end point for the middle of the END of the
746
+ // meter
747
+ var endpoint1 = RGraph.getRadiusEndPoint(
748
+ this.centerx,
749
+ this.centery,
750
+ args.endAngle,
751
+ this.radius - (this.width / 2)
752
+ );
753
+
754
+ // Get the end point for the middle of the START of the
755
+ // meter
756
+ var endpoint2 = RGraph.getRadiusEndPoint(
757
+ this.centerx,
758
+ this.centery,
759
+ args.startAngle,
760
+ this.radius - (this.width / 2)
761
+ );
762
+
763
+ // Draw the outside arc from the LHS to the RHS
764
+ this.path(
765
+ 'a % % % % % false',
766
+ this.centerx,
767
+ this.centery,
768
+ this.radius,
769
+ args.startAngle,
770
+ args.endAngle
771
+ );
772
+
773
+ // Draw the RHS rounded end if the variant is set
774
+ // to rounded
775
+ if (properties.variant === 'rounded') {
776
+ this.path(
777
+ 'a % % % % % false',
778
+ endpoint1[0],
779
+ endpoint1[1],
780
+ this.width / 2,
781
+ args.endAngle,
782
+ args.endAngle + RGraph.PI,
783
+ );
784
+ }
785
+
786
+ // Draw the inner arc from the RHS back to the LHS
787
+ this.path(
788
+ ' a % % % % % true',
789
+ this.centerx,
790
+ this.centery,
791
+ this.radius - this.width,
792
+ args.endAngle,
793
+ args.startAngle
794
+ );
795
+
796
+ // Draw the LHS rounded end if the variant is set
797
+ // to rounded
798
+ if (properties.variant === 'rounded') {
799
+ this.path(
800
+ 'a % % % % % %',
801
+ endpoint2[0],
802
+ endpoint2[1],
803
+ this.width / 2,
804
+ args.startAngle + RGraph.PI,
805
+ args.startAngle,
806
+ args.index > 0
807
+ );
808
+ }
809
+ };
810
+
811
+
812
+
813
+
814
+
815
+
816
+
817
+ //
818
+ // The function that draws the labels
819
+ //
820
+ this.drawLabels = function ()
821
+ {
822
+ // Draw the labelsMin label
823
+ if (properties.labelsMin) {
824
+ //
825
+ // Allow for a specific label
826
+ //
827
+ if (!RGraph.isNull(properties.labelsMinSpecific)) {
828
+ var text = properties.labelsMinSpecific;
829
+ } else {
830
+
831
+ var text = RGraph.numberFormat({
832
+ object: this,
833
+ number: this.scale2.min.toFixed(typeof properties.labelsMinDecimals === 'number'? properties.labelsMinDecimals : properties.scaleDecimals),
834
+ unitspre: properties.labelsMinUnitsPre,
835
+ unitspost: properties.labelsMinUnitsPost,
836
+ point: properties.labelsMinPoint,
837
+ thousand: properties.labelsMinThousand
838
+ });
839
+ }
840
+
841
+
842
+ // Determine the horizontal and vertical alignment for the text
843
+ if (properties.anglesStart === RGraph.PI) {
844
+ var halign = 'center';
845
+ var valign = 'top';
846
+
847
+ } else if (properties.anglesStart <= RGraph.PI) {
848
+ var halign = 'left';
849
+ var valign = 'center';
850
+
851
+ } else if (properties.anglesStart >= RGraph.PI) {
852
+ var halign = 'right';
853
+ var valign = 'center';
854
+ }
855
+
856
+ // Get the X/Y for the min label
857
+ // cx, cy, angle, radius
858
+ var xy = RGraph.getRadiusEndPoint(
859
+ this.centerx,
860
+ this.centery,
861
+ properties.anglesStart + properties.labelsMinOffsetAngle,
862
+ this.radius - (this.width / 2)
863
+ );
864
+
865
+ var textConf = RGraph.getTextConf({
866
+ object: this,
867
+ prefix: 'labelsMin'
868
+ });
869
+
870
+
871
+ // Draw the min label
872
+ RGraph.text({
873
+ object: this,
874
+ font: textConf.font,
875
+ size: textConf.size,
876
+ color: textConf.color,
877
+ bold: textConf.bold,
878
+ italic: textConf.italic,
879
+ x: xy[0] + properties.labelsMinOffsetx,
880
+ y: xy[1] + properties.labelsMinOffsety,
881
+ valign: valign,
882
+ halign: halign,
883
+ text: text
884
+ });
885
+ }
886
+
887
+
888
+
889
+
890
+
891
+
892
+
893
+
894
+
895
+ // Draw the labelsMax label
896
+ if (properties.labelsMax) {
897
+
898
+ // Determine the horizontal and vertical alignment for the text
899
+ if (properties.anglesEnd === RGraph.TWOPI) {
900
+ var halign = 'center';
901
+ var valign = 'top';
902
+
903
+ } else if (properties.anglesEnd >= RGraph.TWOPI) {
904
+ var halign = 'right';
905
+ var valign = 'center';
906
+
907
+ } else if (properties.anglesEnd <= RGraph.TWOPI) {
908
+ var halign = 'left';
909
+ var valign = 'center';
910
+ }
911
+
912
+
913
+
914
+ // Get the formatted max label number
915
+
916
+ //
917
+ // Allow for a specific label
918
+ //
919
+ if (!RGraph.isNull(properties.labelsMaxSpecific)) {
920
+ var text = properties.labelsMaxSpecific;
921
+ } else {
922
+ var text = RGraph.numberFormat({
923
+ object: this,
924
+ number: this.scale2.max.toFixed(typeof properties.labelsMaxDecimals === 'number'? properties.labelsMaxDecimals : properties.scaleDecimals),
925
+ unitspre: properties.labelsMaxUnitsPre,
926
+ unitspost: properties.labelsMaxUnitsPost,
927
+ point: properties.labelsMaxPoint,
928
+ thousand: properties.labelsMaxThousand
929
+ });
930
+ }
931
+
932
+ // Get the X/Y for the max label
933
+ // cx, cy, angle, radius
934
+ var xy = RGraph.getRadiusEndPoint(
935
+ this.centerx,
936
+ this.centery,
937
+ properties.anglesEnd + properties.labelsMaxOffsetAngle,
938
+ this.radius - (this.width / 2)
939
+ );
940
+
941
+ var textConf = RGraph.getTextConf({
942
+ object: this,
943
+ prefix: 'labelsMax'
944
+ });
945
+
946
+ // Draw the max label
947
+ RGraph.text({
948
+
949
+ object: this,
950
+
951
+ font: textConf.font,
952
+ size: textConf.size,
953
+ color: textConf.color,
954
+ bold: textConf.bold,
955
+ italic: textConf.italic,
956
+
957
+ x: xy[0] + properties.labelsMaxOffsetx,
958
+ y: xy[1] + properties.labelsMaxOffsety,
959
+ valign: valign,
960
+ halign: halign,
961
+ text: text
962
+ });
963
+ }
964
+
965
+
966
+
967
+
968
+
969
+
970
+
971
+
972
+
973
+
974
+
975
+
976
+
977
+
978
+ // Draw the big label in the center
979
+ if (properties.labelsCenter) {
980
+ var textConf = RGraph.getTextConf({
981
+ object: this,
982
+ prefix: 'labelsCenter'
983
+ });
984
+
985
+ //
986
+ // Allow for a specific label
987
+ //
988
+ if (!RGraph.isNull(properties.labelsCenterSpecific)) {
989
+ var text = properties.labelsCenterSpecific;
990
+ } else {
991
+
992
+ var text = RGraph.numberFormat({
993
+ object: this,
994
+ number:
995
+ RGraph.isNumber(this.value)
996
+ ? this.value.toFixed( RGraph.isNumber(properties.labelsCenterDecimals) ? properties.labelsCenterDecimals : properties.scaleDecimals )
997
+ : this.value[properties.labelsCenterIndex].toFixed(
998
+ RGraph.isNumber(properties.labelsCenterDecimals)
999
+ ? properties.labelsCenterDecimals
1000
+ : properties.scaleDecimals
1001
+ ),
1002
+ unitspre: properties.labelsCenterUnitsPre,
1003
+ unitspost: properties.labelsCenterUnitsPost,
1004
+ point: properties.labelsCenterPoint,
1005
+ thousand: properties.labelsCenterThousand
1006
+ })
1007
+ }
1008
+
1009
+ var ret = RGraph.text({
1010
+
1011
+ object: this,
1012
+
1013
+ font: textConf.font,
1014
+ size: textConf.size,
1015
+ color: textConf.color,
1016
+ bold: textConf.bold,
1017
+ italic: textConf.italic,
1018
+
1019
+ x: this.centerx + properties.labelsCenterOffsetx,
1020
+ y: this.centery + properties.labelsCenterOffsety,
1021
+
1022
+ valign: properties.labelsCenterValign,
1023
+ halign: 'center',
1024
+ text: text
1025
+ });
1026
+
1027
+ // Allows the center label to fade in
1028
+ if (properties.labelsCenterFade && ret.node) {
1029
+ ret.node.style.opacity = 0;
1030
+
1031
+ var delay = 25,
1032
+ incr = 0.05;
1033
+
1034
+ for (var i=0; i<20; ++i) {
1035
+ (function (index)
1036
+ {
1037
+ setTimeout(function ()
1038
+ {
1039
+ ret.node.style.opacity = incr * index;
1040
+ }, delay * (index + 1));
1041
+ })(i);
1042
+ }
1043
+ }
1044
+ }
1045
+
1046
+ // Draw the title
1047
+ RGraph.drawTitle(this);
1048
+ };
1049
+
1050
+
1051
+
1052
+
1053
+
1054
+
1055
+
1056
+
1057
+ //
1058
+ // Draws the background "grid"
1059
+ //
1060
+ this.drawBackgroundGrid = function ()
1061
+ {
1062
+ if (properties.backgroundGrid) {
1063
+
1064
+ var margin = properties.backgroundGridMargin;
1065
+ var outerRadius = this.radius + margin;
1066
+ var innerRadius = this.radius - this.width - margin;
1067
+
1068
+ // Draw the background grid "circles"
1069
+ if (properties.backgroundGridCircles) {
1070
+
1071
+ // Draw the outer arc
1072
+ this.path(
1073
+ 'b lw % a % % % % % false',
1074
+ properties.backgroundGridLinewidth,
1075
+ this.centerx, this.centery,
1076
+ outerRadius,
1077
+ properties.anglesStart, properties.anglesEnd
1078
+ );
1079
+
1080
+ // Draw the inner arc
1081
+ this.path(
1082
+ p = 'a % % % % % true c s %',
1083
+ this.centerx, this.centery,
1084
+ innerRadius, properties.anglesEnd, properties.anglesStart,
1085
+ properties.backgroundGridColor
1086
+ );
1087
+ }
1088
+
1089
+ //
1090
+ // Draw the background grid radials
1091
+ //
1092
+ if (properties.backgroundGridRadials) {
1093
+
1094
+ // Calculate the radius increment
1095
+ var increment = (properties.anglesEnd - properties.anglesStart) / properties.backgroundGridRadialsCount;
1096
+ var angle = properties.anglesStart;
1097
+
1098
+ for (var i=0; i<properties.backgroundGridRadialsCount; ++i) {
1099
+
1100
+ this.path(
1101
+ ' b a % % % % % false a % % % % % false s %',
1102
+ this.centerx,this.centery,innerRadius,angle,angle,
1103
+ this.centerx,this.centery,outerRadius,angle,angle,
1104
+ properties.backgroundGridColor
1105
+ );
1106
+
1107
+ angle += increment;
1108
+
1109
+ }
1110
+ }
1111
+ }
1112
+ };
1113
+
1114
+
1115
+
1116
+
1117
+
1118
+
1119
+
1120
+
1121
+ //
1122
+ // This function draws the scale
1123
+ //
1124
+ this.drawScale = function ()
1125
+ {
1126
+ if (properties.scale) {
1127
+
1128
+ // Get the max value
1129
+
1130
+ this.scale2 = RGraph.getScale({
1131
+ object: this,
1132
+ options: {
1133
+ 'scale.max': properties.scaleMax || this.max,
1134
+ 'scale.strict': true,
1135
+ 'scale.min': properties.scaleMin,
1136
+ 'scale.thousand': properties.scaleThousand,
1137
+ 'scale.point': properties.scalePoint,
1138
+ 'scale.decimals': properties.scaleDecimals,
1139
+ 'scale.labels.count':properties.scaleLabelsCount,
1140
+ 'scale.round': false,
1141
+ 'scale.units.pre': properties.scaleUnitsPre,
1142
+ 'scale.units.post': properties.scaleUnitsPost,
1143
+ 'scale.formatter': properties.scaleFormatter
1144
+ }
1145
+ });
1146
+
1147
+
1148
+
1149
+ //
1150
+ // Loop thru the number of labels
1151
+ //
1152
+ for (var i=0; i<this.scale2.labels.length; ++i) {
1153
+
1154
+ var textConf = RGraph.getTextConf({
1155
+ object: this,
1156
+ prefix: 'scaleLabels'
1157
+ });
1158
+
1159
+ var xy = RGraph.getRadiusEndPoint({
1160
+ cx: this.centerx,
1161
+ cy: this.centery,
1162
+ angle: properties.anglesStart + (((i+1) / this.scale2.labels.length) * (properties.anglesEnd - properties.anglesStart) ),
1163
+ radius: this.radius + (properties.backgroundGrid ? properties.backgroundGridMargin : 0) + textConf.size + properties.scaleLabelsOffsetr + 5
1164
+ });
1165
+
1166
+ // Draw the label
1167
+ RGraph.text({
1168
+ object: this,
1169
+ tag: 'scale',
1170
+ font: textConf.font,
1171
+ size: textConf.size,
1172
+ color: textConf.color,
1173
+ bold: textConf.bold,
1174
+ italic: textConf.italic,
1175
+ x: xy[0] + (properties.scaleLabelsOffsetx || 0),
1176
+ y: xy[1] + (properties.scaleLabelsOffsety || 0),
1177
+ valign: 'center',
1178
+ halign: 'center',
1179
+ text: this.scale2.labels[i]
1180
+ });
1181
+ }
1182
+
1183
+
1184
+
1185
+
1186
+
1187
+
1188
+
1189
+
1190
+
1191
+
1192
+ //
1193
+ // Draw the zero label
1194
+ //
1195
+ var xy = RGraph.getRadiusEndPoint({
1196
+ cx: this.centerx,
1197
+ cy: this.centery,
1198
+ angle: properties.anglesStart,
1199
+ radius: this.radius + (properties.backgroundGrid ? properties.backgroundGridMargin : 0) + textConf.size + properties.scaleLabelsOffsetr + 5
1200
+ });
1201
+
1202
+ RGraph.text({
1203
+ object: this,
1204
+ font: textConf.font,
1205
+ size: textConf.size,
1206
+ color: textConf.color,
1207
+ bold: textConf.bold,
1208
+ italic: textConf.italic,
1209
+ x: xy[0] + (properties.scaleLabelsOffsetx || 0),
1210
+ y: xy[1] + (properties.scaleLabelsOffsety || 0),
1211
+ valign: 'center',
1212
+ halign: 'center',
1213
+ text: typeof properties.scaleFormatter === 'function'
1214
+ ? (properties.scaleFormatter)({
1215
+ object: this,
1216
+ number: 0,
1217
+ unitspre: properties.scaleUnitsPre,
1218
+ unitspost: properties.scaleUnitsPost,
1219
+ point: properties.scalePoint,
1220
+ thousand: properties.scaleThousand,
1221
+ formatter: properties.scaleFormatter
1222
+ })
1223
+ : (properties.scaleUnitsPre || '') + properties.scaleMin.toFixed(properties.scaleDecimals).replace(/\./, properties.scalePoint) + (properties.scaleUnitsPost || '')
1224
+ });
1225
+ }
1226
+ };
1227
+
1228
+
1229
+
1230
+
1231
+
1232
+
1233
+
1234
+
1235
+ //
1236
+ // Returns the focused bar
1237
+ //
1238
+ // @param event e The event object
1239
+ //
1240
+ this.getShape = function (e)
1241
+ {
1242
+ var mouseXY = RGraph.getMouseXY(e),
1243
+ mouseX = mouseXY[0],
1244
+ mouseY = mouseXY[1]
1245
+
1246
+ // Loop through the coordinates checking for a match
1247
+ for (var i=0; i<this.coords.length; ++i) {
1248
+
1249
+ if (RGraph.tooltipsHotspotIgnore(this, i)) {
1250
+ continue;
1251
+ }
1252
+
1253
+ // Draw the meter here but don't stroke or fill it
1254
+ // so that it can be tested with isPointInPath()
1255
+ this.context.beginPath();
1256
+
1257
+ this.pathBar({
1258
+ startAngle: this.coords[i][3],
1259
+ endAngle: this.coords[i][4]
1260
+ });
1261
+
1262
+
1263
+
1264
+ if (this.context.isPointInPath(mouseX, mouseY)) {
1265
+
1266
+ if (RGraph.parseTooltipText) {
1267
+ var tooltip = RGraph.parseTooltipText(properties.tooltips, i);
1268
+ }
1269
+
1270
+ return {
1271
+ object: this,
1272
+ x: this.coords[i][0],
1273
+ y: this.coords[i][1],
1274
+ radiusOuter: this.coords[i][2],
1275
+ radiusInner: this.coords[i][2] - this.coords[i][5],
1276
+ width: this.coords[i][5],
1277
+ angleStart: this.coords[i][3],
1278
+ angleEnd: this.coords[i][4],
1279
+ index: i,
1280
+ dataset: 0,
1281
+ sequentialIndex: i,
1282
+ tooltip: typeof tooltip === 'string' ? tooltip : null
1283
+ };
1284
+ }
1285
+ }
1286
+ };
1287
+
1288
+
1289
+
1290
+
1291
+
1292
+
1293
+
1294
+
1295
+ //
1296
+ // This function returns the value that the mouse is positioned at, regardless of
1297
+ // the actual indicated value.
1298
+ //
1299
+ // @param object e The event object
1300
+ //
1301
+ this.getValue = function (e)
1302
+ {
1303
+ var mouseXY = RGraph.getMouseXY(e),
1304
+ mouseX = mouseXY[0],
1305
+ mouseY = mouseXY[1],
1306
+ angle = RGraph.getAngleByXY(
1307
+ this.centerx,
1308
+ this.centery,
1309
+ mouseX,
1310
+ mouseY
1311
+ );
1312
+
1313
+ if (
1314
+ angle &&
1315
+ mouseX >= this.centerx
1316
+ && mouseY > this.centery
1317
+ ) {
1318
+
1319
+ angle += RGraph.TWOPI;
1320
+ }
1321
+
1322
+ if (angle < properties.anglesStart && mouseX > this.centerx) { angle = properties.anglesEnd; }
1323
+ if (angle < properties.anglesStart) { angle = properties.anglesStart; }
1324
+
1325
+ var value = (((angle - properties.anglesStart) / (properties.anglesEnd - properties.anglesStart)) * (this.max - this.min)) + this.min;
1326
+
1327
+ value = Math.max(value, this.min);
1328
+ value = Math.min(value, this.max);
1329
+
1330
+ return value;
1331
+ };
1332
+
1333
+
1334
+
1335
+
1336
+
1337
+
1338
+
1339
+
1340
+ //
1341
+ // Each object type has its own Highlight() function which highlights the appropriate shape
1342
+ //
1343
+ // @param object shape The shape to highlight
1344
+ //
1345
+ this.highlight = function (shape)
1346
+ {
1347
+ if (typeof properties.highlightStyle === 'function') {
1348
+ (properties.highlightStyle)(shape);
1349
+ } else {
1350
+ this.context.beginPath();
1351
+
1352
+ this.pathBar({
1353
+ startAngle: shape.angleStart,
1354
+ endAngle: shape.angleEnd,
1355
+ index: shape.index
1356
+ });
1357
+
1358
+ this.path(
1359
+ 'c f % s % lw 1',
1360
+ properties.highlightFill,
1361
+ properties.highlightStroke
1362
+ );
1363
+ }
1364
+ };
1365
+
1366
+
1367
+
1368
+
1369
+
1370
+
1371
+
1372
+
1373
+ //
1374
+ // The getObjectByXY() worker method. Don't call this call:
1375
+ //
1376
+ // RGraph.ObjectRegistry.getObjectByXY(e)
1377
+ //
1378
+ // @param object e The event object
1379
+ //
1380
+ this.getObjectByXY = function (e)
1381
+ {
1382
+ var [mx, my] = RGraph.getMouseXY(e),
1383
+ rounded = properties.variant === 'rounded',
1384
+ cx = this.centerx
1385
+ cy = this.centery,
1386
+ start = properties.anglesStart,
1387
+ end = properties.anglesEnd,
1388
+ radius = this.radius;
1389
+
1390
+ // Draw a Path so that the coords can be tested
1391
+ // (but don't stroke/fill it
1392
+ this.path(
1393
+ 'b a % % % % % false',
1394
+ cx,
1395
+ cy,
1396
+ radius,
1397
+ start - (rounded ? 0.25 : 0),
1398
+ end + (rounded ? 0.25 : 0)
1399
+ );
1400
+
1401
+ this.path(
1402
+ 'a % % % % % true',
1403
+ cx,
1404
+ cy,
1405
+ radius - this.width,
1406
+ end + (rounded ? 0.25 : 0),
1407
+ start - (rounded ? 0.25 : 0)
1408
+ );
1409
+
1410
+ return this.context.isPointInPath(mx, my) ? this : null;
1411
+ };
1412
+
1413
+
1414
+
1415
+
1416
+
1417
+
1418
+
1419
+
1420
+ //
1421
+ // This function allows the progress to be adjustable.
1422
+ // UPDATE: Not any more
1423
+ //
1424
+ this.allowAdjusting = function () {};
1425
+
1426
+
1427
+
1428
+
1429
+
1430
+
1431
+
1432
+
1433
+ //
1434
+ // This method handles the adjusting calculation for when the mouse is moved
1435
+ //
1436
+ // @param object e The event object
1437
+ //
1438
+ this.adjusting_mousemove = function (e)
1439
+ {
1440
+ //
1441
+ // Handle adjusting for the HProgress
1442
+ //
1443
+ if (properties.adjustable && RGraph.Registry.get('adjusting') && RGraph.Registry.get('adjusting').uid == this.uid) {
1444
+
1445
+ var value = this.getValue(e);
1446
+
1447
+ if (typeof value === 'number') {
1448
+
1449
+ // Fire the onadjust event
1450
+ RGraph.fireCustomEvent(this, 'onadjust');
1451
+
1452
+ this.value = Number(value.toFixed(properties.scaleDecimals));
1453
+ RGraph.redrawCanvas(this.canvas);
1454
+ }
1455
+ }
1456
+ };
1457
+
1458
+
1459
+
1460
+
1461
+
1462
+
1463
+
1464
+
1465
+ //
1466
+ // This function returns the appropriate angle (in radians) for the given
1467
+ // Y value
1468
+ //
1469
+ // @param int value The Y value you want the angle for
1470
+ // @returm int The angle
1471
+ //
1472
+ this.getAngle = function (value)
1473
+ {
1474
+ if (value > this.max || value < this.min) {
1475
+ return null;
1476
+ }
1477
+
1478
+ var angle = (value / this.max) * (properties.anglesEnd - properties.anglesStart)
1479
+ angle += properties.anglesStart;
1480
+
1481
+ return angle;
1482
+ };
1483
+
1484
+
1485
+
1486
+
1487
+
1488
+
1489
+
1490
+
1491
+ //
1492
+ // This returns true/false as to whether the cursor is
1493
+ // over the chart area. The cursor does not necessarily
1494
+ // have to be over the bar itself - just the bar or the
1495
+ // background to the bar.
1496
+ //
1497
+ this.overChartArea = function (e)
1498
+ {
1499
+ var mouseXY = RGraph.getMouseXY(e),
1500
+ mouseX = mouseXY[0],
1501
+ mouseY = mouseXY[1]
1502
+
1503
+ // Draw the background to the Progress but don't stroke or fill it
1504
+ // so that it can be tested with isPointInPath()
1505
+ this.context.beginPath();
1506
+
1507
+ this.pathBar({
1508
+ startValue: this.min,
1509
+ endValue: this.max
1510
+ });
1511
+
1512
+
1513
+ return this.context.isPointInPath(mouseX, mouseY);
1514
+ };
1515
+
1516
+
1517
+
1518
+
1519
+
1520
+
1521
+
1522
+
1523
+ //
1524
+ //
1525
+ //
1526
+ this.parseColors = function ()
1527
+ {
1528
+ // Save the original colors so that they can be restored when the canvas is reset
1529
+ if (this.original_colors.length === 0) {
1530
+ this.original_colors.backgroundColor = RGraph.arrayClone(properties.backgroundColor);
1531
+ this.original_colors.colors = RGraph.arrayClone(properties.colors);
1532
+ this.original_colors.keyColors = RGraph.arrayClone(properties.keyColors);
1533
+ }
1534
+
1535
+ properties.colors[0] = this.parseSingleColorForGradient(properties.colors[0]);
1536
+ properties.colors[1] = this.parseSingleColorForGradient(properties.colors[1]);
1537
+
1538
+
1539
+
1540
+ // keyColors
1541
+ var colors = properties.keyColors;
1542
+ if (colors) {
1543
+ for (var i=0; i<colors.length; ++i) {
1544
+ colors[i] = this.parseSingleColorForGradient(colors[i]);
1545
+ }
1546
+ }
1547
+
1548
+ properties.colorsStroke = this.parseSingleColorForGradient(properties.colorsStroke);
1549
+ properties.backgroundColor = this.parseSingleColorForGradient(properties.backgroundColor);
1550
+ };
1551
+
1552
+
1553
+
1554
+
1555
+
1556
+
1557
+
1558
+
1559
+ //
1560
+ // Use this function to reset the object to the post-constructor state. Eg reset colors if
1561
+ // need be etc
1562
+ //
1563
+ this.reset = function ()
1564
+ {
1565
+ };
1566
+
1567
+
1568
+
1569
+
1570
+
1571
+
1572
+
1573
+
1574
+ //
1575
+ // This parses a single color value
1576
+ //
1577
+ this.parseSingleColorForGradient = function (color)
1578
+ {
1579
+ if (!color || typeof color != 'string') {
1580
+ return color;
1581
+ }
1582
+
1583
+ if (color.match(/^gradient\((.*)\)$/i)) {
1584
+
1585
+ // Allow for JSON gradients
1586
+ if (color.match(/^gradient\(({.*})\)$/i)) {
1587
+ return RGraph.parseJSONGradient({object: this, def: RegExp.$1});
1588
+ }
1589
+
1590
+ var parts = RegExp.$1.split(':');
1591
+
1592
+ // Create the gradient
1593
+ var grad = this.context.createLinearGradient(properties.marginLeft,0,this.canvas.width - properties.marginRight,0);
1594
+
1595
+ var diff = 1 / (parts.length - 1);
1596
+
1597
+ grad.addColorStop(0, RGraph.trim(parts[0]));
1598
+
1599
+ for (var j=1,len=parts.length; j<len; ++j) {
1600
+ grad.addColorStop(j * diff, RGraph.trim(parts[j]));
1601
+ }
1602
+
1603
+ return grad ? grad : color;
1604
+ }
1605
+
1606
+ return grad ? grad : color;
1607
+ };
1608
+
1609
+
1610
+
1611
+
1612
+
1613
+
1614
+
1615
+
1616
+ //
1617
+ // This function handles highlighting an entire data-series for the interactive
1618
+ // key
1619
+ //
1620
+ // @param int index The index of the data series to be highlighted
1621
+ //
1622
+ this.interactiveKeyHighlight = function (index)
1623
+ {
1624
+ if (!this.coords[index]) {
1625
+ return;
1626
+ }
1627
+
1628
+ var coords = this.coords[index];
1629
+
1630
+ // Draw some highlight over the top of the segment
1631
+ this.context.beginPath();
1632
+
1633
+ this.pathBar({
1634
+ startAngle: coords[3],
1635
+ endAngle: coords[4],
1636
+ index: index
1637
+ });
1638
+
1639
+ this.path(
1640
+ 's % f %',
1641
+ properties.keyInteractiveHighlightChartStroke,
1642
+ properties.keyInteractiveHighlightChartFill
1643
+ );
1644
+ };
1645
+
1646
+
1647
+
1648
+
1649
+
1650
+
1651
+
1652
+
1653
+ //
1654
+ // Using a function to add events makes it easier to facilitate method chaining
1655
+ //
1656
+ // @param string type The type of even to add
1657
+ // @param function func
1658
+ //
1659
+ this.on = function (type, func)
1660
+ {
1661
+ if (type.substr(0,2) !== 'on') {
1662
+ type = 'on' + type;
1663
+ }
1664
+
1665
+ if (typeof this[type] !== 'function') {
1666
+ this[type] = func;
1667
+ } else {
1668
+ RGraph.addCustomEventListener(this, type, func);
1669
+ }
1670
+
1671
+ return this;
1672
+ };
1673
+
1674
+
1675
+
1676
+
1677
+
1678
+
1679
+
1680
+
1681
+ //
1682
+ // Used in chaining. Runs a function there and then - not waiting for
1683
+ // the events to fire (eg the onbeforedraw event)
1684
+ //
1685
+ // @param function func The function to execute
1686
+ //
1687
+ this.exec = function (func)
1688
+ {
1689
+ func(this);
1690
+
1691
+ return this;
1692
+ };
1693
+
1694
+
1695
+
1696
+
1697
+
1698
+
1699
+
1700
+
1701
+ //
1702
+ // This function runs once only
1703
+ // (put at the end of the file (before any effects))
1704
+ //
1705
+ this.firstDrawFunc = function ()
1706
+ {
1707
+ };
1708
+
1709
+
1710
+
1711
+
1712
+
1713
+
1714
+
1715
+ //
1716
+ // HProgress Grow effect (which is also the VPogress Grow effect)
1717
+ //
1718
+ // @param object obj The chart object
1719
+ //
1720
+ this.grow = function ()
1721
+ {
1722
+ // Cancel any stop request if one is pending
1723
+ this.cancelStopAnimation();
1724
+
1725
+ var obj = this,
1726
+ opt = arguments[0] || {},
1727
+ numFrames = opt.frames || 30,
1728
+ frame = 0,
1729
+ callback = arguments[1] || function () {};
1730
+
1731
+ // Do this if showing a single number
1732
+ if (RGraph.isNumber(this.value)) {
1733
+
1734
+ var initial_value = this.currentValue,
1735
+ diff = this.value - Number(this.currentValue),
1736
+ increment = diff / numFrames;
1737
+
1738
+ // Do this if showing multiple numbers
1739
+ } else {
1740
+
1741
+ var initial_value = [],
1742
+ diff = [],
1743
+ increment = [];
1744
+
1745
+ for (var i=0; i<this.value.length; ++i) {
1746
+ initial_value[i] = RGraph.isNull(this.currentValue) ? 0 : this.currentValue[i];
1747
+ diff[i] = this.value[i] - Number(RGraph.isNull(this.currentValue) ? 0 : this.currentValue[i]);
1748
+ increment[i] = diff[i] / numFrames;
1749
+ }
1750
+ }
1751
+
1752
+
1753
+
1754
+ function iterator ()
1755
+ {
1756
+ if (obj.stopAnimationRequested) {
1757
+
1758
+ // Reset the flag
1759
+ obj.stopAnimationRequested = false;
1760
+
1761
+ return;
1762
+ }
1763
+
1764
+ frame++;
1765
+
1766
+ if (frame <= numFrames) {
1767
+
1768
+ if (RGraph.isNumber(obj.value)) {
1769
+ obj.value = initial_value + (increment * frame);
1770
+ } else {
1771
+ for (var i=0; i<obj.value.length; ++i) {
1772
+ obj.value[i] = initial_value[i] + (increment[i] * frame);
1773
+ }
1774
+ }
1775
+
1776
+ RGraph.clear(obj.canvas);
1777
+ RGraph.redrawCanvas(obj.canvas);
1778
+
1779
+ RGraph.Effects.updateCanvas(iterator);
1780
+ } else {
1781
+ callback();
1782
+ }
1783
+ }
1784
+
1785
+ iterator();
1786
+
1787
+ return this;
1788
+ };
1789
+
1790
+
1791
+
1792
+
1793
+
1794
+
1795
+
1796
+
1797
+ //
1798
+ // Couple of functions that allow you to control the
1799
+ // animation effect
1800
+ //
1801
+ this.stopAnimation = function ()
1802
+ {
1803
+ this.stopAnimationRequested = true;
1804
+ };
1805
+
1806
+ this.cancelStopAnimation = function ()
1807
+ {
1808
+ this.stopAnimationRequested = false;
1809
+ };
1810
+
1811
+
1812
+
1813
+
1814
+
1815
+
1816
+
1817
+
1818
+ //
1819
+ // A worker function that handles Bar chart specific tooltip substitutions
1820
+ //
1821
+ this.tooltipSubstitutions = function (opt)
1822
+ {
1823
+ return {
1824
+ index: opt.index,
1825
+ dataset: 0,
1826
+ sequentialIndex: opt.index,
1827
+ value: this.value,
1828
+ values: [this.value]
1829
+ };
1830
+ };
1831
+
1832
+
1833
+
1834
+
1835
+
1836
+
1837
+
1838
+
1839
+ //
1840
+ // A worker function that returns the correct color/label/value
1841
+ //
1842
+ // @param object specific The indexes that are applicable
1843
+ // @param number index The appropriate index
1844
+ //
1845
+ this.tooltipsFormattedCustom = function (specific, index)
1846
+ {
1847
+ var color = (properties.tooltipsFormattedKeyColors && properties.tooltipsFormattedKeyColors[specific.index]) ? properties.tooltipsFormattedKeyColors[specific.index] : properties.colors[specific.index];
1848
+ var label = (properties.tooltipsFormattedKeyLabels && properties.tooltipsFormattedKeyLabels[specific.index]) ? properties.tooltipsFormattedKeyLabels[specific.index] : '';
1849
+ var value = specific.values[0][specific.index]
1850
+
1851
+
1852
+ return {
1853
+ label: label,
1854
+ color: color,
1855
+ value: value
1856
+ };
1857
+ };
1858
+
1859
+
1860
+
1861
+
1862
+
1863
+
1864
+
1865
+
1866
+ //
1867
+ // This allows for static tooltip positioning
1868
+ //
1869
+ this.positionTooltipStatic = function (args)
1870
+ {
1871
+ var obj = args.object,
1872
+ e = args.event,
1873
+ tooltip = args.tooltip,
1874
+ index = args.index,
1875
+ canvasXY = RGraph.getCanvasXY(obj.canvas)
1876
+ shape = this.getShape(e),
1877
+ angle = ((shape.angleEnd - shape.angleStart) / 2) + shape.angleStart;
1878
+
1879
+ var endpoint = RGraph.getRadiusEndPoint(
1880
+ shape.x,
1881
+ shape.y,
1882
+ angle,
1883
+ ((shape.radiusOuter - shape.radiusInner) / 2) + shape.radiusInner
1884
+ );
1885
+
1886
+
1887
+ // Position the tooltip in the X direction
1888
+ args.tooltip.style.left = (
1889
+ canvasXY[0] // The X coordinate of the canvas
1890
+ + endpoint[0] // The X coordinate of the bar on the chart
1891
+ - (tooltip.offsetWidth / 2) // Subtract half of the tooltip width
1892
+ + obj.properties.tooltipsOffsetx // Add any user defined offset
1893
+ ) + 'px';
1894
+
1895
+ args.tooltip.style.top = (
1896
+ canvasXY[1] // The Y coordinate of the canvas
1897
+ + endpoint[1] // The Y coordinate of the bar on the chart
1898
+ - tooltip.offsetHeight // The height of the tooltip
1899
+ + obj.properties.tooltipsOffsety // Add any user defined offset
1900
+ - 10 // Account for the pointer
1901
+ ) + 'px';
1902
+ };
1903
+
1904
+
1905
+
1906
+
1907
+
1908
+
1909
+
1910
+
1911
+ //
1912
+ // This returns the relevant value for the formatted key
1913
+ // macro %{value}. THIS VALUE SHOULD NOT BE FORMATTED.
1914
+ //
1915
+ // @param number index The index in the dataset to get
1916
+ // the value for
1917
+ //
1918
+ this.getKeyValue = function (index)
1919
+ {
1920
+ return RGraph.isArray(this.properties.keyFormattedValueSpecific) && RGraph.isNumber(this.properties.keyFormattedValueSpecific[index])
1921
+ ? this.properties.keyFormattedValueSpecific[index]
1922
+ : (RGraph.isArray(this.value) ? this.value[index] : this.value);
1923
+ };
1924
+
1925
+
1926
+
1927
+
1928
+
1929
+
1930
+
1931
+
1932
+ //
1933
+ // Returns how many data-points there should be when a string
1934
+ // based key property has been specified. For example, this:
1935
+ //
1936
+ // key: '%{property:_labels[%{index}]} %{value_formatted}'
1937
+ //
1938
+ // ...depending on how many bits of data ther is might get
1939
+ // turned into this:
1940
+ //
1941
+ // key: [
1942
+ // '%{property:_labels[%{index}]} %{value_formatted}',
1943
+ // '%{property:_labels[%{index}]} %{value_formatted}',
1944
+ // '%{property:_labels[%{index}]} %{value_formatted}',
1945
+ // '%{property:_labels[%{index}]} %{value_formatted}',
1946
+ // '%{property:_labels[%{index}]} %{value_formatted}',
1947
+ // ]
1948
+ //
1949
+ // ... ie in that case there would be 4 data-points so the
1950
+ // template is repeated 4 times.
1951
+ //
1952
+ this.getKeyNumDatapoints = function ()
1953
+ {
1954
+ return this.value.length;
1955
+ };
1956
+
1957
+
1958
+
1959
+
1960
+
1961
+
1962
+
1963
+
1964
+ //
1965
+ // The chart is now always registered
1966
+ //
1967
+ RGraph.register(this);
1968
+
1969
+
1970
+
1971
+
1972
+
1973
+
1974
+
1975
+
1976
+ //
1977
+ // This is the 'end' of the constructor so if the first argument
1978
+ // contains configuration data - handle that.
1979
+ //
1980
+ RGraph.parseObjectStyleConfig(this, conf.options);
1981
+ };