RGraph=window.RGraph||{isRGraph:true};RGraph.Gauge=function(conf) {if(typeof conf==='object'&&typeof conf.min==='number'&&typeof conf.max==='number'&&typeof conf.id==='string'){var id=conf.id var canvas=document.getElementById(id);var min=conf.min;var max=conf.max;var value=conf.value;var parseConfObjectForOptions=true;}else{var id=conf;var canvas=document.getElementById(id);var min=arguments[1];var max=arguments[2];var value=arguments[3];} this.id=id;this.canvas=canvas;this.context=this.canvas.getContext?this.canvas.getContext("2d",{alpha:(typeof id==='object'&&id.alpha===false)?false:true}):null;this.canvas.__object__=this;this.type='gauge';this.min=min;this.max=max;this.value=RGraph.stringsToNumbers(value);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;if(typeof(this.value)=='object'){for(var i=0;ithis.max)this.value[i]=max;if(this.value[i]this.max)this.value=max;if(this.valuethis.startAngle&&athis.centerx?'right':'left';var vAlign=y>this.centery?'bottom':'top';if(a==RG.HALFPI){vAlign='center';}else if(a==RG.PI){hAlign='center';}else if(a==(RG.HALFPI+RG.PI)){vAlign='center';} if(prop['chart.labels.centered']){hAlign='center';vAlign='center';} RG.Text2(this,{'font':font,'size':size,'x':x,'y':y,'text':prop['chart.labels.specific']?prop['chart.labels.specific'][i]:RG.number_format(this,(((this.max-this.min)*(i/num))+this.min).toFixed(prop['chart.scale.decimals']),prop['chart.units.pre'],prop['chart.units.post']),'halign':hAlign,'valign':vAlign,'tag':prop['chart.labels.specific']?'labels.specific':'labels'});} co.fill();if(prop['chart.value.text']){var x=this.centerx;var y=this.centery+(prop['chart.value.text.y.pos']*this.radius);var units_pre=typeof(prop['chart.value.text.units.pre'])=='string'?prop['chart.value.text.units.pre']:prop['chart.units.pre'];var units_post=typeof(prop['chart.value.text.units.post'])=='string'?prop['chart.value.text.units.post']:prop['chart.units.post'];var color=prop['chart.value.text.color'];var bounding=prop['chart.value.text.bounding'];var boundingFill=prop['chart.value.text.bounding.fill'];var boundingStroke=prop['chart.value.text.bounding.stroke'];co.fillStyle=color;RG.text2(this,{'font':font,'size':size+2,'x':x,'y':y,'text':RG.number_format(this,this.value.toFixed(prop['chart.scale.decimals']),units_pre,units_post),'halign':'center','valign':'center','bounding':bounding,'bounding.fill':boundingFill,'bounding.stroke':boundingStroke,'tag':'value.text'});}};this.drawTopTitle=this.DrawTopTitle=function() {var x=this.centerx;var y=this.centery-25;if(typeof(prop['chart.title.top.pos'])=='number'){y=this.centery-(this.radius*prop['chart.title.top.pos']);} if(prop['chart.title.top']){co.fillStyle=prop['chart.title.top.color'];RG.Text2(this,{'font':prop['chart.title.top.font'],'size':prop['chart.title.top.size'],'x':x,'y':y,'text':String(prop['chart.title.top']),'halign':'center','valign':'bottom','bold':prop['chart.title.top.bold'],'tag':'title.top'});}};this.drawBottomTitle=this.DrawBottomTitle=function() {var x=this.centerx;var y=this.centery+this.centerpinRadius+10;if(typeof(prop['chart.title.bottom.pos'])=='number'){y=this.centery+(this.radius*prop['chart.title.bottom.pos']);} if(prop['chart.title.bottom']){co.fillStyle=prop['chart.title.bottom.color'];RG.Text2(this,{'font':prop['chart.title.bottom.font'],'size':prop['chart.title.bottom.size'],'x':x,'y':y,'text':String(prop['chart.title.bottom']),'halign':'center','valign':'top','bold':prop['chart.title.bottom.bold'],'tag':'title.bottom'});}};this.drawNeedle=this.DrawNeedle=function(value,color,index) {var type=prop['chart.needle.type'];co.lineWidth=0.5;co.strokeStyle='gray';co.fillStyle=color;var angle=(this.endAngle-this.startAngle)*((value-this.min)/(this.max-this.min));angle+=this.startAngle;if(typeof(prop['chart.needle.size'])=='object'&&prop['chart.needle.size']&&typeof(prop['chart.needle.size'][index])=='number'){var size=prop['chart.needle.size'][index];}else if(typeof(prop['chart.needle.size'])=='number'){var size=prop['chart.needle.size'];}else{var size=this.radius-25-prop['chart.border.width'];} if(type=='line'){co.beginPath();co.lineWidth=7;co.strokeStyle=color;co.arc(this.centerx,this.centery,size,angle,angle+0.0001,false);co.lineTo(this.centerx,this.centery);if(prop['chart.needle.tail']){co.arc(this.centerx,this.centery,this.radius*0.2,angle+RG.PI,angle+0.00001+RG.PI,false);} co.lineTo(this.centerx,this.centery);co.stroke();}else{co.beginPath();co.arc(this.centerx,this.centery,size,angle,angle+0.00001,false);co.arc(this.centerx,this.centery,this.centerpinRadius*0.5,angle+RG.HALFPI,angle+0.00001+RG.HALFPI,false);if(prop['chart.needle.tail']){co.arc(this.centerx,this.centery,this.radius*0.2,angle+RG.PI,angle+0.00001+RG.PI,false);} co.arc(this.centerx,this.centery,this.centerpinRadius*0.5,angle-RG.HALFPI,angle-0.00001-RG.HALFPI,false);co.stroke();co.fill();this.angle=angle;}};this.drawColorBands=this.DrawColorBands=function() {if(RG.is_array(prop['chart.colors.ranges'])){var ranges=prop['chart.colors.ranges'];for(var i=0;i=0&&angle<=RG.HALFPI){angle+=RG.TWOPI;} var value=((angle-this.startAngle)/(this.endAngle-this.startAngle))*(this.max-this.min);value=value+this.min;if(valuethis.max){value=this.max} return value;};this.getObjectByXY=function(e) {var mouseXY=RGraph.getMouseXY(e);if(mouseXY[0]>(this.centerx-this.radius)&&mouseXY[0]<(this.centerx+this.radius)&&mouseXY[1]>(this.centery-this.radius)&&mouseXY[1]<(this.centery+this.radius)&&RG.getHypLength(this.centerx,this.centery,mouseXY[0],mouseXY[1])<=this.radius){return this;}};this.drawGradient=this.DrawGradient=function() {if(prop['chart.border.gradient']){co.beginPath();var grad=co.createRadialGradient(this.centerx,this.centery,this.radius,this.centerx,this.centery,this.radius-15);grad.addColorStop(0,'gray');grad.addColorStop(1,'white');co.fillStyle=grad;co.arc(this.centerx,this.centery,this.radius,0,RG.TWOPI,false) co.arc(this.centerx,this.centery,this.radius-15,RG.TWOPI,0,true) co.fill();}};this.adjusting_mousemove=this.Adjusting_mousemove=function(e) {if(prop['chart.adjustable']&&RG.Registry.Get('chart.adjusting')&&RG.Registry.Get('chart.adjusting').uid==this.uid){this.value=this.getValue(e);RG.redrawCanvas(this.canvas);RG.fireCustomEvent(this,'onadjust');}};this.getAngle=function(value) {if(value>this.max||valueobj.max)obj.value=obj.max;if(obj.valueobj.max)obj.value[i]=obj.max;if(obj.value[i]