/*
 TeeChart(tm) for JavaScript(tm)
 @fileOverview TeeChart for JavaScript(tm)
 v1.4 - December 2012
 Copyright(c) 2012 by Steema Software SL. All Rights Reserved.
 http://www.steema.com

 Licensed with commercial and non-commercial attributes,
 specifically: http://www.steema.com/licensing/html5

 JavaScript is a trademark of Oracle Corporation.
*/
var Tee=Tee||{};
(function(){Tee.CircularGauge=function(q,n){function I(b,d){b.hover.value!=d&&(b.hover.value=d,b.hover.valid=null!==d,requestAnimFrame(function(){b.chart.draw()}))}Tee.Series.call(this,q,n);this.useAxes=!1;this.min=0;this.max=100;this.value=this.step=0;this.angle=280;this.rotation=0;this.rotateText=!1;this.shape="circle";this.drag={enabled:!0};var l=this.bevel=new Tee.Format(this.chart);l.gradient.visible=!0;l.gradient.colors=["white","blue","white"];l.shadow.visible=!1;l.visible=!0;l.stroke.fill=
"";var k=this.center=new Tee.Format(this.chart);k.stroke.fill="";k.gradient.visible=!0;k.size=10;k.visible=!0;k.shadow.visible=!0;k.gradient.offset={x:2,y:-2};k.location={x:0,y:0};k.top=new Tee.Format(this.chart);k.top.size=40;k.top.visible=!0;k.top.stroke.fill="";k.top.gradient.colors=["silver","white"];k.top.gradient.visible=!0;k.top.gradient.direction="topbottom";var t=this.ticks=new Tee.Format(this.chart);t.length=6;t.stroke.fill="silver";t.visible=!0;t.outside=!0;t.triangle=!1;t.fill="white";
var D=this.ticksBack=new Tee.Format(this.chart);D.stroke.fill="";D.fill="black";D.gradient.visible=!0;D.gradient.colors=["red","yellow","green"];D.gradient.direction="rightleft";D.visible=!0;D.radius=0;var f=this.minor=new Tee.Format(this.chart);f.stroke.fill="silver";f.visible=!0;f.count=4;f.shape="";var E=this.minorBack=new Tee.Format(this.chart);E.stroke.fill="";E.visible=!0;E.fill="white";E.gradient.visible=!0;E.gradient.direction="bottomtop";E.gradient.colors=["white","gray","white","silver"];
E.radius=0;this.hands=[];this.addHand=function(){var b=new Tee.Format(this.chart);b.size=6;b.length=60;b.back=20;b.gradient.visible=!0;b.gradient.colors[0]="orange";b.shadow.visible=!0;b.shadow.blur=12;b.shadow.color="black";b.stroke.fill="";b.pointer=!0;b.shape="needle";b.visible=!0;this.hands.push(b);return b};var T=this.hand=this.addHand(),J=this.back=new Tee.Format(this.chart);J.fill="black";J.visible=!0;J.gradient.visible=!0;J.gradient.colors=["black","gray"];J.stroke.fill="";var F=this.pointer=
new Tee.Format(this.chart);F.size=3;F.fill="black";F.stroke.fill="";F.visible=!0;var u=this.marks,l=u.format;u.location={x:0,y:10};u.visible=!0;l.fill="black";l.font.fill="white";l.gradient.visible=!0;l.gradient.colors=["gray","black"];l.shadow.visible=!0;l.shadow.blur=8;l.shadow.color="black";var d=this.format;d.visible=!0;d.gradient.visible=!0;d.gradient.colors=["white","black","white"];d.shadow.visible=!0;d.font.style="12px Verdana";d.font.fill="white";d.font.visible=!0;d.size=14;d.round={x:6,
y:6};d.padding=0.5;this.units=new Tee.Annotation(this.chart);this.units.transparent=!0;this.units.format.font.fill="orange";this.units.location={x:0,y:24};this.bounds=this.getRect();this.hover.enabled=!0;var K,R,x=this;this.animate=new Tee.Animation(this.chart,function(b){x.value=K+b*(R-K);x.chart.draw()});this.animate.duration=100;this.animate.onstop=function(){x.value=R;if(x.onchange)x.onchange(x);x.chart.draw()};var M,v,L,Q,s,y,B,C,N,O;this.calcBounds=function(){return this.bounds.custom?this.bounds:
this.cellRect(this.bounds,!0)};this.draw=function(){function b(b,c,e,d,g){0<b.radius&&(e=p*b.radius*0.01);a.beginPath();a.arc(0,0,c,d,g,!1);a.arc(0,0,e,g,d,!0);b.draw(a,null,-e,-e,2*e,2*e)}function q(a,c,e){if(a.visible&&""!==a.fill)if(a.ranges&&0<a.ranges.length){var d=n,g,h=a.fill,k=a.gradient.visible,z=m.max-m.min,l=y-s;a.gradient.visible=!1;m.inverted&&(d+=l);for(var f=0;f<a.ranges.length;f++){var p=Math.min(m.max,a.ranges[f].value);g=0===f?p:p-a.ranges[f-1].value+m.min;g=m.inverted?d-l*(g-m.min)/
z:d+l*(g-m.min)/z;a.fill=a.ranges[f].fill;""!==a.fill&&(m.inverted?b(a,c,e,g,d):b(a,c,e,d,g));d=g;if(p>=m.max)break}a.fill=h;a.gradient.visible=k}else b(a,c,e,n,n+(y-s))}function h(b){if(b.visible)if("circle"==m.shape)b.ellipse(B,C,e,g);else if("segment"==m.shape){a.beginPath();var c=m.units.visible?275:240,d=n+0.01745*m.rotation+0.5*(6.283-0.01745*Math.max(c,m.angle)),h=0.5*e,k=0.5*g;a.arc(B,C,h,d,d+Math.max(0.01745*c,z),!1);a.closePath();b.draw(a,null,B-h,C-k,e,g)}else b.rectangle(B-0.5*e,C-0.5*
g,e,g);return b.visible}var z=0.01745*this.angle,c=this.calcBounds(),e,g;B=c.x+0.5*c.width;C=c.y+0.5*c.height;this.bounds.custom?(e=c.width,g=c.height):g=e=Math.min(c.width,c.height);var m=this,a=m.chart.ctx,n=1.57,p=e;for(s=0.01745*m.rotation+0.5*(6.283-z);6.283<=s;)s-=6.283;for(y=s+z;6.283<=y;)y-=6.283;this.drawHand=function(b){b.value=this.limitValue(b.value);var c=0.01745*this.rotation+0.5*(9.4248-z)+z*((this.inverted?this.max-b.value:b.value)-this.min)/l;N=B+e*k.location.x*0.005;O=C+g*k.location.y*
0.005;a.save();a.translate(N,O);a.rotate(c);var c=b.size,d=p*b.back*0.005,h=Math.min(c,6),f=p*b.length*0.005;a.beginPath();1<c?(a.moveTo(-d+h,-c),"needle"==b.shape?(a.quadraticCurveTo(-d,-c,-d,-c+h),a.lineTo(-d,c-h),a.quadraticCurveTo(-d,c,-d+h,c),a.lineTo(f,0)):(a.lineTo(-d+h,c),a.lineTo(f,c),a.lineTo(f,-c)),a.closePath()):(a.moveTo(-d,0),a.lineTo(f,0));1<c?b.draw(a,null,-d,-c,d+f,2*c):(b.stroke.prepare(),a.strokeStyle=b.fill,a.stroke());if(this.ondrawHand)this.ondrawHand(this,b);b.pointer&&F.visible&&
F.ellipse(0.5*(L+v),0,F.size,F.size);a.restore()};h(d)&&(e*=1-0.01*d.size,g*=1-0.01*d.size,this.bounds.custom||(p=g=e));h(this.bevel)&&(e*=1-0.002*d.size,g*=1-0.002*d.size,this.bounds.custom||(p=g=e));h(J);var r=t.outside,c=this.min,l=this.max-this.min,A=this.step;0===A&&(A=l/20);A=Math.max(0.1,A);v=r?0.48*p:0.41*p;M=v-0.01*p*t.length;Q=r?0.39*p:this.rotateText?0.46*p:0.48*p;L=r?0.45*p:0.38*p;d.font.prepare();var x=d.textHeight("Wj"),x=Math.max(1,l/A/(p*z/6.283/x)|0);a.fillStyle=d.font.fill;a.save();
var G=B,H=C;m.bounds.custom&&(e>g?H+=0.75*g*g/e:G+=0.75*e*e/g);a.translate(G,H);a.rotate(s);q(D,M,v);q(E,L,v);var G=A*z/l/f.count,H=s,I=this.rotateText?0:0.3*d.textHeight("Wj"),K=0;for(!t.visible&&r&&(Q=0.9*L);c<=this.max;){t.visible&&(r=(this.hover.enabled&&this.hover.valid?Math.abs(c-this.hover.value)<0.2*A?this.hover:null:null)||t,a.beginPath(),a.moveTo(0,M),t.triangle?(a.lineTo(-3,v),a.lineTo(3,v),a.closePath(),r.draw(a,-3,M,3,v)):(a.lineTo(0,v),r.stroke.prepare(),a.stroke()));if(d.font.visible&&
0===K%x&&(360!=this.angle||c+A<=this.max)){r=Q-d.textHeight()*d.padding;a.translate(0,r);var P=this.rotateText?3.1416:H;a.rotate(-P);d.font.prepare();a.fillStyle=d.font.fill;var w=m.inverted?this.max-c:c,w=m.ongetText?m.ongetText(w):(w|0)==w?w.toFixed(0):w.toFixed(this.decimals);a.fillText(w,0,I);a.rotate(P);a.translate(0,-r)}if(f.visible){if(c<this.max)for(r=0;r<f.count;r++)if(a.rotate(G),r<f.count-1){w=A/f.count;P=c+(r+1)*w;w=(this.hover.enabled&&this.hover.valid?Math.abs(P-this.hover.value)<0.2*
w?this.hover:null:null)||f;if(P>this.max)break;"ellipse"==f.shape?f.ellipse(0,0.5*(L+v),f.size,f.size):(a.beginPath(),a.moveTo(0,L),a.lineTo(0,v),w.stroke.prepare(),a.stroke())}}else a.rotate(G*f.count);H+=G*f.count;c+=A;K++}a.restore();u.visible&&(u.text=this.value.toFixed(this.decimals),u.resize(),u.position.x=B-0.5*u.bounds.width+u.location.x*e*0.01,u.position.y=C+u.location.y*g*0.01,u.draw());c=this.units;c.visible&&(c.resize(),c.position.x=B-0.5*c.bounds.width+c.location.x*e*0.01,c.position.y=
C+c.location.y*g*0.01,c.draw(a));a.save();T.value=this.value;for(c=0;c<this.hands.length;c++)this.hands[c].visible&&this.drawHand(this.hands[c]);a.restore();k.visible&&(c=p*k.size*0.01,k.ellipse(N,O,c,c),k.top.visible&&(c=c*k.top.size*0.01,k.top.ellipse(N,O,c,c)))};this.limitValue=function(b){return Math.min(this.max,Math.max(this.min,b))};this.setValue=function(b){b=this.limitValue(b);var d=this.value!=b;if(d)if(this.animate.active&&0<this.animate.duration)K=this.value,R=b,this.animate.animate(this.chart);
else if(this.value=b,this.onchange)this.onchange(this);return d};this.onclick=function(){};this.clicked=function(){this.dragging=!1;return-1};this.inValue=function(b,d){if(!d.contains(b))return!1;for(var h=b.x-N,f=b.y-O,c=Math.sqrt(h*h+f*f),h=Math.atan2(f,h)-0.5*Math.PI;0>h;)h+=6.283;var e,g;s>y?(f=y,e=s,g=h>=e||h<=f):(e=y,f=s,g=h>=f&&h<=e);return g?(h=this.min+(this.max-this.min)*(s>y?h>e?(h-e)/(6.283-e+f):(6.283-e+h)/(6.283-e+f):(h-f)/(e-f)),this.inverted&&(h=this.max-h),b.value=h,b.inTicks=c>=
Math.min(M,Q)&&c<=v,!0):b.inTicks=!1};this.mousemove=function(b){var d=this.calcBounds(),d=this.inValue(b,d);this.dragging?(d&&this.setValue(b.value)&&this.chart.draw(),this.chart.newCursor="pointer"):b.inTicks&&this.drag.enabled?(I(this,b.value),this.chart.newCursor="pointer"):I(this,null)};var S={x:0,y:0};this.mousedown=function(b){if(this.drag.enabled){var d=this.calcBounds();this.chart.calcMouse(b,S);this.inValue(S,d)?(this.dragging=!0,this.hover.value=null,this.hover.valid=!1,this.setValue(S.value)&&
this.chart.draw()):this.dragging=!1;return this.dragging}return!1}};Tee.CircularGauge.prototype=new Tee.Series;Tee.CircularGauge.prototype.setChart=function(q,n){var I=Tee.Series.prototype.setChart;I(q,n);q.back.setChart(n);q.center.setChart(n);q.center.top.setChart(n);q.ticks.setChart(n);q.ticksBack.setChart(n);q.minor.setChart(n);q.minorBack.setChart(n);q.hand.setChart(n);q.units.setChart(n);q.pointer.setChart(n);q.bevel.setChart(n)}})();
