UNPKG

js-pkg

Version:
10 lines 239 kB
/*! * filename: ej.gauge.min.js * version : 15.3.0.33 * Copyright Syncfusion Inc. 2001 - 2017. All rights reserved. * Use of this code is subject to the terms of our license. * A copy of the current license can be obtained at any time by e-mailing * licensing@syncfusion.com. Any infringement will be prosecuted under * applicable laws. */ (function(n){typeof define=="function"&&define.amd?define(["./../common/ej.core.min"],n):n()})(function(){(function(n,t,i){var r,f,u;t.widget({ejCircularGauge:"ej.datavisualization.CircularGauge"},{_rootCSS:"e-circulargauge",validTags:["div","span"],_savedPoints:[],_labelRadius:0,_customLblMaxSize:0,defaults:{locale:null,enableGroupSeparator:!1,value:0,minimum:0,maximum:100,radius:180,width:360,height:360,frame:{frameType:"fullcircle",backgroundImageUrl:null,halfCircleFrameStartAngle:180,halfCircleFrameEndAngle:360},backgroundColor:null,interiorGradient:null,readOnly:!0,enableAnimation:!0,animationSpeed:500,theme:"flatlight",isRadialGradient:!1,enableResize:!1,isResponsive:!1,tooltip:{showLabelTooltip:!1,showCustomLabelTooltip:!1,templateID:null},outerCustomLabelPosition:"bottom",gaugePosition:"center",distanceFromCorner:20,rangeZOrder:"rear",drawTicks:null,drawLabels:null,drawPointers:null,drawRange:null,drawCustomLabel:null,drawIndicators:null,drawPointerCap:null,load:null,renderComplete:null,mouseClick:null,mouseClickMove:null,mouseClickUp:null,legendItemRender:null,legendItemClick:null,rangeMouseMove:null,scales:null,legend:{visible:!1,toggleVisibility:!0,border:{color:"transparent",width:1},itemPadding:20,shape:"circle",alignment:"center",position:"bottom",itemStyle:{height:9,width:9,border:{color:"transparent",width:1}},opacity:1,fill:null,font:{color:null,fontFamily:"Segoe UI",fontStyle:"Normal",fontWeight:"Regular",size:"12px"},size:{height:null,width:null}},themeProperties:{flatlight:{backgroundColor:"#FFFFFF",scales:{pointerCap:{borderColor:"#424242",backgroundColor:"#424242"},backgroundColor:"#777777",border:{color:"#777777"},pointers:{backgroundColor:"#424242",border:{color:"#424242"}},ticks:{color:"#777777"},labels:{color:"#282828"}}},flatdark:{backgroundColor:"#1F1F1F",scales:{pointerCap:{borderColor:"#686868",backgroundColor:"#686868"},backgroundColor:"#7a7a7a",border:{color:"#7a7a7a"},pointers:{backgroundColor:"#686868",border:{color:"#686868"}},ticks:{color:"#7a7a7a"},labels:{color:"#d3d3d3"}}}}},_defaultScaleValues:function(){return{size:6,pointerCap:{radius:7,borderWidth:3,interiorGradient:null,borderColor:null,backgroundColor:null},showScaleBar:!1,sweepAngle:310,radius:170,startAngle:115,majorIntervalValue:10,minorIntervalValue:2,maximum:null,minimum:null,border:{color:null,width:1.5},backgroundColor:null,direction:"clockwise",showPointers:!0,showRanges:!1,showTicks:!0,showLabels:!0,showIndicators:!1,opacity:1,shadowOffset:0,customLabels:[{value:null,color:null,textAngle:0,positionType:"inner",position:{x:0,y:0},font:{size:"11px",fontFamily:"arial",fontStyle:"bold"}}],pointers:[{distanceFromScale:0,showBackNeedle:!1,backNeedleLength:10,length:150,placement:"near",width:7,opacity:1,value:null,border:{color:null,width:1.5},backgroundColor:null,gradients:null,type:"needle",needleType:"triangle",markerType:"rectangle",imageUrl:"",pointerValueText:{showValue:!1,distance:20,font:{size:"11px",fontFamily:"Arial",fontStyle:"Bold"},color:"#8c8c8c",opacity:1,autoAngle:!1,angle:0}}],ranges:[{legendText:null,distanceFromScale:25,size:5,placement:"near",startValue:null,endValue:null,startWidth:null,endWidth:null,gradients:null,opacity:null,backgroundColor:"#32b3c6",border:{color:"#32b3c6",width:1.5}}],ticks:[{angle:0,distanceFromScale:0,color:null,type:"major",placement:"near",height:16,width:3},{angle:0,distanceFromScale:0,color:null,type:"minor",placement:"near",height:7,width:1}],labels:[{angle:0,autoAngle:!1,opacity:null,font:{size:"11px",fontFamily:"Arial",fontStyle:"Bold"},color:null,distanceFromScale:0,includeFirstValue:!0,placement:"near",type:"major",unitText:"",unitTextPosition:"back"}],indicators:[{height:15,width:15,type:"circle",imageUrl:null,position:{x:0,y:0},stateRanges:[{endValue:0,startValue:0,backgroundColor:null,borderColor:null,text:"",textColor:null,font:null}]}],subGauges:[{height:150,width:150,position:{x:0,y:0}}]}},dataTypes:{scales:"data",isResponsive:"boolean"},observables:["value","minimum","maximum"],_tags:[{tag:"scales",attr:["showScaleBar","pointerCap.radius","pointerCap.borderWidth","pointerCap.interiorGradient","pointerCap.borderColor","pointerCap.backgroundColor","sweepAngle","startAngle","showPointers","showTicks","backgroundColor","scaleRadius","majorIntervalValue","minorIntervalValue","shadowOffset","showRanges","showLabels","showCustomLabels","showIndicators","border.width","border.color",[{tag:"pointers",attr:["distanceFromScale","showBackNeedle","backNeedleLength","backgroundColor","needleType","markerType","border.width","border.color","imageUrl","pointerValueText.showValue","pointerValueText.distance","pointerValueText.font.size","pointerValueText.font.fontFamily","pointerValueText.font.fontStyle","pointerValueText.angle","pointerValueText.autoAngle","pointerValueText.color","pointerValueText.opacity"]},{tag:"labels",attr:["autoAngle","distanceFromScale","includeFirstValue","unitText","unitTextPosition","font.size","font.fontFamily","font.fontStyle"]},{tag:"ticks",attr:["distanceFromScale"]},{tag:"ranges",attr:["legendText","distanceFromScale","startValue","endValue","startWidth","endWidth","backgroundColor","border.color","border.width"]},{tag:"indicators",attr:["imageUrl","position.x","position.y",[{tag:"stateRanges",attr:["endValue","startValue","backgroundColor","borderColor","textColor"]}]]},{tag:"subGauges",attr:["controlID","position.x","position.y"]},{tag:"customLabels",attr:["positionType","textAngle","position.x","position.y","font.size","font.fontFamily","font.fontStyle"]}]]}],value:t.util.valueFunction("value"),minimum:t.util.valueFunction("minimum"),maximum:t.util.valueFunction("maximum"),_setModel:function(t){var i,r,u,f,e;for(i in t)switch(i){case"height":this.model.height=t[i];break;case"width":this.model.width=t[i];break;case"radius":this.model.radius=t[i];break;case"frame":n.extend(this.model.frame,t[i]);break;case"tooltip":n.extend(this.model.tooltip,t[i]);break;case"backgroundColor":this.model.backgroundColor=t[i];break;case"interiorGradient":this.model.interiorGradient=t[i];break;case"readOnly":this.model.readOnly=t[i];break;case"theme":this.model.theme=t[i];break;case"isRadialGradient":this.model.isRadialGradient=t[i];break;case"outerCustomLabelPosition":this.model.outerCustomLabelPosition=t[i];break;case"gaugePosition":this.model.gaugePosition=t[i];break;case"distanceFromCorner":this.model.distanceFromCorner=t[i];break;case"rangeZOrder ":this.model.rangeZOrder=t[i];break;case"value":for(this.value()==""&&this.value(0),r=0;this.model.scales[r]!=null;r++)for(u=0;this.model.scales[r].pointers[u]!=null;u++)this.model.scales[r].pointers[u].value=parseFloat(this.value());break;case"minimum":for(this.minimum()==""&&this.minimum(0),f=0;this.model.scales[f]!=null;f++)this.model.scales[f].minimum=parseInt(this.minimum());break;case"maximum":for(this.maximum()==""&&this.maximum(100),e=0;this.model.scales[e]!=null;e++)this.model.scales[e].maximum=parseInt(this.maximum());break;case"scales":n.extend(!0,this.model.scales,t[i])}this._init()},_destroy:function(){this._unWireEvents();this.element.empty().removeClass("e-circulargauge e-js e-widget")},_init:function(){r=n(".e-circulargauge").length;f=r;this._scaleRedrawn=!1;this._scalesInitialize();this._trigger("load");this._setTheme();this._initialize();this._wireEvents();this._onWindowResize()},_onWindowResize:function(){(this.model.enableResize||this.model.isResponsive)&&(t.isTouchDevice()?this._on(n(window),"orientationchange",this.resizeCanvas):this._on(n(window),"resize",this.resizeCanvas))},_initialize:function(){this._androidAnimation=this.isAndroid()&&t.datavisualization.CircularGauge.animationPolyfill;this._initObject(this);this._drawOuterLayer();this.model.legend.visible&&this.model.legend._legendItemHeight>0&&this.model.legend._legendItemWidth>0&&(this._drawLegend(),this._legendDrawn=!0);this._drawScales();this.model.renderComplete&&this._onRenderComplete()},_drawLegend:function(){var u=this.model.legend,n,p=this.GaugeEl,i=20,c=this.model.legend.position.toLowerCase(),l=this.model.legend.alignment.toLowerCase(),y,f=this.model.legend.border.width,e=this.model.width,o=this.model.height,s,a,h;for(n=this.model.legendActualBounds,c=="top"||c=="bottom"?(n.y=c=="top"?f+i:o-n.Height-i,n.x=l=="center"?e/2-n.Width/2:l=="near"?f+i:e-n.Width-i,n.x=n.x+n.Width>e?n.x-Math.abs(n.x+n.Width-e):n.x):(n.x=c=="left"?f+i:e-n.Width-i,n.y=l=="center"?o/2-n.Height/2:l=="near"?f+i:o-n.Height-i,n.y=n.y+n.Height>o?n.y-Math.abs(n.y+n.Height-o):n.y),this._legendBounds=n,this.contextEl.lineWidth=f,this.contextEl.save(),this.contextEl.strokeStyle=this.model.legend.border.color,this.contextEl.strokeRect(n.x,n.y,n.Width,n.Height),this.contextEl.restore(),this.model._legendCollection=[],s=0;s<this.model.scales.length;s++)for(a=this.model.scales[s],h=0;h<a.ranges.length;h++){var r=a.ranges[h],v;r._visible=t.util.isNullOrUndefined(r._visible)?!0:r._visible;t.util.isNullOrUndefined(r.legendText)||(v=this._getLegendSize(r,10),y={Bounds:{Height:v.Height,Width:v.Width},legendStyle:{font:u.font,opacity:u.opacity,BorderColor:u.itemStyle.border.color,BorderWidth:u.itemStyle.border.width},displayText:r.legendText,fill:t.util.isNullOrUndefined(u.fill)?r.backgroundColor:u.fill,ScaleIndex:s,RangeIndex:h,visible:r._visible},this.model._legendCollection.push(y))}this._drawLegendItem(n)},legendMouseClick:function(n){var i,t,u,f,e,o,s,h,r=this.calMousePosition(n);if(this.model.legend.toggleVisibility)for(i=0;i<this.legendRegion.length;i++)t=this.legendRegion[i],u=t.X,f=t.X+t.Width,e=t.Y,o=t.Y+t.Height,r.X>=u&&r.X<=f&&r.Y>=e&&r.Y<=o&&(s={type:"legendItemClick",cancel:!1,data:t,model:this.model},this._trigger("legendItemClick",s),h=this.model.scales[t.item.ScaleIndex].ranges[t.item.RangeIndex]._visible?!1:!0,this.setRangeVisible(t.item.ScaleIndex,t.item.RangeIndex,h))},calMousePosition:function(t){var e=jQuery.uaMatch(navigator.userAgent),r,u,f,o,i;return r=this.GaugeEl[0],i=r.querySelector("canvas"),o=e.browser.toLowerCase(),u=t.pageX-n(i).offset().left,f=t.pageY-n(i).offset().top,{X:u,Y:f}},rangesMouseMove:function(t){var ot=this,a,v,p,w,b,k,d,g,ft,f,r,nt,y,s,tt,h=this.calMousePosition(t),i,e,o,et,it,rt,ut,u,c,l;if(this.model.legend.toggleVisibility&&this._legendDrawn)for(v=0;v<this.legendRegion.length;v++)if(i=this.legendRegion[v],p=i.X,w=i.X+i.Width,b=i.Y,k=i.Y+i.Height,h.X>=p&&h.X<=w&&h.Y>=b&&h.Y<=k){n(this.GaugeEl[0]).css("cursor","pointer");break}else n(this.GaugeEl[0]).css("cursor","default");for(d=h.X,g=h.Y,ft=[],f=this.model.scales[0].startAngle,r=this.model.scales[0].sweepAngle,nt=f*(Math.PI/180),y=0;y<this._rangeCollectionRegions.length;y++)if(i=this._rangeCollectionRegions[y],e=d-i.centerRadius.centerX,o=g-i.centerRadius.centerY,et=i.Radius.endRadius?i.Radius.endRadius:0,f=f<0?f+360:f,r=r<0?r+360:r,it=r-f,rt=-.5*Math.PI+nt,it<0){if(r=r/360,ut=r?2*Math.PI*(r<0?1+r:r):0,u=(Math.atan2(o,e)-rt-ut)%(2*Math.PI),u<0&&(u=2*Math.PI+u),c=Math.PI*(i.Region.startAngle/180),l=Math.PI*(i.Region.endAngle/180),u<=c&&u>=l&&(s=Math.sqrt(Math.pow(Math.abs(e),2)+Math.pow(Math.abs(o),2)),s<=i.Radius.startRadius&&s>i.Radius.endRadius)){a={type:"rangeMouseMove",cancel:!1,data:i,model:this.model};this._trigger("rangeMouseMove",a);break}}else if(u=Math.atan2(o,e)%(2*Math.PI),u<0&&(u=2*Math.PI+u),i.Region.endAngle<i.Region.startAngle?(c=e>0&&o>0?0:Math.PI*(i.Region.startAngle/180),l=e>0&&o>0?Math.PI*(i.Region.endAngle/180):Math.PI*((360+i.Region.endAngle)/180)):(c=Math.PI*(i.Region.startAngle/180),l=Math.PI*(i.Region.endAngle/180)),u>=c&&u<=l&&(s=Math.sqrt(Math.pow(Math.abs(e),2)+Math.pow(Math.abs(o),2)),s<=i.Radius.startRadius&&s>i.Radius.endRadius)){tt=i;a={type:"rangeMouseMove",cancel:!1,data:i,model:this.model};this._trigger("rangeMouseMove",a);break}return tt},_drawLegendItem:function(i){var s=[],e=[],st,tt,r,nt,pt;for(this.legendRegion=[],this.model.legend._legendTextMaxHeight=0,this.model.legend._legendTextMaxWidth=0,tt=this.model.legend.position.toLowerCase(),r=0;r<this.model._legendCollection.length;r++){var c=this.model.legend.shape.toLowerCase(),y=10,p=10,w=3,a,v,it,rt,ut,u,b,ht,k,ft,ct,et,lt,at,o,vt,ot,f,d,h,l,g,yt=10;u=this.model._legendCollection[r];t.util.isNullOrUndefined(u.displayText)||(st={type:"legendItemRender",cancel:!1,data:u,model:this.model},this._trigger("legendItemRender",st),this.model.scales[u.ScaleIndex].ranges[u.RangeIndex]._visible=t.util.isNullOrUndefined(this.model.scales[u.ScaleIndex].ranges[u.RangeIndex]._visible)?!0:this.model.scales[u.ScaleIndex].ranges[u.RangeIndex]._visible,ht=this.model.scales[u.ScaleIndex].ranges[u.RangeIndex]._visible?u.fill:"#808080",lt=this.model.scales[u.ScaleIndex].ranges[u.RangeIndex]._visible?u.legendStyle.font.color:"#808080",at=this._getFontString(this,u.legendStyle.font),o=this.calcText(u.displayText,i.Width,u.legendStyle.font),this.model.legend._legendTextMaxHeight=Math.max(o.height,this.model.legend._legendTextMaxHeight),this.model.legend._legendTextMaxWidth=Math.max(o.width,this.model.legend._legendTextMaxWidth),vt=this.model.legend.itemStyle.height,ot=this.model.legend.itemStyle.width,f=(vt+ot)/2,d={angle:0,width:f,isFill:!0,isStroke:!0,height:f,lineWidth:this.model.legend.itemStyle.border.width,opacity:u.legendStyle.opacity,strokeStyle:u.legendStyle.BorderColor,fillStyle:ht},y=f>o.height/2?y+f/2:y+o.height/4,p=c=="circle"?p+f/2:p,r==0?(a=p+i.x,v=i.y+y):tt=="top"||tt=="bottom"?(nt=e[r-1].x+e[r-1].width+this.model.legend.itemPadding,nt+f+w+o.width>=i.x+i.Width?(a=p+i.x,v=this.model.legend._legendTextMaxHeight/2>f?e[r-1].y+s[r-1].actualBounds.height/2+f/2+yt:yt+s[r-1].actualBounds.y+s[r-1].actualBounds.height/2+f/2):(a=c.toLowerCase()=="circle"?nt+f/2:nt,v=s[r-1].actualBounds.y)):(ut=e[r-1].height>f?e[r-1].y+this.model.legend.itemPadding:s[r-1].actualBounds.y+f+this.model.legend.itemPadding,pt=e[r-1].height>f?o.height:f,ut+pt-2>i.y+i.Height+2?(v=i.y+y,a=s[r-1].actualBounds.x+s[r-1].actualBounds.width+(this.model.legend._legendTextMaxWidth+w)+10):(a=s[r-1].actualBounds.x,v=ut)),h={startX:a,startY:v},c=c.charAt(0).toUpperCase()+c.slice(1),l=n.extend({},h,!0),l.startX=c.toLowerCase()=="circle"?l.startX-f/2:l.startX,l.startY=l.startY-f/2,s.push({actualBounds:{x:h.startX,y:h.startY,height:f,width:f},item:u}),b={angle:0,width:o.width,isFill:!0,isStroke:!0,height:o.height,textValue:u.displayText,font:at,fillStyle:lt,opacity:u.legendStyle.opacity,strokeStyle:u.legendStyle.BorderColor},it=c.toLowerCase()=="circle"?h.startX+ot/2+w:h.startX+d.width+w,rt=h.startY+o.height/4,e.push({x:it,y:rt,height:o.height/2,width:o.width}),k=l.startX,ct=Math.abs(k+s[r].actualBounds.width-k)+w+Math.abs(e[r].x+e[r].width-e[r].x),f>e[r].height?(ft=l.startY,et=f):(ft=e[r].y-e[r].height,et=e[r].height),c.toLowerCase()=="circle"?(g=this._setPointerDimension(d,this),this._contextOpenPath(g,this),this._setContextRotation(g,this),this.contextEl.arc(h.startX,h.startY,f/2,0,2*Math.PI),this._contextClosePath(g,this)):this["_draw"+c](h,d,this),this._contextOpenPath(b,this),this.contextEl.font=b.font,this.contextEl.translate(it,rt),this.contextEl.fillText(b.textValue,0,0),this._contextClosePath(b,this),this.legendRegion.push({X:k,Y:ft,Width:ct,Height:et,item:u}))}},calcText:function(t,r,u){var h=n(document).find("#measureTex"),f,c=null,l=null,a=null,v=null,o,s,e,y;if(n("#measureTex").css("display","block"),h.length==0?(f=document.createElement("text"),n(f).attr({id:"measureTex"}),document.body.appendChild(f)):f=h[0],typeof t=="string"&&(t.indexOf("<")>-1||t.indexOf(">")>-1)){for(o=t.split(" "),s=0;s<o.length;s++)o[s].indexOf("<br/>")==-1&&(o[s]=o[s].replace(/[<>]/g,"&"));t=o.join(" ")}return f.innerHTML=t,u!=i&&u.size==i&&(e=u,e=e.split(" "),c=e[0],l=e[1],a=e[2],v=e[3]),u!=null&&(f.style.fontSize=u.size>0?u.size+"px":u.size?u.size:l,f.style.fontStyle&&(f.style.fontStyle=u.fontStyle?u.fontStyle:c),f.style.fontFamily=u.fontFamily?u.fontFamily:a,window.navigator.userAgent.indexOf("MSIE 8.0")==-1&&(f.style.fontWeight=u.fontWeight?u.fontWeight:v)),f.style.backgroundColor="white",f.style.position="absolute",f.style.top=-100,f.style.left=0,f.style.visibility="hidden",f.style.whiteSpace="nowrap",r&&(f.style.maxwidth=r+"px"),y={width:f.offsetWidth,height:f.offsetHeight},n("#measureTex").css("display","none"),y},_calculateLegendBounds:function(){var i=this,r=i.model.legend,f=0,a,e=i.model.legend.position.toLowerCase(),o,v,c,u=10,y=i.model.legend.border.width,p=i.model.legend.itemPadding,s,l,h;return s=i.findMaxHeightWidth(),this._gaugeResizeState||t.util.isNullOrUndefined(i.model.legend.size.height)&&t.util.isNullOrUndefined(i.model.legend.size.width)?(h=i.findLegendMax(),l={Height:h.Height,Width:h.Width},i.model.legend.size._height=i.model.legend.size._width=null):parseInt(i.model.legend.size.width)<s.width&&!t.util.isNullOrUndefined(i.model.legend.size.width)||parseInt(i.model.legend.size.height)<s.height&&!t.util.isNullOrUndefined(i.model.legend.size.height)?(h=i.findLegendMax(),l={Height:h.Height,Width:h.Width},i.model.legend.size._height=i.model.legend.size._width=null):(i.model.legend._legendItemHeight=0,i.model.legend._columnWidth=0,i.model.legend._legendItemWidth=0,i.model.legend._rowCount=1,i.model.legend._columnCount=1,i.model.legend._maxWidth=0,i.model.legend._maxHeight=0,i._columnIncreasing=0,i._columnDecreasing=0,n.each(i.model.scales,function(w,b){if(b.showRanges&&(i.scaleIndex=w,b.ranges!=null)){for(i.rangeEl=b.ranges,i.index=0,a=0;a<i.model.scales[i.scaleIndex].ranges.length;a++)t.util.isNullOrUndefined(i.model.scales[i.scaleIndex].ranges[a].legendText)||f++;n.each(b.ranges,function(n,a){i.rangeIndex=n;!t.util.isNullOrUndefined(a.legendText)&&a.legendText.replace(/\s/g,"").length>0&&i.index<f&&(o=i._getLegendSize(a),parseInt(i.model.legend.size.width)?(c=i.index==0?u+y:e=="top"||e=="bottom"?p:u,v=i.index==0?u+y:0,r._legendItemWidth=e=="top"||e=="bottom"?c+o.Width+r._legendItemWidth:c+s.width+r._legendItemWidth,r._legendItemHeight=v+Math.max(o.Height,r._legendItemHeight),i._columnIncreasing++,i._columnDecreasing=Math.max(i._columnDecreasing,i._columnIncreasing),parseInt(i.model.legend.size.width)<=r._legendItemWidth?(i.model.legend._rowCount++,i._columnIncreasing=0,r._legendItemHeight+=e=="top"||e=="bottom"?i.index==f-1?o.Height+u*2:o.Height+u:i.index==f-1?o.Height+u+p:o.Height+p,r._legendItemWidth=e=="top"||e=="bottom"?i.index==f-1?parseInt(i.model.legend.size.width):o.Width+u:s.width+u):i.index==f-1&&i.model.legend._rowCount>1&&(r._legendItemHeight+=u,i.model.legend.size._width=i.model.legend.size.width,parseInt(i.model.legend.size.width)>s.width*(i._columnDecreasing-1)+(i._columnDecreasing-1)*u+u&&(r._legendItemWidth=s.width*(i._columnDecreasing-1)+(i._columnDecreasing-1)*u+u,i.model.legend.size._width=null))):e=="left"||e=="right"?(c=i.index==0?u+y:i.index==f-1?u:0,v=i.index==0?u+y:p,r._legendItemWidth=c+Math.max(s.width,r._legendItemWidth),r._legendItemHeight=v+o.Height+r._legendItemHeight,i.model.legend.size._height=parseInt(i.model.legend.size.height),parseInt(i.model.legend.size.height)<r._legendItemHeight?(i.model.legend._rowCount++,r._legendItemWidth+=i.index==f-1?s.width+u*2:s.width+u,r._legendItemHeight=o.Height+u):f==1&&parseInt(i.model.legend.size.height)>r._legendItemHeight&&(i.model.legend.size._height=null,r._legendItemWidth+=u,r._legendItemHeight+=u)):(h=i.findLegendMax(),l={Height:h.Height,Width:h.Width},i.index=f-1));i.index++})}}),l={Height:r._legendItemHeight,Width:r._legendItemWidth}),l},findLegendMax:function(){var i=this,r;i.model.legend._legendItemHeight=0;i.model.legend._rowWidth=0;i.model.legend._legendItemWidth=0;i.model.legend._rowCount=1;i.model.legend._columnCount=1;i.model.legend._maxWidth=0;i.model.legend._maxHeight=0;var r=i.model.legend,f=0,a,v,y=i.model.legend.position.toLowerCase(),o,h,c,e=20,u=10,p,s=i.model.legend.border.width,l=i.model.legend.itemPadding;return i.model.legend.size._height=i.model.legend.size._width=null,n.each(i.model.scales,function(w,b){if(b.showRanges&&(i.scaleIndex=w,b.ranges!=null)){for(i.rangeEl=b.ranges,i.index=0,a=0;a<i.model.scales[i.scaleIndex].ranges.length;a++)t.util.isNullOrUndefined(i.model.scales[i.scaleIndex].ranges[a].legendText)||f++;n.each(b.ranges,function(n,a){i.rangeIndex=n;t.util.isNullOrUndefined(a.legendText)||(o=i._getLegendSize(a),y=="top"||y=="bottom"?(f!=1?(c=i.index==0?u*2+s:i.index==f-1?u+l:l,h=i.index==0?u:i.index==f-1?u:0):h=c=u*2,r._legendItemHeight=h+Math.max(o.Height,r._legendItemHeight),r._maxHeight=Math.max(o.Height,r._maxHeight),r._legendItemWidth=c+o.Width+r._legendItemWidth,p=i.model.legend._rowCount>1&&i.index==f-1?u:0,i.model.width-(e-s)<=r._legendItemWidth-p?(i.model.legend._rowCount++,r._rowWidth=Math.max(r._rowWidth,r._legendItemWidth-l-o.Width),r._legendItemWidth=i.index==f-1?r._rowWidth<i.model.width-e*2?r._rowWidth:i.model.width-e*2:i.index==0?e+u+s:o.Width+e+u+s,r._legendItemHeight+=r._maxHeight+(u+s)):i.index==f-1&&i.model.legend._rowCount>1&&(r._legendItemWidth=r._rowWidth<i.model.width-e*2?r._rowWidth:i.model.width-e*2)):(f!=1?(h=i.index==0?u+s:i.index==f-1?u+l:l,c=i.index==0?u:i.index==f-1?u*2:0):h=c=u*2,r._legendItemHeight=o.Height+h+r._legendItemHeight,r._legendItemWidth=c+Math.max(o.Width,r._legendItemWidth),r._maxWidth=Math.max(o.Width,r._maxWidth),i.model.height-e<r._legendItemHeight?(i.model.legend._columnCount++,v=i.model.legend._columnCount==2?e:0,r._legendItemHeight=i.index==f-1?i.model.height-e*2:o.Height+e+u+s+v,r._legendItemWidth+=r._maxWidth+u):i.index==f-1&&i.model.legend._columnCount>1&&(r._legendItemHeight=i.model.height-e*2)),i.index++)})}}),{Height:r._legendItemHeight,Width:r._legendItemWidth}},findMaxHeightWidth:function(){var u=this,t=0,i=0,r;return n.each(u.model.scales,function(f,e){n.each(e.ranges,function(n,f){r=u._getLegendSize(f);t=Math.max(r.Height,t);i=Math.max(r.Width,i)})}),{height:t,width:i}},_getLegendSize:function(n){var t,i,r,u,f=this.model.legend.font;return t=(this.model.legend.itemStyle.width+this.model.legend.itemStyle.height)/2,i=this.calcText(n.legendText,null,f),r=Math.max(t,i.height/2),u=t+3+i.width,{Height:r,Width:u}},_scalesInitialize:function(){var t=this;this.model.scales!=null?n.each(this.model.scales,function(i,r){r=t._checkArrayObject(r,i);var u=t._defaultScaleValues();n.extend(u,r);n.extend(r,u)}):this.model.scales=[this._defaultScaleValues()]},_checkArrayObject:function(t,i){var r=this,u;return n.each(t,function(n,t){if(u=typeof n,(u!="string"||u=="string"&&n.indexOf("_")==-1&&n.indexOf("__")==-1)&&typeof t!="function")if(t instanceof Array)r._checkArrayObject(t,n);else if(t!=null&&typeof t=="object"&&!t.setter&&!t.factory&&!t.key){var f=r._defaultScaleValues();r._LoadIndividualDefaultValues(t,f,typeof n=="number"?i:n)}}),t},_LoadIndividualDefaultValues:function(t,i,r){var u=null,e=this,f;return n.each(i,function(n,t){if(r==n){u=t;return}}),u instanceof Array&&(u=u[0]),f=typeof r,n.each(t,function(n,t){t instanceof Array?e._checkArrayObject(t,r):t!=null&&typeof t=="object"&&(f!="string"||f=="string"&&r.indexOf("_")==-1&&r.indexOf("__")==-1)&&e._LoadIndividualDefaultValues(t,t,typeof n=="number"?r:n)}),n.extend(u,t),n.extend(t,u),t},_initObject:function(i){var p,a,l,y,s,h,o,tt,d,g,e,c,nt,it,v;for(this._savedPoints=[],this.element.addClass("e-widget"),i.GaugeEl=this.element,i.canvasEl?(i.canvasEl.remove(),i.GaugeEl.empty()):i.canvasEl=n("<canvas><\/canvas>"),p=0,e=0;this.model.scales[e]!=null;e++){for(this.model.scales[e].minimum==null&&(this.model.scales[e].minimum=this.minimum()),this.model.scales[e].maximum==null&&(this.model.scales[e].maximum=this.maximum()),a=0;this.model.scales[e].pointers[a]!=null;a++)this.model.scales[e].pointers[a].value==null&&(this.model.scales[e].pointers[a].value=this.value());for(l=0;this.model.scales[e].customLabels[l]!=null;l++)if(this.model.scales[e].customLabels[l].value!=null&&(p++,i.GaugeEl.find("div").length==0))if(this.model.scales[e].customLabels[l]!=null&&this.model.scales[e].customLabels[l].positionType!=null&&this.model.scales[e].customLabels[l].positionType=="outer")if(i.outerDiv=t.buildTag("div"),i.model.outerCustomLabelPosition=="bottom")i.GaugeEl.append(i.canvasEl),i.GaugeEl.append(i.outerDiv),i.outerDiv.css("text-align","center");else if(i.model.outerCustomLabelPosition!="top"){y=t.buildTag("TABLE");y.css("width","100%");var w=t.buildTag("TR"),b=t.buildTag("TD"),k=t.buildTag("td");i.model.outerCustomLabelPosition=="left"?(b.append(i.outerDiv),k.append(i.canvasEl)):(b.append(i.canvasEl),k.append(i.outerDiv));w.append(b);w.append(k);y.append(w);i.GaugeEl.append(y);i.outerDiv.css({width:this.element.width()-i.model.width})}else i.GaugeEl.append(i.outerDiv),i.GaugeEl.append(i.canvasEl),i.outerDiv.css("text-align","center");else i.GaugeEl.append(i.canvasEl);p==0&&i.GaugeEl.append(i.canvasEl)}if(i.canvasEl.attr("role","presentation"),r==f&&(u=window.innerWidth),i.canvasEl[0].setAttribute("width",i.model.width),i.canvasEl[0].setAttribute("height",i.model.height),i.centerX=i.canvasEl[0].width/2,i.centerY=i.canvasEl[0].height/2,s=20,this.model.legend.visible){if(this.model.legend.font.color=this.model.theme=="flatdark"?t.util.isNullOrUndefined(this.model.legend.font.color)?"#8c8c8c":this.model.legend.font.color:t.util.isNullOrUndefined(this.model.legend.font.color)?"#282828":this.model.legend.font.color,tt=this.model.legend.position.toLowerCase(),o=this._calculateLegendBounds(),o.Height=t.util.isNullOrUndefined(this.model.legend.size._height)?o.Height:parseInt(this.model.legend.size.height),o.Width=t.util.isNullOrUndefined(this.model.legend.size._width)?o.Width:parseInt(this.model.legend.size.width),this.model.legendActualBounds=o,o.Height>0&&o.Width>0){switch(tt){case"top":d=i.model.height-(o.Height+s);i.centerY=o.Height+s+d/2;h=d/2-s;break;case"bottom":i.centerY=(i.model.height-(o.Height+s))/2;h=i.centerY-s;break;case"left":g=i.model.width-(o.Width+s);i.centerX=o.Width+s+g/2;h=g/2-s*2;break;case"right":i.centerX=(i.model.width-(o.Width+s))/2;h=i.centerX-s*2}for(e=0;e<this.model.scales.length;e++)c=this.model.scales[e],nt=0,this._scaleRedrawn||(c._radius=c.radius),n.each(c.ranges,function(n,t){nt+=t.size}),it=nt/c.ranges.length,h=Math.abs((h-it)/(e+1)),h=c.radius=c._radius<h?c._radius:h}}else n.each(this.model.scales,function(n,i){i.radius=t.util.isNullOrUndefined(i._radius)?i.radius:i._radius});if(this._isHalfCircle&&this._isHalfCircle())if(i.model.frame.halfCircleFrameEndAngle-i.model.frame.halfCircleFrameStartAngle>=180){if(i.model.frame.halfCircleFrameStartAngle==0)switch(i.model.gaugePosition){case"center":i.centerY=i.model.height/2-i.model.radius/2;i.centerX=i.model.width/2;break;case"topleft":i.centerY=i.model.distanceFromCorner;i.centerX=i.model.radius+i.model.distanceFromCorner;break;case"topright":i.centerY=i.model.distanceFromCorner;i.centerX=i.model.width-(i.model.radius+i.model.distanceFromCorner);break;case"topcenter":i.centerY=i.model.distanceFromCorner;i.centerX=i.model.width/2;break;case"middleleft":i.centerY=i.model.height/2-i.model.radius/2;i.centerX=i.model.radius+i.model.distanceFromCorner;break;case"middleright":i.centerY=i.model.height/2-i.model.radius/2;i.centerX=i.model.width-(i.model.radius+i.model.distanceFromCorner);break;case"bottomleft":i.centerY=i.model.height-(i.model.radius+i.model.distanceFromCorner);i.centerX=i.model.radius+i.model.distanceFromCorner;break;case"bottomright":i.centerY=i.model.height-(i.model.radius+i.model.distanceFromCorner);i.centerX=i.model.width-(i.model.radius+i.model.distanceFromCorner);break;case"bottomcenter":i.centerY=i.model.height-(i.model.radius+i.model.distanceFromCorner);i.centerX=i.model.width/2}else if(i.model.frame.halfCircleFrameStartAngle==90)switch(i.model.gaugePosition){case"center":i.centerY=i.model.height/2;i.centerX=i.model.width/2+i.model.radius/2;break;case"topleft":i.centerY=i.model.distanceFromCorner+i.model.radius;i.centerX=i.model.distanceFromCorner+i.model.radius;break;case"topright":i.centerY=i.model.distanceFromCorner+i.model.radius;i.centerX=i.model.width-i.model.distanceFromCorner;break;case"topcenter":i.centerY=i.model.distanceFromCorner+i.model.radius;i.centerX=i.model.width/2+i.model.radius/2;break;case"middleleft":i.centerY=i.model.height/2;i.centerX=i.model.distanceFromCorner+i.model.radius;break;case"middleright":i.centerY=i.model.height/2;i.centerX=i.model.width-i.model.distanceFromCorner;break;case"bottomleft":i.centerY=i.model.height-(i.model.distanceFromCorner+i.model.radius);i.centerX=i.model.distanceFromCorner+i.model.radius;break;case"bottomright":i.centerY=i.model.height-(i.model.distanceFromCorner+i.model.radius);i.centerX=i.model.width-i.model.distanceFromCorner;break;case"bottomcenter":i.centerY=i.model.height-(i.model.distanceFromCorner+i.model.radius);i.centerX=i.model.width/2+i.model.radius/2}else if(i.model.frame.halfCircleFrameStartAngle==180)switch(i.model.gaugePosition){case"center":i.centerY=i.model.height/2+i.model.radius/2;i.centerX=i.model.width/2;break;case"topleft":i.centerY=i.model.distanceFromCorner+i.model.radius;i.centerX=i.model.distanceFromCorner+i.model.radius;break;case"topright":i.centerY=i.model.distanceFromCorner+i.model.radius;i.centerX=i.model.width-(i.model.distanceFromCorner+i.model.radius);break;case"topcenter":i.centerY=i.model.distanceFromCorner+i.model.radius;i.centerX=i.model.width/2;break;case"middleleft":i.centerY=i.model.height/2+i.model.radius/2;i.centerX=i.model.distanceFromCorner+i.model.radius;break;case"middleright":i.centerY=i.model.height/2+i.model.radius/2;i.centerX=i.model.width-(i.model.distanceFromCorner+i.model.radius);break;case"bottomleft":i.centerY=i.model.height-i.model.distanceFromCorner;i.centerX=i.model.distanceFromCorner+i.model.radius;break;case"bottomright":i.centerY=i.model.height-i.model.distanceFromCorner;i.centerX=i.model.width-(i.model.distanceFromCorner+i.model.radius);break;case"bottomcenter":i.centerY=i.model.height-i.model.distanceFromCorner;i.centerX=i.model.width/2}}else if(i.model.frame.halfCircleFrameStartAngle==270&&i.model.frame.halfCircleFrameEndAngle==90)switch(i.model.gaugePosition){case"center":i.centerY=i.model.height/2;i.centerX=i.model.width/2-i.model.radius/2;break;case"topleft":i.centerY=i.model.radius+i.model.distanceFromCorner;i.centerX=i.model.distanceFromCorner;break;case"topright":i.centerY=i.model.radius+i.model.distanceFromCorner;i.centerX=i.model.width-(i.model.radius+i.model.distanceFromCorner);break;case"topcenter":i.centerY=i.model.radius+i.model.distanceFromCorner;i.centerX=i.model.width/2-i.model.radius/2;break;case"middleleft":i.centerY=i.model.height/2;i.centerX=i.model.distanceFromCorner;break;case"middleright":i.centerY=i.model.height/2;i.centerX=i.model.width-(i.model.radius+i.model.distanceFromCorner);break;case"bottomleft":i.centerY=i.model.height-(i.model.radius+i.model.distanceFromCorner);i.centerX=i.model.distanceFromCorner;break;case"bottomright":i.centerY=i.model.height-(i.model.radius+i.model.distanceFromCorner);i.centerX=i.model.width-(i.model.radius+i.model.distanceFromCorner);break;case"bottomcenter":i.centerY=i.model.height-(i.model.radius+i.model.distanceFromCorner);i.centerX=i.model.width/2-i.model.radius/2}else if(i.model.frame.halfCircleFrameEndAngle-i.model.frame.halfCircleFrameStartAngle<=90)if(i.model.frame.halfCircleFrameStartAngle==0)switch(i.model.gaugePosition){case"center":i.centerY=i.model.height/2-i.model.radius/2;i.centerX=i.model.width/2-i.model.radius/2;break;case"topleft":i.centerY=i.model.distanceFromCorner;i.centerX=i.model.distanceFromCorner;break;case"topright":i.centerY=i.model.distanceFromCorner;i.centerX=i.model.width-(i.model.distanceFromCorner+i.model.radius);break;case"topcenter":i.centerY=i.model.distanceFromCorner;i.centerX=i.model.width/2-i.model.radius/2;break;case"middleleft":i.centerY=i.model.height/2-i.model.radius/2;i.centerX=i.model.distanceFromCorner;break;case"middleright":i.centerY=i.model.height/2-i.model.radius/2;i.centerX=i.model.width-(i.model.distanceFromCorner+i.model.radius);break;case"bottomleft":i.centerY=i.model.height-(i.model.distanceFromCorner+i.model.radius);i.centerX=i.model.distanceFromCorner;break;case"bottomright":i.centerY=i.model.height-(i.model.distanceFromCorner+i.model.radius);i.centerX=i.model.width-(i.model.distanceFromCorner+i.model.radius);break;case"bottomcenter":i.centerY=i.model.height-(i.model.distanceFromCorner+i.model.radius);i.centerX=i.model.width/2-i.model.radius/2}else if(i.model.frame.halfCircleFrameStartAngle==90)switch(i.model.gaugePosition){case"center":i.centerY=i.model.height/2-i.model.radius/2;i.centerX=i.model.width/2+i.model.radius/2;break;case"topleft":i.centerY=i.model.distanceFromCorner;i.centerX=i.model.radius+i.model.distanceFromCorner;break;case"topright":i.centerY=i.model.distanceFromCorner;i.centerX=i.model.width-i.model.distanceFromCorner;break;case"topcenter":i.centerY=i.model.distanceFromCorner;i.centerX=i.model.width/2+i.model.radius/2;break;case"middleleft":i.centerY=i.model.height/2-i.model.radius/2;i.centerX=i.model.radius+i.model.distanceFromCorner;break;case"middleright":i.centerY=i.model.height/2-i.model.radius/2;i.centerX=i.model.width-i.model.distanceFromCorner;break;case"bottomleft":i.centerY=i.model.height-(i.model.radius+i.model.distanceFromCorner);i.centerX=i.model.radius+i.model.distanceFromCorner;break;case"bottomright":i.centerY=i.model.height-(i.model.radius+i.model.distanceFromCorner);i.centerX=i.model.width-i.model.distanceFromCorner;break;case"bottomcenter":i.centerY=i.model.height-(i.model.radius+i.model.distanceFromCorner);i.centerX=i.model.width/2+i.model.radius/2}else if(i.model.frame.halfCircleFrameStartAngle==180)switch(i.model.gaugePosition){case"center":i.centerY=i.model.height/2+i.model.radius/2;i.centerX=i.model.width/2+i.model.radius/2;break;case"topleft":i.centerY=i.model.distanceFromCorner+i.model.radius;i.centerX=i.model.radius+i.model.distanceFromCorner;break;case"topright":i.centerY=i.model.distanceFromCorner+i.model.radius;i.centerX=i.model.width-i.model.distanceFromCorner;break;case"topcenter":i.centerY=i.model.distanceFromCorner+i.model.radius;i.centerX=i.model.width/2+i.model.radius/2;break;case"middleleft":i.centerY=i.model.height/2+i.model.radius/2;i.centerX=i.model.radius+i.model.distanceFromCorner;break;case"middleright":i.centerY=i.model.height/2+i.model.radius/2;i.centerX=i.model.width-i.model.distanceFromCorner;break;case"bottomleft":i.centerY=i.model.height-i.model.distanceFromCorner;i.centerX=i.model.radius+i.model.distanceFromCorner;break;case"bottomright":i.centerY=i.model.height-i.model.distanceFromCorner;i.centerX=i.model.width-i.model.distanceFromCorner;break;case"bottomcenter":i.centerY=i.model.height-i.model.distanceFromCorner;i.centerX=i.model.width/2+i.model.radius/2}else if(i.model.frame.halfCircleFrameStartAngle==270)switch(i.model.gaugePosition){case"center":i.centerY=i.model.radius/2+i.model.height/2;i.centerX=i.model.width/2-i.model.radius/2;break;case"topleft":i.centerY=i.model.distanceFromCorner+i.model.radius;i.centerX=i.model.distanceFromCorner;break;case"topright":i.centerY=i.model.distanceFromCorner+i.model.radius;i.centerX=i.model.width-(i.model.distanceFromCorner+i.model.radius);break;case"topcenter":i.centerY=i.model.distanceFromCorner+i.model.radius;i.centerX=i.model.width/2-i.model.radius/2;break;case"middleleft":i.centerY=i.model.height/2+i.model.radius/2;i.centerX=i.model.distanceFromCorner;break;case"middleright":i.centerY=i.model.radius/2+i.model.height/2;i.centerX=i.model.width-(i.model.distanceFromCorner+i.model.radius);break;case"bottomleft":i.centerY=i.model.height-i.model.distanceFromCorner;i.centerX=i.model.distanceFromCorner;break;case"bottomright":i.centerY=i.model.height-i.model.distanceFromCorner;i.centerX=i.model.width-(i.model.distanceFromCorner+i.model.radius);break;case"bottomcenter":i.centerY=i.model.height-i.model.distanceFromCorner;i.centerX=i.model.width/2-i.model.radius/2}(v=i.canvasEl[0],typeof G_vmlCanvasManager!="undefined"&&(v=window.G_vmlCanvasManager.initElement(v)),v&&v.getContext)&&(i.contextEl=i.canvasEl[0].getContext("2d"))},_browserInfo:function(){var n={},t=[],i={webkit:/(chrome)[ \/]([\w.]+)/i,safari:/(webkit)[ \/]([\w.]+)/i,msie:/(msie) ([\w.]+)/i,opera:/(opera)(?:.*version|)[ \/]([\w.]+)/i,mozilla:/(mozilla)(?:.*? rv:([\w.]+)|)/i};for(var r in i)if(i.hasOwnProperty(r)&&(t=navigator.userAgent.match(i[r]),t)){n.name=t[1].toLowerCase();n.version=t[2];!navigator.userAgent.match(/Trident\/7\./)||(n.name="msie");break}return n.isMSPointerEnabled=n.name=="msie"&&n.version>9&&window.navigator.msPointerEnabled,n.pointerEnabled=window.navigator.pointerEnabled,n},_wireEvents:function(){var f=jQuery.uaMatch(navigator.userAgent),r=this._browserInfo(),i=r.isMSPointerEnabled,t=r.pointerEnabled,u;this.startEv=i?t?"pointerdown":"MSPointerDown":"touchstart mousedown";this.endEv=i?t?"pointerup":"MSPointerUp":"touchend mouseup";this.moveEv=i?t?"pointermove":"MSPointerMove":"touchmove mousemove";this.leaveEv=i?t?"pointerleave":"MSPointerOut":"touchleave mouseleave";this.scrollEv=f.browser.toLowerCase()=="mozilla"?t?"mousewheel":"DOMMouseScroll":"mousewheel";this.model.browserInfo=r;u=this.model.readOnly?"pan-y pan-x":"none";n(this.element).css("touch-action",u);this.onMouseMoveHandler=n.proxy(this._onMouseMove,this);this.onMouseUpHandler=n.proxy(this._onMouseUp,this);this.onMouseDownHandler=n.proxy(this._onMouseDown,this);this.onHoverOCustomLabel=n.proxy(this._onHoverOCustomLabel,this);this.onLeaveOCustomLabel=n.proxy(this._onLeaveOCustomLabel,this);this.model.legend.visible&&this._on(n(this.canvasEl),"click",this.legendMouseClick);this._on(n(this.canvasEl),"mousemove",this.rangesMouseMove);(this.model.tooltip.showCustomLabelTooltip||this.model.tooltip.showLabelTooltip)&&(n(this.canvasEl).bind(this.moveEv,this.onMouseMoveHandler),n(this.canvasEl).bind(this.scrollEv,this.onMouseMoveHandler),n(this.canvasEl).bind(this.startEv,this.onMouseDownHandler),n(this.canvasEl).bind(this.endEv,this.onLeaveOCustomLabel),n(this.canvasEl).bind(this.leaveEv,this.onLeaveOCustomLabel));this.model.readOnly||n(this.canvasEl).bind(this.startEv,this.onMouseDownHandler);this.model.tooltip.showCustomLabelTooltip&&(n("."+this._id+"outercustomlbl").bind("mouseenter",this.onHoverOCustomLabel),n("."+this._id+"outercustomlbl").bind("this.leaveEv",this.onLeaveOCustomLabel))},_unWireEvents:function(){n(this.canvasEl).unbind(this.startEv,this.onMouseDownHandler)},_onHoverOCustomLabel:function(n){(n.currentTarget.innerHTML!=null||n.currentTarget.innerHTML!="")&&this._showTooltip(n,n.currentTarget.innerHTML)},_onLeaveOCustomLabel:function(t){this.isTouch(t)?(this._performTooltip(t),window.clearTimeout(this.model.timer),this.model.timer=setTimeout(function(){n(".tooltipDiv").fadeOut(500)},1200)):this._hideTooltip()},isTouch:function(n){var t=n.originalEvent?n.originalEvent:n;return t.pointerType=="touch"||t.pointerType==2||t.type.indexOf("touch")>-1?!0:!1},_showTooltip:function(t,i){var e=this.model.locale,o=e&&this.model.enableGroupSeparator?i.toLocaleString(e):i.toString(),r=n(".tooltipDiv"),s;r.length==0&&(r=n("<div class='tooltipDiv' style='pointer-events:none; position: absolute; z-index: 105; display: block;'><\/div>"),n(document.body).append(r));this.model.tooltip.templateID!=""&&this.model.tooltip.templateID!=null?(s=n("#"+this.model.tooltip.templateID).clone(),n(".tooltipDiv")[0].innerHTML="",n(s).css("display","block").appendTo(r),n(r).css({"pointer-events":"none","background-color":this.model.backgroundColor,border:"1px solid #bbbcbb","border-radius":"3px",color:"#565656"}),r.html(r.html().replace("#label#",o))):(n(r).html(o),n(r).css({"pointer-events":"none","background-color":"white",border:"2px solid #bbbcbb",position:"absolute",padding:"10px 20px","margin-top":"5px","text-align":"left",font:"12px Segoe UI","font-stretch":"condensed",display:"inline-block","border-radius":"3px",color:"#565656",width:"auto"}));var h=10,u=t.pageX+h,f=t.pageY+h;u=u+n(r).width()<this.model.width?u:u-n(r).width();f=f+n(r).height()<this.model.height?f:f-n(r).height();n(r).css("left",u);n(r).css("top",f);n(".tooltipDiv").show()},_hideTooltip:function(){n(".tooltipDiv").remove()},_onMouseDown:function(t){this._blockDefaultActions(t);this._mouseDown=!0;var s=this.isTouch(t)?10:0,o=t.originalEvent.touches?t.originalEvent.touches[0]:t,u={x:this.centerX,y:this.centerY},f={x:o.pageX-n(this.canvasEl).offset().left,y:o.pageY-n(this.canvasEl).offset().top},h=180*this._getCirucumferenceAngle(u,f)/Math.PI,r,e,i=this;this.model.readOnly||n.each(this.model.scales,function(t,o){i.scaleIndex=t;o.pointers!=null&&(i.pointerEl=o.pointers,r=o.radius,e=o.ticks[0].height,n.each(o.pointers,function(t,c){var l;i._isHalfCircle()&&(o.showBackNeedle=!1);l=i._getAngle(c.value);l>360&&(l=l-360);var v=l+c.width,y=l-c.width,a=Math.sqrt((f.x-u.x)*(f.x-u.x)+(f.y-u.y)*(f.y-u.y)),p=a<(c.placement=="far"?r+c.width+c.distanceFromScale:c.placement=="center"?r-c.distanceFromScale:r-15-e-c.distanceFromScale)&&a>(c.placement=="far"?r+c.distanceFromScale:c.placement=="center"?r-c.width-c.distanceFromScale:r-c.width-15-e-c.distanceFromScale),w=c.type=="needle"?a<=c.length:p;i._isBetween(y,v,h,s)&&w&&(i._onMouseClick(l,o.value),i.activeElement=c,n(document).bind(i.moveEv,i.onMouseMoveHandler),n(document).bind(i.endEv,i.onMouseUpHandler))}))})},_onMouseUp:function(){this._mouseDown=!1;n(document).unbind(self.moveEv,self.onMouseMoveHandler);n(document).unbind(self.endEv,self.onMouseUpHandler);this.activeElement&&this._onMouseClickUp(this._getAngle(this.activeElement.value),this.activeElement.value);this.activeElement=null},_mousePosition:function(n){if(!t.util.isNullOrUndefined(n.pageX)&&n.pageX>0)return{x:n.pageX,y:n.pageY};if(n.originalEvent&&!t.util.isNullOrUndefined(n.originalEvent.pageX)&&n.originalEvent.pageX>0)return{x:n.originalEvent.pageX,y:n.originalEvent.pageY};if(n.originalEvent&&n.originalEvent.changedTouches!=i){if(!t.util.isNullOrUndefined(n.originalEvent.changedTouches[0].pageX)&&n.originalEvent.changedTouches[0].pageX>0)return{x:n.originalEvent.changedTouches[0].pageX,y:n.originalEvent.changedTouches[0].pageY}}else return{x:0,y:0}},_calTouchPosition:function(n){var i=jQuery.uaMatch(navigator.userAgent),t=this._mousePosition(n);n.pageX=t.x;n.pageY=t.y},getEvent:function(n){return n.targetTouches&&n.targetTouches[0]?n.targetTouches[0]:n},_onMouseMove:function(i){if(this._mouseDown&&!t.isNullOrUndefined(this.activeElement)){this._blockDefaultActions(i);var f={x:this.centerX,y:this.centerY},u=i.originalEvent.touches?i.originalEvent.touches[0]:i,e={x:u.pageX-n(this.canvasEl).offset().left,y:u.pageY-n(this.canvasEl).offset().top},r=180*this._getCirucumferenceAngle(f,e)/Math.PI;r<this.scaleEl[this.scaleIndex].startAngle&&!this._isHalfCircle()&&(r=r+360);this._onMouseClickMove(this._getAngle(this.activeElement.value),this.activeElement.value);this._getValue(r)<=this.scaleEl[this.scaleIndex].maximum&&(this.activeElement.value=this.scaleEl[this.scaleIndex].direction=="clockwise"?this._getValue(r):this.scaleEl[this.scaleIndex].maximum-this._getValue(r));this.contextEl.putImageData?this._reDrawPointer():this._init()}else(this.model.tooltip.showCustomLabelTooltip||this.model.tooltip.showLabelTooltip)&&!this.isTouch(i)&&this._performTooltip(i)},_performTooltip:function(t){for(var r,u=!1,f=10,o=this.isTouch(t),i=0;this._savedPoints[i]!=null;i++)if(o){var c=this._calTouchPosition(t),e=this.getEvent(t),s=e.pageX,h=e.pageY,r={X:s-n(this.canvasEl).offset().left,Y:h-n(this.canvasEl).offset().top};r.X>this._savedPoints[i].startX-f&&r.X<this._savedPoints[i].startX+this._savedPoints[i].width+f&&r.Y>this._savedPoints[i].startY-f&&r.Y<this._savedPoints[i].startY+this._savedPoints[i].height+f?(this._showTooltip(t,this._savedPoints[i].value),u=!0):u==!1&&this._hideTooltip()}else r={X:t.pageX-n(this.canvasEl).offset().left,Y:t.pageY-n(this.canvasEl).offset().top},r.X>this._savedPoints[i].startX&&r.X<this._savedPoints[i].startX+this._savedPoints[i].width&&r.Y>this._savedPoints[i].startY&&r.Y<this._savedPoints[i].startY+this._savedPoints[i].height?(this._showTooltip(t,this._savedPoints[i].value),u=!0):u==!1&&this._hideTooltip()},_isHalfCircle:function(){return this.model.frame.frameType=="halfcircle"?!0:!1},_calFontLength:function(t){var i=this.model.scales[0].minimum+this.model.scales[0].labels[0].unitText,r=this.model.scales[0].maximum+this.model.scales[0].labels[0].unitText,u=r.length>i.length?r:i,f=n('<span id="test"><\/span>').css({font:t,display:"none",whiteSpace:"nowrap"}).appendTo(n("body")).text(u).width();return n("#test").remove(),f/2},_getHalfCircleYPosition:function(){return this._getYCordinate(this.centerY,0,(this.model.frame.halfCircleFrameStartAngle+this.model.frame.halfCircleFrameEndAngle)/2)},_getHalfCircleXPosition:function(){return this._getXCordinate(this.centerX,0,(this.model.frame.halfCircleFrameStartAngle+this.model.frame.halfCircleFrameEndAngle)/2)},_getXCordinate:function(n,t,i){return n+t*Math.cos(Math.PI*(i/180))},_getYCordinate:function(n,t,i){return n+t*Math.sin(Math.PI*(i/180))},_getAngle:function(n){var t;return t=n>=this.scaleEl[this.scaleIndex].minimum&&n<=this.scaleEl[this.scaleIndex].maximum?this.scaleEl[this.scaleIndex].direction=="clockwise"?n-this.scaleEl[this.scaleIndex].minimum:this.scaleEl[this.scaleIndex].maximum-n:this.scaleEl[this.scaleIndex].direction=="clockwise"?n<=this.scaleEl[this.scaleIndex].minimum?this.scaleEl[this.scaleIndex].minimum:this.scaleEl[this.scaleIndex].maximum:n<=this.scaleEl[this.scaleIndex].minimum?this.scaleEl[this.scaleIndex].maximum:this.scaleEl[this.scaleIndex].minimum,t*(this.scaleEl[this.scaleIndex].sweepAngle/(this.scaleEl[this.scaleIndex].maximum-this.scaleEl[this.scaleIndex].minimum))+this.scaleEl[this.scaleIndex].startAngle},_subtractDecimal:function(n,t){var r=n.toString(),u=t.toString(),f,e,i,o;return f=r.indexOf(".")>-1?r.length-r.indexOf(".")-1:0,e=u.indexOf(".")>-1?u.length-u.indexOf(".")-1:0,i=f>e?f:e,o=(n*Math.pow(10,i)-t*Math.pow(10,i))/Math.pow(10,i),o},_getCirucumferenceAngle:function(n,t){return t.x>n.x?t.y>n.y?this._tangent(n,t):t.y==n.y?0:2*Math.PI+this._tangent(n,t):t.x==n.x?t.y==n.y?0:t.y>n.y?Math.PI/2:1.5*Math.PI:t.y==n.y?Math.PI:t.y>n.y?Math.PI+this._tangent(n,t):Math.PI+this._tangent(n,t)},_calcDistanceFactor:function(n,t,i){var r;return r=n>240&&n<=300||n>60&&n<=120?0:n>330&&n<=360||n>=0&&n<=30?-i*.5:n>30&&n<=60||n>300&&n<=330?-i/2:n>150&&n<=210?i*.5:i/2,t=="far"?-r:r},_tangent:function(n,t){var i=(t.y-n.y)/(t.x-n.x);return Math.atan(i)},_getValue:function(n){return this.scaleEl[this.scaleIndex].direction=="counterclockwise"?(n-this.scaleEl[this.scaleIndex].startAngle)/this.scaleEl[this.scaleIndex].sweepAngle*(this.scaleEl[this.scaleIndex].maximum-this.scaleEl[this.scaleIndex].minimum):(n-this.scaleEl[this.scaleIndex].startAngle)/this.scaleEl[this.scaleIndex].sweepAngle*(this.scaleEl[this.scaleIndex].maximum-this.scaleEl[this.scaleIndex].minimum)+this.scaleEl[this.scaleIndex].minimum},_drawScales:function(){var r=this,u,i,f,t;if(this.scaleEl=this.model.scales,n.each(this.model.scales,function(n,t){r.scaleIndex=n;t.showScaleBar&&r._setScaleCordinates(t)}),this.model.rangeZOrder=="rear"?(this._setRanges(),this._setTicks()):(this._setTicks(),this._setRanges()),this._setLabels(),this._subGauge(),this._setCustomLabel(),this._setPointers(),this.contextEl.putImageData||(this.model.enableAnimation=!1),this.model.animationSpeed!=null&&this.model.animationSpeed>0&&(u=this.model.animationSpeed/25,u>=0&&(i=navigator.userAgent.toLowerCase(),f=i.indexOf("msie")!=-1?parseInt(i.split("msie")[1]):0,this.model.enableAnimation&&f!=9))){for(t=0;t<this.model.scales[0].pointers.length;t++)this.pointerValue=[],this.currentValue=[],this.pointerValue[t]=null,this.currentValue[t]=null,this.updatePointerOnAnimation=!1;this.dt=(new Date).getTime();this._onAnimate(this)}this._setIndicators()},_setTicks:function(){var t=this;n.each(this.model.scales,function(i,r){r.showTicks&&(t.scaleIndex=i,r.ticks!=null&&(t.tickEl=r.ticks,n.each(r.ticks,function(n,i){t.tickIndex=n;t._setTicksCordinates(n,i)})))})},_setLabels:function(){var t=this;n.each(this.model.scales,function(i,r){r.showLabels&&(t.scaleIndex=i,r.labels!=null&&(t.labelEl=r.labels,n.each(r.labels,function(n,i){t.labelIndex=n;t._setLabelCoridnates(n,i)})))})},_setIndicators:function(){var t=this;n.each(this.model.scales,function(i,r){r.showIndicators&&(t.scaleIndex=i,r.indicators!=null&&(t.indicatorEl=r.indicators,n.each(r.indicators,function(n,i){t.indicatorIndex=n;t._drawIndicator(n,i)})))})},_setPointers:function(){var t=this;n.each(this.model.scales,function(i,r){r.showPointers&&(t.scaleIndex=i,r.pointers!=null&&(t.pointerEl=r.pointers,n.each(r.pointers,function(n,i){t._isHalfCircle()&&(r.showBackNeedle=!1);t.pointerIndex=n;t._drawPointers(n,i)})))})},_onAnimate:function(n){if(!this._androidAnimation&&!t.util.isNullOrUndefined(n.model)){for(var o=n,i=o,l=i.model.animationSpeed/25,u,f,s,h,c,a=n.model.scales[0].pointers.length,e=[],r=0;r<a;r++)e[r]=!0,i.model.scales[0].pointers[r]._value||(i.model.scales[0].pointers[r]._value=i.model.scales[0].pointers[r].value),i.pointerValue[r]=t.util.isNullOrUndefined(i.pointerValue[r])?i.model.scales[0].pointers[r]._value:i.pointerValue[r],i.currentValue[r]=t.util.isNullOrUndefined(i.currentValue[r])?i.model.scales[0].minimum:i.currentValue[r],u=i.pointerValue[r],s=(new Date).getTime(),h=s-i.dt,h>l&&u>i.currentValue[r]?(i.currentValue[r]=i.currentValue[r]+(i.model.scales[0].maximum-i.model.scales[0].minimum)/100,i.updatePointerOnAnimation=!0,u>i.currentValue[r]?i.setPointerValue(0,r,i.currentValue[r]):i.setPointerValue(0,r,u),i.dt=s-h%l):i.currentValue>=u&&(e[r]=!1);for(f=0;f<e.length;f++)if(c=e[f],c)break;c&&requestAnimationFrame(function(){o._onAnimate(o)})}},_pointInterval:function(n,t,i,r){this.timer=setTimeout(function(){t>n?(n=n+(r.model.