summaryrefslogtreecommitdiffstats
path: root/tools/qtestlib/chart/3rdparty/flotr.js
blob: 80bb506fd3f982eea612b85c78b0d022a9bd9a7c (plain)
1
2
//Flotr 0.1.0alpha Copyright (c) 2008 Bas Wenneker, <http://solutoire.com>, MIT License.
var Flotr=(function(){var C=0;function L(M){return M.collect(function(N){return(N.data)?Object.clone(N):{data:N}})}function G(P,N){var M=N||{};for(var O in P){M[O]=(typeof (P[O])=="object"&&!(P[O].constructor==Array||P[O].constructor==RegExp))?G(P[O],N[O]):M[O]=P[O]}return M}function I(Q,P,M,N){var T=(M-P)/Q;var S=H(T);var O=T/S;var R=10;if(O<1.5){R=1}else{if(O<2.25){R=2}else{if(O<3){R=2.5}else{if(O<7.5){R=5}}}}if(R==2.5&&N==0){R=2}R*=S;return R}function E(M){return M.toString()}function F(M){return"("+M.x+", "+M.y+")"}function H(M){return Math.pow(10,Math.floor(Math.log(M)/Math.LN10))}function K(O){var M;if((M=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(O))){return new B(parseInt(M[1]),parseInt(M[2]),parseInt(M[3]))}if((M=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(O))){return new B(parseInt(M[1]),parseInt(M[2]),parseInt(M[3]),parseFloat(M[4]))}if((M=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(O))){return new B(parseFloat(M[1])*2.55,parseFloat(M[2])*2.55,parseFloat(M[3])*2.55)}if((M=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(O))){return new B(parseFloat(M[1])*2.55,parseFloat(M[2])*2.55,parseFloat(M[3])*2.55,parseFloat(M[4]))}if((M=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(O))){return new B(parseInt(M[1],16),parseInt(M[2],16),parseInt(M[3],16))}if((M=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(O))){return new B(parseInt(M[1]+M[1],16),parseInt(M[2]+M[2],16),parseInt(M[3]+M[3],16))}var N=O.strip().toLowerCase();if(N=="transparent"){return new B(255,255,255,0)}M=D[N];return new B(M[0],M[1],M[2])}function A(N){var M;do{M=N.getStyle("background-color").toLowerCase();if(M!=""&&M!="transparent"){break}N=N.up(0)}while(N.nodeName.toLowerCase()!="body");if(M=="rgba(0, 0, 0, 0)"){return"transparent"}return M}function B(S,R,N,P){var Q=["r","g","b","a"];var M=4;while(-1<--M){this[Q[M]]=arguments[M]||((M==3)?1:0)}this.toString=function(){return(this.a>=1)?"rgb("+[this.r,this.g,this.b].join(",")+")":"rgba("+[this.r,this.g,this.b,this.a].join(",")+")"};this.scale=function(V,U,W,T){M=4;while(-1<--M){if(arguments[M]!=null){this[Q[M]]*=arguments[M]}}return this.normalize()};this.adjust=function(V,U,W,T){M=4;while(-1<--M){if(arguments[M]!=null){this[Q[M]]+=arguments[M]}}return this.normalize()};this.clone=function(){return new B(this.r,this.b,this.g,this.a)};var O=function(U,T,V){return Math.max(Math.min(U,V),T)};this.normalize=function(){this.r=O(parseInt(this.r),0,255);this.g=O(parseInt(this.g),0,255);this.b=O(parseInt(this.b),0,255);this.a=O(this.a,0,1);return this};this.normalize()}var D={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]};function J(y,AO,p){var o,S,AL,h,AS;var z="flotr-"+C++;var R=L(AO);var N=y;var u={},c={};var l={left:0,right:0,top:0,bottom:0};var AA=0;var d=0;var AH=0;var U=0;var P=0;var AD=0;var AC=0;var AB=0;g(p);k();AN();q();AK(u,o.xaxis);Z();AK(c,o.yaxis);m(u,o.xaxis);m(c,o.yaxis);Y();AP();AQ();this.getCanvas=function(){return S};this.getPlotOffset=function(){return l};this.clearSelection=M;this.setSelection=AF;function g(AV){o=G(AV,{colors:["#00A8F0","#C0D800","#cb4b4b","#4da74d","#9440ed"],legend:{show:true,noColumns:1,labelFormatter:null,labelBoxBorderColor:"#ccc",container:null,position:"ne",margin:5,backgroundColor:null,backgroundOpacity:0.85},xaxis:{ticks:null,noTicks:5,tickFormatter:E,tickDecimals:null,min:null,max:null,autoscaleMargin:0},yaxis:{ticks:null,noTicks:5,tickFormatter:E,tickDecimals:null,min:null,max:null,autoscaleMargin:0},points:{show:false,radius:3,lineWidth:2,fill:true,fillColor:"#ffffff"},lines:{show:false,lineWidth:2,fill:false,fillColor:null},bars:{show:false,lineWidth:2,barWidth:1,fill:true,fillColor:null},grid:{color:"#545454",backgroundColor:null,tickColor:"#dddddd",labelMargin:3},selection:{mode:null,color:"#B6D9FF",fps:10},mouse:{track:null,position:"se",trackFormatter:F,margin:3,color:"#ff3f19",trackDecimals:1,sensibility:2,radius:3},shadowSize:4});var Ah=R.length;var AT=[];var AZ=[];for(var Ac=0;Ac<R.length;++Ac){var Ag=R[Ac].color;if(Ag!=null){--Ah;if(Object.isNumber(Ag)){AZ.push(Ag)}else{AT.push(K(R[Ac].color))}}}for(var Ab=0;Ab<AZ.length;++Ab){Ah=Math.max(Ah,AZ[Ab]+1)}var AU=[];var AY=0;var Aa=0;while(AU.length<Ah){var Af=(o.colors.length==Aa)?new B(100,100,100):K(o.colors[Aa]);var AW=AY%2==1?-1:1;var Ae=1+AW*Math.ceil(AY/2)*0.2;Af.scale(Ae,Ae,Ae);AU.push(Af);if(++Aa>=o.colors.length){Aa=0;++AY}}var Ad=0;for(var AX=0,Ai;AX<R.length;++AX){Ai=R[AX];if(Ai.color==null){Ai.color=AU[Ad].toString();++Ad}else{if(Object.isNumber(Ai.color)){Ai.color=AU[Ai.color].toString()}}Ai.lines=Object.extend(Object.clone(o.lines),Ai.lines);Ai.points=Object.extend(Object.clone(o.points),Ai.points);Ai.bars=Object.extend(Object.clone(o.bars),Ai.bars);Ai.mouse=Object.extend(Object.clone(o.mouse),Ai.mouse);if(Ai.shadowSize==null){Ai.shadowSize=o.shadowSize}}}function k(){AH=N.getWidth();U=N.getHeight();N.innerHTML="";N.setStyle({position:"relative"});if(AH<=0||U<=0){throw"Invalid dimensions for plot, width = "+AH+", height = "+U}S=$(document.createElement("canvas")).writeAttribute({width:AH,height:U});N.appendChild(S);if(Prototype.Browser.IE){S=$(window.G_vmlCanvasManager.initElement(S))}h=S.getContext("2d");AL=$(document.createElement("canvas")).writeAttribute({width:AH,height:U}).setStyle({position:"absolute",left:"0px",top:"0px"});N.setStyle({cursor:"default"}).appendChild(AL);if(Prototype.Browser.IE){AL=$(window.G_vmlCanvasManager.initElement(AL))}AS=AL.getContext("2d")}function AN(){if(o.selection.mode!=null){AL.observe("mousedown",r)}AL.observe("mousemove",e);AL.observe("click",f)}function q(){c.datamin=u.datamin=0;u.datamax=c.datamax=1;if(R.length==0){return }var AY=false;for(var AV=0;AV<R.length;++AV){if(R[AV].data.length>0){u.datamin=u.datamax=R[AV].data[0][0];c.datamin=c.datamax=R[AV].data[0][1];AY=true;break}}if(!AY){return }for(var AU=0;AU<R.length;++AU){var AX=R[AU].data;for(var AW=0;AW<AX.length;++AW){var AT=AX[AW][0];var AZ=AX[AW][1];if(AT<u.datamin){u.datamin=AT}else{if(AT>u.datamax){u.datamax=AT}}if(AZ<c.datamin){c.datamin=AZ}else{if(AZ>c.datamax){c.datamax=AZ}}}}}function AK(AW,AY){var AV=AY.min!=null?AY.min:AW.datamin;var AT=AY.max!=null?AY.max:AW.datamax;if(AT-AV==0){var AU=(AT==0)?1:0.01;AV-=AU;AT+=AU}AW.tickSize=I(AY.noTicks,AV,AT,AY.tickDecimals);var AX;if(AY.min==null){AX=AY.autoscaleMargin;if(AX!=0){AV-=AW.tickSize*AX;if(AV<0&&AW.datamin>=0){AV=0}AV=AW.tickSize*Math.floor(AV/AW.tickSize)}}if(AY.max==null){AX=AY.autoscaleMargin;if(AX!=0){AT+=AW.tickSize*AX;if(AT>0&&AW.datamax<=0){AT=0}AT=AW.tickSize*Math.ceil(AT/AW.tickSize)}}AW.min=AV;AW.max=AT}function Z(){if(o.xaxis.max==null){var AU=u.max;for(var AT=0;AT<R.length;++AT){if(R[AT].bars.show&&R[AT].bars.barWidth+u.datamax>AU){AU=u.max+R[AT].bars.barWidth}}u.max=AU}}function m(AV,AW){AV.ticks=[];if(AW.ticks){var AZ=AW.ticks;if(Object.isFunction(AZ)){AZ=AZ({min:AV.min,max:AV.max})}for(var AX=0,Aa,AY;AX<AZ.length;++AX){var Ab=AZ[AX];if(typeof (Ab)=="object"){Aa=Ab[0];AY=(Ab.length>1)?Ab[1]:AW.tickFormatter(Aa)}else{Aa=Ab;AY=AW.tickFormatter(Aa)}AV.ticks[AX]={v:Aa,label:AY}}}else{var AT=AV.tickSize*Math.ceil(AV.min/AV.tickSize);for(AX=0;AT+AX*AV.tickSize<=AV.max;++AX){Aa=AT+AX*AV.tickSize;var AU=AW.tickDecimals;if(AU==null){AU=1-Math.floor(Math.log(AV.tickSize)/Math.LN10)}if(AU<0){AU=0}Aa=Aa.toFixed(AU);AV.ticks.push({v:Aa,label:AW.tickFormatter(Aa)})}}}function Y(){var AX="";for(var AW=0;AW<c.ticks.length;++AW){var AU=c.ticks[AW].label.length;if(AU>AX.length){AX=c.ticks[AW].label}}var AT=N.insert('<div style="position:absolute;top:-10000px;font-size:smaller" class="flotr-grid-label">'+AX+"</div>").down(0).next(1);AA=AT.getWidth();d=AT.getHeight();AT.remove();var AY=2;if(o.points.show){AY=Math.max(AY,o.points.radius+o.points.lineWidth/2)}for(var AV=0;AV<R.length;++AV){if(R[AV].points.show){AY=Math.max(AY,R[AV].points.radius+R[AV].points.lineWidth/2)}}l.left=l.right=l.top=l.bottom=AY;l.left+=AA+o.grid.labelMargin;l.bottom+=d+o.grid.labelMargin;P=AH-l.left-l.right;AD=U-l.bottom-l.top;AC=P/(u.max-u.min);AB=AD/(c.max-c.min)}function AP(){V();AR();for(var AT=0;AT<R.length;AT++){AI(R[AT])}}function AE(AT){return(AT-u.min)*AC}function j(AT){return AD-(AT-c.min)*AB}function V(){h.save();h.translate(l.left,l.top);if(o.grid.backgroundColor!=null){h.fillStyle=o.grid.backgroundColor;h.fillRect(0,0,P,AD)}h.lineWidth=1;h.strokeStyle=o.grid.tickColor;h.beginPath();for(var AV=0,AT=null;AV<u.ticks.length;++AV){AT=u.ticks[AV].v;if(AT==u.min||AT==u.max){continue}h.moveTo(Math.floor(AE(AT))+h.lineWidth/2,0);h.lineTo(Math.floor(AE(AT))+h.lineWidth/2,AD)}for(var AU=0,AT=null;AU<c.ticks.length;++AU){AT=c.ticks[AU].v;if(AT==c.min||AT==c.max){continue}h.moveTo(0,Math.floor(j(AT))+h.lineWidth/2);h.lineTo(P,Math.floor(j(AT))+h.lineWidth/2)}h.stroke();h.lineWidth=2;h.strokeStyle=o.grid.color;h.lineJoin="round";h.strokeRect(0,0,P,AD);h.restore()}function AR(){var AZ=0;for(var AY=0;AY<u.ticks.length;++AY){if(u.ticks[AY].label){++AZ}}var AU=P/AZ;var AX='<div style="font-size:smaller;color:'+o.grid.color+'">';for(var AV=0,AW=null;AV<u.ticks.length;++AV){AW=u.ticks[AV];if(!AW.label){continue}AX+='<div style="position:absolute;top:'+(l.top+AD+o.grid.labelMargin)+"px;left:"+(l.left+AE(AW.v)-AU/2)+"px;width:"+AU+'px;text-align:center" class="flotr-grid-label">'+AW.label+"</div>"}for(var AT=0,AW=null;AT<c.ticks.length;++AT){AW=c.ticks[AT];if(!AW.label||AW.label.length==0){continue}AX+='<div style="position:absolute;top:'+(l.top+j(AW.v)-d/2)+"px;left:0;width:"+AA+'px;text-align:right" class="flotr-grid-label">'+AW.label+"</div>"}AX+="</div>";N.insert(AX)}function AI(AT){if(AT.lines.show||(!AT.bars.show&&!AT.points.show)){i(AT)}if(AT.bars.show){v(AT)}if(AT.points.show){w(AT)}}function i(AV){function AU(Ad,Ac){if(Ad.length<2){return }var Ab=AE(Ad[0][0]),Aa=j(Ad[0][1])+Ac;h.beginPath();h.moveTo(Ab,Aa);for(var Ae=0;Ae<Ad.length-1;++Ae){var AZ=Ad[Ae][0],Ag=Ad[Ae][1],AY=Ad[Ae+1][0],Af=Ad[Ae+1][1];if(Ag<=Af&&Ag<c.min){if(Af<c.min){continue}AZ=(c.min-Ag)/(Af-Ag)*(AY-AZ)+AZ;Ag=c.min}else{if(Af<=Ag&&Af<c.min){if(Ag<c.min){continue}AY=(c.min-Ag)/(Af-Ag)*(AY-AZ)+AZ;Af=c.min}}if(Ag>=Af&&Ag>c.max){if(Af>c.max){continue}AZ=(c.max-Ag)/(Af-Ag)*(AY-AZ)+AZ;Ag=c.max}else{if(Af>=Ag&&Af>c.max){if(Ag>c.max){continue}AY=(c.max-Ag)/(Af-Ag)*(AY-AZ)+AZ;Af=c.max}}if(AZ<=AY&&AZ<u.min){if(AY<u.min){continue}Ag=(u.min-AZ)/(AY-AZ)*(Af-Ag)+Ag;AZ=u.min}else{if(AY<=AZ&&AY<u.min){if(AZ<u.min){continue}Af=(u.min-AZ)/(AY-AZ)*(Af-Ag)+Ag;AY=u.min}}if(AZ>=AY&&AZ>u.max){if(AY>u.max){continue}Ag=(u.max-AZ)/(AY-AZ)*(Af-Ag)+Ag;AZ=u.max}else{if(AY>=AZ&&AY>u.max){if(AZ>u.max){continue}Af=(u.max-AZ)/(AY-AZ)*(Af-Ag)+Ag;AY=u.max}}if(Ab!=AE(AZ)||Aa!=j(Ag)+Ac){h.moveTo(AE(AZ),j(Ag)+Ac)}Ab=AE(AY);Aa=j(Af)+Ac;h.lineTo(Ab,Aa)}h.stroke()}function AW(Ac){if(Ac.length<2){return }var AY=Math.min(Math.max(0,c.min),c.max);var Ah,Aa=0;var Ae=true;h.beginPath();for(var Ad=0;Ad<Ac.length-1;++Ad){var Ab=Ac[Ad][0],Ai=Ac[Ad][1],AZ=Ac[Ad+1][0],Ag=Ac[Ad+1][1];if(Ab<=AZ&&Ab<u.min){if(AZ<u.min){continue}Ai=(u.min-Ab)/(AZ-Ab)*(Ag-Ai)+Ai;Ab=u.min}else{if(AZ<=Ab&&AZ<u.min){if(Ab<u.min){continue}Ag=(u.min-Ab)/(AZ-Ab)*(Ag-Ai)+Ai;AZ=u.min}}if(Ab>=AZ&&Ab>u.max){if(AZ>u.max){continue}Ai=(u.max-Ab)/(AZ-Ab)*(Ag-Ai)+Ai;Ab=u.max}else{if(AZ>=Ab&&AZ>u.max){if(Ab>u.max){continue}Ag=(u.max-Ab)/(AZ-Ab)*(Ag-Ai)+Ai;AZ=u.max}}if(Ae){h.moveTo(AE(Ab),j(AY));Ae=false}if(Ai>=c.max&&Ag>=c.max){h.lineTo(AE(Ab),j(c.max));h.lineTo(AE(AZ),j(c.max));continue}else{if(Ai<=c.min&&Ag<=c.min){h.lineTo(AE(Ab),j(c.min));h.lineTo(AE(AZ),j(c.min));continue}}var Aj=Ab,Af=AZ;if(Ai<=Ag&&Ai<c.min&&Ag>=c.min){Ab=(c.min-Ai)/(Ag-Ai)*(AZ-Ab)+Ab;Ai=c.min}else{if(Ag<=Ai&&Ag<c.min&&Ai>=c.min){AZ=(c.min-Ai)/(Ag-Ai)*(AZ-Ab)+Ab;Ag=c.min}}if(Ai>=Ag&&Ai>c.max&&Ag<=c.max){Ab=(c.max-Ai)/(Ag-Ai)*(AZ-Ab)+Ab;Ai=c.max}else{if(Ag>=Ai&&Ag>c.max&&Ai<=c.max){AZ=(c.max-Ai)/(Ag-Ai)*(AZ-Ab)+Ab;Ag=c.max}}if(Ab!=Aj){Ah=(Ai<=c.min)?Ah=c.min:c.max;h.lineTo(AE(Aj),j(Ah));h.lineTo(AE(Ab),j(Ah))}h.lineTo(AE(Ab),j(Ai));h.lineTo(AE(AZ),j(Ag));if(AZ!=Af){Ah=(Ag<=c.min)?c.min:c.max;h.lineTo(AE(Af),j(Ah));h.lineTo(AE(AZ),j(Ah))}Aa=Math.max(AZ,Af)}h.lineTo(AE(Aa),j(AY));h.closePath();h.fill()}h.save();h.translate(l.left,l.top);h.lineJoin="round";var AX=AV.lines.lineWidth;var AT=AV.shadowSize;if(AT>0){h.lineWidth=AT/2;h.strokeStyle="rgba(0,0,0,0.1)";AU(AV.data,AX/2+AT/2+h.lineWidth/2);h.lineWidth=AT/2;h.strokeStyle="rgba(0,0,0,0.2)";AU(AV.data,AX/2+h.lineWidth/2)}h.lineWidth=AX;h.strokeStyle=AV.color;if(AV.lines.fill){h.fillStyle=AV.lines.fillColor!=null?AV.lines.fillColor:K(AV.color).scale(null,null,null,0.4).toString();AW(AV.data,0)}AU(AV.data,0);h.restore()}function w(AU){function AX(Ab,AZ,Ac){for(var Aa=0;Aa<Ab.length;++Aa){var AY=Ab[Aa][0],Ad=Ab[Aa][1];if(AY<u.min||AY>u.max||Ad<c.min||Ad>c.max){continue}h.beginPath();h.arc(AE(AY),j(Ad),AZ,0,2*Math.PI,true);if(Ac){h.fill()}h.stroke()}}function AW(Ab,Ac,AZ){for(var Aa=0;Aa<Ab.length;++Aa){var AY=Ab[Aa][0],Ad=Ab[Aa][1];if(AY<u.min||AY>u.max||Ad<c.min||Ad>c.max){continue}h.beginPath();h.arc(AE(AY),j(Ad)+Ac,AZ,0,Math.PI,false);h.stroke()}}h.save();h.translate(l.left,l.top);var AV=AU.lines.lineWidth;var AT=AU.shadowSize;if(AT>0){h.lineWidth=AT/2;h.strokeStyle="rgba(0,0,0,0.1)";AW(AU.data,AT/2+h.lineWidth/2,AU.points.radius);h.lineWidth=AT/2;h.strokeStyle="rgba(0,0,0,0.2)";AW(AU.data,h.lineWidth/2,AU.points.radius)}h.lineWidth=AU.points.lineWidth;h.strokeStyle=AU.color;h.fillStyle=AU.points.fillColor!=null?AU.points.fillColor:AU.color;AX(AU.data,AU.points.radius,AU.points.fill);h.restore()}function v(AU){function AT(Ab,Ak,AZ,Aj){if(Ab.length<2){return }for(var Ac=0;Ac<Ab.length;Ac++){var Ag=Ab[Ac][0],Af=Ab[Ac][1];var Ai=true,Aa=true,Ad=true;var AY=Ag,Ah=Ag+Ak,AX=0,Ae=Af;if(Ah<u.min||AY>u.max||Ae<c.min||AX>c.max){continue}if(AY<u.min){AY=u.min;Ai=false}if(Ah>u.max){Ah=u.max;Ad=false}if(AX<c.min){AX=c.min}if(Ae>c.max){Ae=c.max;Aa=false}if(Aj){h.beginPath();h.moveTo(AE(AY),j(AX)+AZ);h.lineTo(AE(AY),j(Ae)+AZ);h.lineTo(AE(Ah),j(Ae)+AZ);h.lineTo(AE(Ah),j(AX)+AZ);h.fill()}if(Ai||Ad||Aa){h.beginPath();h.moveTo(AE(AY),j(AX)+AZ);if(Ai){h.lineTo(AE(AY),j(Ae)+AZ)}else{h.moveTo(AE(AY),j(Ae)+AZ)}if(Aa){h.lineTo(AE(Ah),j(Ae)+AZ)}else{h.moveTo(AE(Ah),j(Ae)+AZ)}if(Ad){h.lineTo(AE(Ah),j(AX)+AZ)}else{h.moveTo(AE(Ah),j(AX)+AZ)}h.stroke()}}}h.save();h.translate(l.left,l.top);h.lineJoin="round";var AW=AU.bars.barWidth;var AV=Math.min(AU.bars.lineWidth,AW);h.lineWidth=AV;h.strokeStyle=AU.color;if(AU.bars.fill){h.fillStyle=AU.bars.fillColor!=null?AU.bars.fillColor:K(AU.color).scale(null,null,null,0.4).toString()}AT(AU.data,AW,0,AU.bars.fill);h.restore()}function AQ(){if(!o.legend.show){return }var Aa=[];var AY=false;for(var AX=0;AX<R.length;++AX){if(!R[AX].label){continue}if(AX%o.legend.noColumns==0){Aa.push((AY)?"</tr><tr>":"<tr>");AY=true}var Ac=R[AX].label;if(o.legend.labelFormatter!=null){Ac=o.legend.labelFormatter(Ac)}Aa.push('<td class="flotr-legend-color-box"><div style="border:1px solid '+o.legend.labelBoxBorderColor+';padding:1px"><div style="width:14px;height:10px;background-color:'+R[AX].color+'"></div></div></td><td class="flotr-legend-label">'+Ac+"</td>")}if(AY){Aa.push("</tr>")}if(Aa.length>0){var Ad='<table style="font-size:smaller;color:'+o.grid.color+'">'+Aa.join("")+"</table>";if(o.legend.container!=null){o.legend.container.append(Ad)}else{var Ab="";var AU=o.legend.position,AV=o.legend.margin;if(AU.charAt(0)=="n"){Ab+="top:"+(AV+l.top)+"px;"}else{if(AU.charAt(0)=="s"){Ab+="bottom:"+(AV+l.bottom)+"px;"}}if(AU.charAt(1)=="e"){Ab+="right:"+(AV+l.right)+"px;"}else{if(AU.charAt(1)=="w"){Ab+="left:"+(AV+l.bottom)+"px;"}}var AT=N.insert('<div class="flotr-legend" style="position:absolute;z-index:2;'+Ab+'">'+Ad+"</div>").getElementsBySelector("div.flotr-legend").first();if(o.legend.backgroundOpacity!=0){var AZ=o.legend.backgroundColor;if(AZ==null){var AW=(o.grid.backgroundColor!=null)?o.grid.backgroundColor:A(AT);AZ=K(AW).adjust(null,null,null,1).toString()}N.insert('<div class="flotr-legend-bg" style="position:absolute;width:'+AT.getWidth()+"px;height:"+AT.getHeight()+"px;"+Ab+"background-color:"+AZ+';"> </div>').select("div.flotr-legend-bg").first().setStyle({opacity:o.legend.backgroundOpacity})}}}}var AG={pageX:null,pageY:null};var b={first:{x:-1,y:-1},second:{x:-1,y:-1}};var T=null;var x=null;var t=false;var Q=null;function f(AT){if(t){t=false;return }var AU=AL.cumulativeOffset();N.fire("flotr:click",[{x:u.min+(AT.pageX-AU.left-l.left)/AC,y:c.max-(AT.pageY-AU.top-l.top)/AB}])}function e(AU){if(AU.pageX==null&&AU.clientX!=null){var AX=document.documentElement,AT=document.body;AG.pageX=AU.clientX+(AX&&AX.scrollLeft||AT.scrollLeft||0);AG.pageY=AU.clientY+(AX&&AX.scrollTop||AT.scrollTop||0)}else{AG.pageX=AU.pageX;AG.pageY=AU.pageY}var AV=AL.cumulativeOffset();var AW={x:u.min+(AU.pageX-AV.left-l.left)/AC,y:c.max-(AU.pageY-AV.top-l.top)/AB};if(o.mouse.track&&x==null){n(AW)}N.fire("flotr:mousemove",[AU,AW])}function r(AT){if(!AT.isLeftClick()){return }AM(b.first,AT);if(x!=null){clearInterval(x)}AG.pageX=null;x=setInterval(AJ,1000/o.selection.fps);$(document).observe("mouseup",O)}function a(){var AU=(b.first.x<=b.second.x)?b.first.x:b.second.x;var AT=(b.first.x<=b.second.x)?b.second.x:b.first.x;var AW=(b.first.y>=b.second.y)?b.first.y:b.second.y;var AV=(b.first.y>=b.second.y)?b.second.y:b.first.y;AU=u.min+AU/AC;AT=u.min+AT/AC;AW=c.max-AW/AB;AV=c.max-AV/AB;N.fire("flotr:select",[{x1:AU,y1:AW,x2:AT,y2:AV}])}function O(AT){$(document).stopObserving("mouseup",O);if(x!=null){clearInterval(x);x=null}AM(b.second,AT);M();if(W()||AT.isLeftClick()){X();a();t=true}Event.stop(AT)}function AM(AV,AT){var AU=$(AL).cumulativeOffset();if(o.selection.mode=="y"){AV.x=(AV==b.first)?0:P}else{AV.x=AT.pageX-AU.left-l.left;AV.x=Math.min(Math.max(0,AV.x),P)}if(o.selection.mode=="x"){AV.y=(AV==b.first)?0:AD}else{AV.y=AT.pageY-AU.top-l.top;AV.y=Math.min(Math.max(0,AV.y),AD)}}function AJ(){if(AG.pageX==null){return }AM(b.second,AG);M();if(W()){X()}}function M(){if(T==null){return }var AT=Math.min(T.first.x,T.second.x),AW=Math.min(T.first.y,T.second.y),AU=Math.abs(T.second.x-T.first.x),AV=Math.abs(T.second.y-T.first.y);AS.clearRect(AT+l.left-AS.lineWidth,AW+l.top-AS.lineWidth,AU+AS.lineWidth*2,AV+AS.lineWidth*2);T=null}function AF(AT){M();b.first.y=(o.selection.mode=="x")?0:(c.max-AT.y1)*AB;b.second.y=(o.selection.mode=="x")?AD:(c.max-AT.y2)*AB;b.first.x=(o.selection.mode=="y")?0:(AT.x1-u.min)*AC;b.second.x=(o.selection.mode=="y")?P:(AT.x2-u.min)*AC;X();a()}function X(){if(T!=null&&b.first.x==T.first.x&&b.first.y==T.first.y&&b.second.x==T.second.x&&b.second.y==T.second.y){return }AS.strokeStyle=K(o.selection.color).scale(null,null,null,0.8).toString();AS.lineWidth=1;h.lineJoin="round";AS.fillStyle=K(o.selection.color).scale(null,null,null,0.4).toString();T={first:{x:b.first.x,y:b.first.y},second:{x:b.second.x,y:b.second.y}};var AT=Math.min(b.first.x,b.second.x),AW=Math.min(b.first.y,b.second.y),AU=Math.abs(b.second.x-b.first.x),AV=Math.abs(b.second.y-b.first.y);AS.fillRect(AT+l.left,AW+l.top,AU,AV);AS.strokeRect(AT+l.left,AW+l.top,AU,AV)}function W(){var AT=5;return Math.abs(b.second.x-b.first.x)>=AT&&Math.abs(b.second.y-b.first.y)>=AT}function s(){if(Q){AS.clearRect(AE(Q.x)+l.left-o.points.radius*2,j(Q.y)+l.top-o.points.radius*2,o.points.radius*3+o.points.lineWidth*3,o.points.radius*3+o.points.lineWidth*3);Q=null}}function n(Ae){var AX={dist:Number.MAX_VALUE,x:null,y:null,mouse:null};for(var Ad=0,Ac,AZ,AV;Ad<R.length;Ad++){if(!R[Ad].mouse.track){continue}Ac=R[Ad].data;AZ=(AC*R[Ad].mouse.sensibility);AV=(AB*R[Ad].mouse.sensibility);for(var Aa=0,Af,Ab;Aa<Ac.length;Aa++){Af=AC*Math.abs(Ac[Aa][0]-Ae.x);Ab=AB*Math.abs(Ac[Aa][1]-Ae.y);if(Af<AZ&&Ab<AV&&(Af+Ab)<AX.dist){AX.dist=(Af+Ab);AX.x=Ac[Aa][0];AX.y=Ac[Aa][1];AX.mouse=R[Ad].mouse}}}if(AX.mouse&&AX.mouse.track&&!Q||(Q&&AX.x!=Q.x&&AX.y!=Q.y)){var AU=N.select(".flotr-mouse-value").first();if(!AU){var Ag="",AT=o.mouse.position,AY=o.mouse.margin;if(AT.charAt(0)=="n"){Ag+="top:"+(AY+l.top)+"px;"}else{if(AT.charAt(0)=="s"){Ag+="bottom:"+(AY+l.bottom)+"px;"}}if(AT.charAt(1)=="e"){Ag+="right:"+(AY+l.right)+"px;"}else{if(AT.charAt(1)=="w"){Ag+="left:"+(AY+l.bottom)+"px;"}}N.insert('<div class="flotr-mouse-value" style="opacity:0.7;background-color:#000;color:#fff;display:none;position:absolute;'+Ag+'"></div>');return }if(AX.x!==null&&AX.y!==null){AU.setStyle({display:"block"});s();if(AX.mouse.lineColor!=null){AS.save();AS.translate(l.left,l.top);AS.lineWidth=o.points.lineWidth;AS.strokeStyle=AX.mouse.lineColor;AS.fillStyle="#ffffff";AS.beginPath();AS.arc(AE(AX.x),j(AX.y),o.points.radius,0,2*Math.PI,true);AS.fill();AS.stroke();AS.restore()}Q=AX;var AW=AX.mouse.trackDecimals;if(AW==null||AW<0){AW=0}AU.innerHTML=AX.mouse.trackFormatter({x:AX.x.toFixed(AW),y:AX.y.toFixed(AW)});N.fire("flotr:hit",[AX])}else{if(Q){AU.setStyle({display:"none"});s()}}}}}return{clean:function(M){M.innerHTML=""},draw:function(P,N,M){var O=new J(P,N,M);return O}}})();