/usr/share/javascript/flotr/flotr-min.js is in libjs-flotr 0.2.1~r301-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 | var Flotr={version:"0.2.0-alpha",revision:("$Revision: 301 $".match(/(\d+)/)||[null,null])[1],author:["Bas Wenneker","Fabien Ménager"],website:"http://www.solutoire.com",isIphone:/iphone/i.test(navigator.userAgent),isIE9:document.documentMode==9,graphTypes:{},plugins:{},addType:function(a,b){Flotr.graphTypes[a]=b;Flotr.defaultOptions[a]=b.options||{};Flotr.defaultOptions.defaultType=Flotr.defaultOptions.defaultType||a},addPlugin:function(a,b){Flotr.plugins[a]=b;Flotr.defaultOptions[a]=b.options||{}},draw:function(b,c,a,d){d=d||Flotr.Graph;return new d(b,c,a)},getSeries:function(a){return a.collect(function(c){c=(c.data)?Object.clone(c):{data:c};for(var b=c.data.length-1;b>-1;--b){c.data[b][1]=(c.data[b][1]===null?null:parseFloat(c.data[b][1]))}return c})},merge:function(e,c){var d,b,a=c||{};for(d in e){b=e[d];a[d]=(b&&typeof(b)==="object"&&!(b.constructor===Array||b.constructor===RegExp)&&!Object.isElement(b))?Flotr.merge(b,c[d]):a[d]=b}return a},clone:function(b){var c,a,d={};for(c in b){a=b[c];d[c]=(a&&typeof(a)==="object"&&!(a.constructor===Array||a.constructor===RegExp)&&!Object.isElement(a))?Flotr.clone(a):a}return d},getTickSize:function(e,d,a,b){var h=(a-d)/e,g=Flotr.getMagnitude(h),f=10,c=h/g;if(c<1.5){f=1}else{if(c<2.25){f=2}else{if(c<3){f=((b==0)?2:2.5)}else{if(c<7.5){f=5}}}}return f*g},defaultTickFormatter:function(a){return a+""},defaultTrackFormatter:function(a){return"("+a.x+", "+a.y+")"},engineeringNotation:function(e,a,d){var c=["Y","Z","E","P","T","G","M","k",""],f=["y","z","a","f","p","n","µ","m",""],b=c.length;d=d||1000;a=Math.pow(10,a||2);if(e==0){return 0}if(e>1){while(b--&&(e>=d)){e/=d}}else{c=f;b=c.length;while(b--&&(e<1)){e*=d}}return(Math.round(e*a)/a)+c[b]},getMagnitude:function(a){return Math.pow(10,Math.floor(Math.log(a)/Math.LN10))},toPixel:function(a){return Math.floor(a)+0.5},toRad:function(a){return -a*(Math.PI/180)},floorInBase:function(b,a){return a*Math.floor(b/a)},drawText:function(b,d,a,e,c){if(!b.fillText||Flotr.isIphone){b.drawText(d,a,e,c);return}c=Object.extend({size:Flotr.defaultOptions.fontSize,color:"#000000",textAlign:"left",textBaseline:"bottom",weight:1,angle:0},c);b.save();b.translate(a,e);b.rotate(c.angle);b.fillStyle=c.color;b.font=(c.weight>1?"bold ":"")+(c.size*1.3)+"px sans-serif";b.textAlign=c.textAlign;b.textBaseline=c.textBaseline;b.fillText(d,0,0);b.restore()},measureText:function(a,d,c){if(!a.fillText||Flotr.isIphone){return{width:a.measure(d,c)}}c=Object.extend({size:Flotr.defaultOptions.fontSize,weight:1,angle:0},c);a.save();a.rotate(c.angle);a.font=(c.weight>1?"bold ":"")+(c.size*1.3)+"px sans-serif";var b=a.measureText(d);a.restore();return b},getBestTextAlign:function(b,a){a=a||{textAlign:"center",textBaseline:"middle"};b+=Flotr.getTextAngleFromAlign(a);if(Math.abs(Math.cos(b))>0.01){a.textAlign=(Math.cos(b)>0?"right":"left")}if(Math.abs(Math.sin(b))>0.01){a.textBaseline=(Math.sin(b)>0?"top":"bottom")}return a},alignTable:{"right middle":0,"right top":Math.PI/4,"center top":Math.PI/2,"left top":3*(Math.PI/4),"left middle":Math.PI,"left bottom":-3*(Math.PI/4),"center bottom":-Math.PI/2,"right bottom":-Math.PI/4,"center middle":0},getTextAngleFromAlign:function(a){return Flotr.alignTable[a.textAlign+" "+a.textBaseline]||0}};Flotr.defaultOptions={colors:["#00A8F0","#C0D800","#CB4B4B","#4DA74D","#9440ED"],title:null,subtitle:null,shadowSize:4,defaultType:null,HtmlText:true,fontSize:7.5,resolution:1,legend:{show:true,noColumns:1,labelFormatter:function(a){return a},labelBoxBorderColor:"#CCCCCC",labelBoxWidth:14,labelBoxHeight:10,labelBoxMargin:5,container:null,position:"nw",margin:5,backgroundColor:null,backgroundOpacity:0.85},xaxis:{ticks:null,minorTicks:null,showLabels:true,showMinorLabels:false,labelsAngle:0,title:null,titleAngle:0,noTicks:5,minorTickFreq:null,tickFormatter:Flotr.defaultTickFormatter,tickDecimals:null,min:null,max:null,autoscale:false,autoscaleMargin:0,color:null,mode:"normal",timeFormat:null,scaling:"linear",base:Math.E,titleAlign:"center",margin:true},x2axis:{},yaxis:{ticks:null,minorTicks:null,showLabels:true,showMinorLabels:false,labelsAngle:0,title:null,titleAngle:90,noTicks:5,minorTickFreq:null,tickFormatter:Flotr.defaultTickFormatter,tickDecimals:null,min:null,max:null,autoscale:false,autoscaleMargin:0,color:null,scaling:"linear",base:Math.E,titleAlign:"center",margin:true},y2axis:{titleAngle:270},grid:{color:"#545454",backgroundColor:null,backgroundImage:null,watermarkAlpha:0.4,tickColor:"#DDDDDD",labelMargin:3,verticalLines:true,minorVerticalLines:null,horizontalLines:true,minorHorizontalLines:null,outlineWidth:2,circular:false},selection:{mode:null,color:"#B6D9FF",fps:20},crosshair:{mode:null,color:"#FF0000",hideCursor:true},mouse:{track:false,trackAll:false,position:"se",relative:false,trackFormatter:Flotr.defaultTrackFormatter,margin:5,lineColor:"#FF3F19",trackDecimals:1,sensibility:2,trackY:true,radius:3,fillColor:null,fillOpacity:0.4}};Flotr.Graph=Class.create({initialize:function(c,d,a){try{this.el=$(c);if(!this.el){throw"The target container doesn't exist"}if(!this.el.clientWidth){throw"The target container must be visible"}this.registerPlugins();this.el.fire("flotr:beforeinit",[this]);this.el.graph=this;this.data=d;this.lastMousePos={pageX:null,pageY:null};this.selection={first:{x:-1,y:-1},second:{x:-1,y:-1}};this.plotOffset={left:0,right:0,top:0,bottom:0};this.prevSelection=null;this.selectionInterval=null;this.ignoreClick=false;this.prevHit=null;this.series=Flotr.getSeries(d);this.setOptions(a);var b,g;for(b in Flotr.graphTypes){this[b]=Object.clone(Flotr.graphTypes[b]);for(g in this[b]){if(Object.isFunction(this[b][g])){this[b][g]=this[b][g].bind(this)}}}this.constructCanvas();this.el.fire("flotr:afterconstruct",[this]);this.initEvents();this.findDataRanges();this.calculateTicks(this.axes.x);this.calculateTicks(this.axes.x2);this.calculateTicks(this.axes.y);this.calculateTicks(this.axes.y2);this.calculateSpacing();this.setupAxes();this.draw(function(){this.insertLegend();this.el.fire("flotr:afterinit",[this])}.bind(this))}catch(f){try{console.error(f)}catch(f){}}},setOptions:function(b){var v=Flotr.clone(Flotr.defaultOptions);v.x2axis=Object.extend(Object.clone(v.xaxis),v.x2axis);v.y2axis=Object.extend(Object.clone(v.yaxis),v.y2axis);this.options=Flotr.merge(b||{},v);this.axes={x:{options:this.options.xaxis,n:1},x2:{options:this.options.x2axis,n:2},y:{options:this.options.yaxis,n:1},y2:{options:this.options.y2axis,n:2}};if(this.options.grid.minorVerticalLines===null&&this.options.xaxis.scaling==="logarithmic"){this.options.grid.minorVerticalLines=true}if(this.options.grid.minorHorizontalLines===null&&this.options.yaxis.scaling==="logarithmic"){this.options.grid.minorHorizontalLines=true}var h=[],d=[],m=this.series.length,q=this.series.length,e=this.options.colors,a=[],g=0,o,l,k,u;for(l=q-1;l>-1;--l){o=this.series[l].color;if(o){--q;if(Object.isNumber(o)){h.push(o)}else{a.push(Flotr.Color.parse(o))}}}for(l=h.length-1;l>-1;--l){q=Math.max(q,h[l]+1)}for(l=0;d.length<q;){o=(e.length==l)?new Flotr.Color(100,100,100):Flotr.Color.parse(e[l]);var f=g%2==1?-1:1,n=1+f*Math.ceil(g/2)*0.2;o.scale(n,n,n);d.push(o);if(++l>=e.length){l=0;++g}}for(l=0,k=0;l<m;++l){u=this.series[l];if(u.color==null){u.color=d[k++].toString()}else{if(Object.isNumber(u.color)){u.color=d[u.color].toString()}}if(!u.xaxis){u.xaxis=this.axes.x}if(u.xaxis==1){u.xaxis=this.axes.x}else{if(u.xaxis==2){u.xaxis=this.axes.x2}}if(!u.yaxis){u.yaxis=this.axes.y}if(u.yaxis==1){u.yaxis=this.axes.y}else{if(u.yaxis==2){u.yaxis=this.axes.y2}}for(var r in Flotr.graphTypes){u[r]=Object.extend(Object.clone(this.options[r]),u[r])}u.mouse=Object.extend(Object.clone(this.options.mouse),u.mouse);if(u.shadowSize==null){u.shadowSize=this.options.shadowSize}}},setupAxes:function(){function f(j,k){if(k.scaling==="logarithmic"){j=Math.log(Math.max(j,Number.MIN_VALUE));if(k.base!==Math.E){j/=Math.log(k.base)}}return j}function c(j,k){if(k.scaling==="logarithmic"){j=(k.base===Math.E)?Math.exp(j):Math.pow(k.base,j)}return j}var a=this.axes.x,b=this.axes.x2,h=this.axes.y,d=this.axes.y2;var e=this.plotWidth,g=this.plotHeight;a.scale=e/(f(a.max,a.options)-f(a.min,a.options));b.scale=e/(f(b.max,b.options)-f(b.min,b.options));h.scale=g/(f(h.max,h.options)-f(h.min,h.options));d.scale=g/(f(d.max,d.options)-f(d.min,d.options));if(this.options.scaling==="logarithmic"){a.d2p=b.d2p=function(j){var k=this.options;return(f(j,k)-f(this.min,k))*this.scale};a.p2d=this.axes.x2.p2d=function(j){var k=this.options;return c(j/this.scale+f(this.min,k),k)};h.d2p=d.d2p=function(k){var j=this.options;return g-(f(k,j)-f(this.min,j))*this.scale};h.p2d=d.p2d=function(k){var j=this.options;return c((g-k)/this.scale+f(this.min,j),j)}}else{a.d2p=b.d2p=function(j){return(j-this.min)*this.scale};a.p2d=this.axes.x2.p2d=function(j){return j/this.scale+this.min};h.d2p=d.d2p=function(j){return g-(j-this.min)*this.scale};h.p2d=d.p2d=function(j){return(g-j)/this.scale+this.min}}},constructCanvas:function(){var e=this.el,b,g,a;this.canvas=e.select(".flotr-canvas")[0];this.overlay=e.select(".flotr-overlay")[0];e.descendants().invoke("remove");e.style.position="relative";e.style.cursor=e.style.cursor||"default";b=e.getDimensions();this.canvasWidth=b.width;this.canvasHeight=b.height;var d={width:b.width+"px",height:b.height+"px"};var f=this.options;b.width*=f.resolution;b.height*=f.resolution;if(this.canvasWidth<=0||this.canvasHeight<=0){throw"Invalid dimensions for plot, width = "+this.canvasWidth+", height = "+this.canvasHeight}if(!this.canvas){g=this.canvas=$(document.createElement("canvas"));g.className="flotr-canvas";g.style.cssText="position:absolute;left:0px;top:0px;"}g=this.canvas.writeAttribute(b).show().setStyle(d);g.context_=null;e.insert(g);if(!this.overlay){a=this.overlay=$(document.createElement("canvas"));a.className="flotr-overlay";a.style.cssText="position:absolute;left:0px;top:0px;"}a=this.overlay.writeAttribute(b).show().setStyle(d);a.context_=null;e.insert(a);if(window.G_vmlCanvasManager){window.G_vmlCanvasManager.initElement(g);window.G_vmlCanvasManager.initElement(a)}this.ctx=g.getContext("2d");this.octx=a.getContext("2d");if(!window.G_vmlCanvasManager){this.ctx.scale(f.resolution,f.resolution);this.octx.scale(f.resolution,f.resolution)}this.textEnabled=!!this.ctx.drawText},processColor:function(a,b){if(!a){return"rgba(0, 0, 0, 0)"}b=Object.extend({x1:0,y1:0,x2:this.plotWidth,y2:this.plotHeight,opacity:1,ctx:this.ctx},b);if(a instanceof Flotr.Color){return a.adjust(null,null,null,b.opacity).toString()}if(Object.isString(a)){return Flotr.Color.parse(a).scale(null,null,null,b.opacity).toString()}var h=a.colors?a:{colors:a};if(!b.ctx){if(!Object.isArray(h.colors)){return"rgba(0, 0, 0, 0)"}return Flotr.Color.parse(Object.isArray(h.colors[0])?h.colors[0][1]:h.colors[0]).scale(null,null,null,b.opacity).toString()}h=Object.extend({start:"top",end:"bottom"},h);if(/top/i.test(h.start)){b.x1=0}if(/left/i.test(h.start)){b.y1=0}if(/bottom/i.test(h.end)){b.x2=0}if(/right/i.test(h.end)){b.y2=0}var e,g,d,f=b.ctx.createLinearGradient(b.x1,b.y1,b.x2,b.y2);for(e=0;e<h.colors.length;e++){g=h.colors[e];if(Object.isArray(g)){d=g[0];g=g[1]}else{d=e/(h.colors.length-1)}f.addColorStop(d,Flotr.Color.parse(g).scale(null,null,null,b.opacity))}return f},registerPlugins:function(){var a,b,d;for(a in Flotr.plugins){b=Flotr.plugins[a];for(d in b.callbacks){this.el.stopObserving(d).observe(d,b.callbacks[d].bindAsEventListener(this))}this[a]=Object.clone(b);for(p in this[a]){if(Object.isFunction(this[a][p])){this[a][p]=this[a][p].bind(this)}}}},getTextDimensions:function(g,c,b,d){if(!g){return{width:0,height:0}}if(!this.options.HtmlText&&this.textEnabled){var e=this.ctx.getTextBounds(g,c);return{width:e.width+2,height:e.height+6}}else{var a=this.el.insert('<div style="position:absolute;top:-10000px;'+b+'" class="'+d+' flotr-dummy-div">'+g+"</div>").select(".flotr-dummy-div")[0],f=a.getDimensions();a.remove();return f}},loadDataGrid:function(){if(this.seriesData){return this.seriesData}var a=this.series,b=[];for(i=0;i<a.length;++i){a[i].data.each(function(d){var c=d[0],g=d[1],f=b.find(function(h){return h[0]==c});if(f){f[i+1]=g}else{var e=[];e[0]=c;e[i+1]=g;b.push(e)}})}return this.seriesData=b.sortBy(function(c){return c[0]})},initEvents:function(){this.overlay.stopObserving().observe("mousedown",this.mouseDownHandler.bindAsEventListener(this)).observe("mousemove",this.mouseMoveHandler.bindAsEventListener(this)).observe("mouseout",this.clearHit.bindAsEventListener(this)).observe("click",this.clickHandler.bindAsEventListener(this))},findDataRanges:function(){var n=this.series,k=this.axes;k.x.datamin=k.x2.datamin=k.y.datamin=k.y2.datamin=Number.MAX_VALUE;k.x.datamax=k.x2.datamax=k.y.datamax=k.y2.datamax=-Number.MAX_VALUE;if(n.length>0){var d,b,e,l,g,c,m,f;for(d=0;d<n.length;++d){c=n[d].data,m=n[d].xaxis,f=n[d].yaxis;if(c.length>0&&!n[d].hide){for(e=c.length-1;e>-1;--e){l=c[e][0];if((l<=0)&&(m.options.scaling==="logarithmic")){continue}if(l<m.datamin){m.datamin=l;m.used=true}if(l>m.datamax){m.datamax=l;m.used=true}for(b=1;b<c[e].length;b++){g=c[e][b];if((g<=0)&&(f.options.scaling==="logarithmic")){continue}if(g<f.datamin){f.datamin=g;f.used=true}if(g>f.datamax){f.datamax=g;f.used=true}}}}}}this.findAxesValues();this.calculateRange(k.x,"x");if(k.x2.used){this.calculateRange(k.x2,"x")}this.calculateRange(k.y,"y");if(k.y2.used){this.calculateRange(k.y2,"y")}},extendRange:function(c,b){var e=(b==="y")?"extendYRange":"extendXRange";for(var a in Flotr.graphTypes){if(this.options[a]&&this.options[a].show){if(this[a][e]){this[a][e](c)}}else{var g=false;for(i=0;i<this.series.length;i++){var d=this.series[i];if(d[a]&&d[a].show){g=true;break}}if(g){if(this[a][e]){this[a][e](c)}}}}},calculateRange:function(d,g){var c=d.options,f=c.min!=null?c.min:d.datamin,h=c.max!=null?c.max:d.datamax,e=c.autoscaleMargin;if(c.scaling=="logarithmic"){if(f<=0){f=d.datamin}if(h<=0){h=f}}if(h-f==0){var b=(h==0)?1:0.01;f-=b;h+=b}if(c.scaling==="logarithmic"){if(f<0){f=h/c.base}var a=Math.log(h);if(c.base!=Math.E){a/=Math.log(c.base)}a=Math.ceil(a);var j=Math.log(f);if(c.base!=Math.E){j/=Math.log(c.base)}j=Math.ceil(j);d.tickSize=Flotr.getTickSize(c.noTicks,j,a,c.tickDecimals===null?0:c.tickDecimals);if(c.minorTickFreq===null){if(a-j>10){c.minorTickFreq=0}else{if(a-j>5){c.minorTickFreq=2}else{c.minorTickFreq=5}}}}else{d.tickSize=Flotr.getTickSize(c.noTicks,f,h,c.tickDecimals)}d.min=f;d.max=h;this.extendRange(d,g);if(c.min==null&&c.autoscale){d.min-=d.tickSize*e;if(d.min<0&&d.datamin>=0){d.min=0}d.min=d.tickSize*Math.floor(d.min/d.tickSize)}if(c.max==null&&c.autoscale){d.max+=d.tickSize*e;if(d.max>0&&d.datamax<=0&&d.datamax!=d.datamin){d.max=0}d.max=d.tickSize*Math.ceil(d.max/d.tickSize)}if(d.min==d.max){d.max=d.min+1}},findAxesValues:function(){var b,a,c;for(b=this.series.length-1;b>-1;--b){c=this.series[b];this.findXAxesValues(c);if(c.bars.show&&c.bars.horizontal&&c.bars.stacked){this.findYAxesValues(c)}}},findXAxesValues:function(b){var a;b.xaxis.values=b.xaxis.values||{};for(a=b.data.length-1;a>-1;--a){b.xaxis.values[b.data[a][0]+""]={}}},findYAxesValues:function(b){var a;b.yaxis.values=b.yaxis.values||{};for(a=b.data.length-1;a>-1;--a){b.yaxis.values[b.data[a][1]+""]={}}},calculateTicks:function(e){var u=e.options,A,m;e.ticks=[];e.minorTicks=[];if(u.ticks){var E=u.ticks,b=u.minorTicks||[],n,l;if(Object.isFunction(E)){E=E({min:e.min,max:e.max})}if(Object.isFunction(b)){b=b({min:e.min,max:e.max})}for(A=0;A<E.length;++A){n=E[A];if(typeof(n)==="object"){m=n[0];l=(n.length>1)?n[1]:u.tickFormatter(m)}else{m=n;l=u.tickFormatter(m)}e.ticks[A]={v:m,label:l}}for(A=0;A<b.length;++A){n=b[A];if(typeof(n)==="object"){m=n[0];l=(n.length>1)?n[1]:u.tickFormatter(m)}else{m=n;l=u.tickFormatter(m)}e.minorTicks[A]={v:m,label:l}}}else{if(u.mode=="time"){var G=Flotr.Date.timeUnits,k=Flotr.Date.spec,D=(e.max-e.min)/e.options.noTicks,r,q;for(A=0;A<k.length-1;++A){var C=k[A][0]*G[k[A][1]];if(D<(C+k[A+1][0]*G[k[A+1][1]])/2&&C>=e.tickSize){break}}r=k[A][0];q=k[A][1];if(q=="year"){r=Flotr.getTickSize(e.options.noTicks*G.year,e.min,e.max,0)}e.tickSize=r;e.tickUnit=q;e.ticks=Flotr.Date.generator(e)}else{if(u.scaling==="logarithmic"){var z=Math.log(e.max);if(u.base!=Math.E){z/=Math.log(u.base)}z=Math.ceil(z);var w=Math.log(e.min);if(u.base!=Math.E){w/=Math.log(u.base)}w=Math.ceil(w);for(A=w;A<z;A+=e.tickSize){var a=(u.base==Math.E)?Math.exp(A):Math.pow(u.base,A);var f=a*((u.base==Math.E)?Math.exp(e.tickSize):Math.pow(u.base,e.tickSize));var h=(f-a)/u.minorTickFreq;e.ticks.push({v:a,label:u.tickFormatter(a)});for(m=a+h;m<f;m+=h){e.minorTicks.push({v:m,label:u.tickFormatter(m)})}}var a=(u.base==Math.E)?Math.exp(A):Math.pow(u.base,A);e.ticks.push({v:a,label:u.tickFormatter(a)})}else{var g=e.tickSize*Math.ceil(e.min/e.tickSize),F,B,c;if(u.minorTickFreq){B=e.tickSize/u.minorTickFreq}for(A=0;g+A*e.tickSize<=e.max;++A){m=c=g+A*e.tickSize;F=u.tickDecimals;if(F==null){F=1-Math.floor(Math.log(e.tickSize)/Math.LN10)}if(F<0){F=0}m=m.toFixed(F);e.ticks.push({v:m,label:u.tickFormatter(m)});if(u.minorTickFreq){for(var x=0;x<u.minorTickFreq&&(A*e.tickSize+x*B)<e.max;++x){m=c+x*B;m=m.toFixed(F);e.minorTicks.push({v:m,label:u.tickFormatter(m)})}}}}}}},calculateSpacing:function(){var q=this.axes,t=this.options,k=this.series,e=t.grid.labelMargin,r=q.x,b=q.x2,n=q.y,o=q.y2,g=2,h,f,d,m;[r,b,n,o].each(function(j){var a="";if(j.options.showLabels){for(h=0;h<j.ticks.length;++h){d=j.ticks[h].label.length;if(d>a.length){a=j.ticks[h].label}}}j.maxLabel=this.getTextDimensions(a,{size:t.fontSize,angle:Flotr.toRad(j.options.labelsAngle)},"font-size:smaller;","flotr-grid-label");j.titleSize=this.getTextDimensions(j.options.title,{size:t.fontSize*1.2,angle:Flotr.toRad(j.options.titleAngle)},"font-weight:bold;","flotr-axis-title")},this);m=this.getTextDimensions(t.title,{size:t.fontSize*1.5},"font-size:1em;font-weight:bold;","flotr-title");this.titleHeight=m.height;m=this.getTextDimensions(t.subtitle,{size:t.fontSize},"font-size:smaller;","flotr-subtitle");this.subtitleHeight=m.height;if(t.show){g=Math.max(g,t.points.radius+t.points.lineWidth/2)}for(f=0;f<t.length;++f){if(k[f].points.show){g=Math.max(g,k[f].points.radius+k[f].points.lineWidth/2)}}var c=this.plotOffset;if(r.options.margin===false){c.bottom=0;c.top=0}else{c.bottom+=(t.grid.circular?0:(r.options.showLabels?(r.maxLabel.height+e):0))+(r.options.title?(r.titleSize.height+e):0)+g;c.top+=(t.grid.circular?0:(b.options.showLabels?(b.maxLabel.height+e):0))+(b.options.title?(b.titleSize.height+e):0)+this.subtitleHeight+this.titleHeight+g}if(n.options.margin===false){c.left=0;c.right=0}else{c.left+=(t.grid.circular?0:(n.options.showLabels?(n.maxLabel.width+e):0))+(n.options.title?(n.titleSize.width+e):0)+g;c.right+=(t.grid.circular?0:(o.options.showLabels?(o.maxLabel.width+e):0))+(o.options.title?(o.titleSize.width+e):0)+g}c.top=Math.floor(c.top);this.plotWidth=this.canvasWidth-c.left-c.right;this.plotHeight=this.canvasHeight-c.bottom-c.top},draw:function(d){var c=function(){this.drawGrid();this.drawLabels();this.drawTitles();if(this.series.length){this.el.fire("flotr:beforedraw",[this.series,this]);for(var e=0;e<this.series.length;e++){if(!this.series[e].hide){this.drawSeries(this.series[e])}}}this.drawOutline();this.el.fire("flotr:afterdraw",[this.series,this]);d()}.bind(this);var b=this.options.grid;if(b&&b.backgroundImage){if(Object.isString(b.backgroundImage)){b.backgroundImage={src:b.backgroundImage,left:0,top:0}}else{b.backgroundImage=Object.extend({left:0,top:0},b.backgroundImage)}var a=new Image();a.onload=function(){var g=this.plotOffset.left+(parseInt(b.backgroundImage.left)||0);var f=this.plotOffset.top+(parseInt(b.backgroundImage.top)||0);var e=this.ctx.globalAlpha;this.ctx.globalAlpha=(b.backgroundImage.alpha||e);this.ctx.drawImage(a,g,f);this.ctx.globalAlpha=e;c()}.bind(this);a.onabort=a.onerror=c;a.src=b.backgroundImage.src}else{c()}},drawGrid:function(){var m,b=this.options,n=this.ctx,l;if(b.grid.verticalLines||b.grid.minorVerticalLines||b.grid.horizontalLines||b.grid.minorHorizontalLines){this.el.fire("flotr:beforegrid",[this.axes.x,this.axes.y,b,this])}n.save();n.lineWidth=1;n.strokeStyle=b.grid.tickColor;if(b.grid.circular){n.translate(this.plotOffset.left+this.plotWidth/2,this.plotOffset.top+this.plotHeight/2);var h=Math.min(this.plotHeight,this.plotWidth)*b.radar.radiusRatio/2,c=this.axes.x.ticks.length,g=2*(Math.PI/c),d=-Math.PI/2;n.beginPath();if(b.grid.horizontalLines){l=this.axes.y;for(var f=0;f<l.ticks.length;++f){m=l.ticks[f].v;var k=m/l.max;for(var e=0;e<=c;++e){n[e==0?"moveTo":"lineTo"](Math.cos(e*g+d)*h*k,Math.sin(e*g+d)*h*k)}}}if(b.grid.minorHorizontalLines){l=this.axes.y;for(var f=0;f<l.minorTicks.length;++f){m=l.minorTicks[f].v;var k=m/l.max;for(var e=0;e<=c;++e){n[e==0?"moveTo":"lineTo"](Math.cos(e*g+d)*h*k,Math.sin(e*g+d)*h*k)}}}if(b.grid.verticalLines){for(var f=0;f<c;++f){n.moveTo(0,0);n.lineTo(Math.cos(f*g+d)*h,Math.sin(f*g+d)*h)}}n.stroke()}else{n.translate(this.plotOffset.left,this.plotOffset.top);if(b.grid.backgroundColor!=null){n.fillStyle=this.processColor(b.grid.backgroundColor,{x1:0,y1:0,x2:this.plotWidth,y2:this.plotHeight});n.fillRect(0,0,this.plotWidth,this.plotHeight)}n.beginPath();if(b.grid.verticalLines){l=this.axes.x;for(var f=0;f<l.ticks.length;++f){m=l.ticks[f].v;if((m<=l.min||m>=l.max)||(m==l.min||m==l.max)&&b.grid.outlineWidth!=0){continue}n.moveTo(Math.floor(l.d2p(m))+n.lineWidth/2,0);n.lineTo(Math.floor(l.d2p(m))+n.lineWidth/2,this.plotHeight)}}if(b.grid.minorVerticalLines){l=this.axes.x;for(var f=0;f<l.minorTicks.length;++f){m=l.minorTicks[f].v;if((m<=l.min||m>=l.max)||(m==l.min||m==l.max)&&b.grid.outlineWidth!=0){continue}n.moveTo(Math.floor(l.d2p(m))+n.lineWidth/2,0);n.lineTo(Math.floor(l.d2p(m))+n.lineWidth/2,this.plotHeight)}}if(b.grid.horizontalLines){l=this.axes.y;for(var e=0;e<l.ticks.length;++e){m=l.ticks[e].v;if((m<=l.min||m>=l.max)||(m==l.min||m==l.max)&&b.grid.outlineWidth!=0){continue}n.moveTo(0,Math.floor(l.d2p(m))+n.lineWidth/2);n.lineTo(this.plotWidth,Math.floor(l.d2p(m))+n.lineWidth/2)}}if(b.grid.minorHorizontalLines){l=this.axes.y;for(var e=0;e<l.minorTicks.length;++e){m=l.minorTicks[e].v;if((m<=l.min||m>=l.max)||(m==l.min||m==l.max)&&b.grid.outlineWidth!=0){continue}n.moveTo(0,Math.floor(l.d2p(m))+n.lineWidth/2);n.lineTo(this.plotWidth,Math.floor(l.d2p(m))+n.lineWidth/2)}}n.stroke()}n.restore();if(b.grid.verticalLines||b.grid.minorVerticalLines||b.grid.horizontalLines||b.grid.minorHorizontalLines){this.el.fire("flotr:aftergrid",[this.axes.x,this.axes.y,b,this])}},drawOutline:function(){var j,a=this.options,k=this.ctx;if(a.grid.outlineWidth==0){return}k.save();if(a.grid.circular){k.translate(this.plotOffset.left+this.plotWidth/2,this.plotOffset.top+this.plotHeight/2);var g=Math.min(this.plotHeight,this.plotWidth)*a.radar.radiusRatio/2,b=this.axes.x.ticks.length,f=2*(Math.PI/b),d=-Math.PI/2;k.beginPath();k.lineWidth=a.grid.outlineWidth;k.strokeStyle=a.grid.color;k.lineJoin="round";for(var e=0;e<=b;++e){k[e==0?"moveTo":"lineTo"](Math.cos(e*f+d)*g,Math.sin(e*f+d)*g)}k.stroke()}else{k.translate(this.plotOffset.left,this.plotOffset.top);var c=a.grid.outlineWidth,h=0.5-c+((c+1)%2/2);k.lineWidth=c;k.strokeStyle=a.grid.color;k.lineJoin="miter";k.strokeRect(h,h,this.plotWidth,this.plotHeight)}k.restore()},drawLabels:function(){var c=0,d,m,o,k,q,g,l,e=this.options,n=this.ctx,v=this.axes;for(o=0;o<v.x.ticks.length;++o){if(v.x.ticks[o].label){++c}}m=this.plotWidth/c;if(e.grid.circular){n.save();n.translate(this.plotOffset.left+this.plotWidth/2,this.plotOffset.top+this.plotHeight/2);var f=this.plotHeight*e.radar.radiusRatio/2+e.fontSize,u=this.axes.x.ticks.length,b=2*(Math.PI/u),t=-Math.PI/2;var r={size:e.fontSize};d=v.x;r.color=d.options.color||e.grid.color;for(o=0;o<d.ticks.length&&d.options.showLabels;++o){q=d.ticks[o];q.label+="";if(!q.label||q.label.length==0){continue}var j=Math.cos(o*b+t)*f,h=Math.sin(o*b+t)*f;r.angle=Flotr.toRad(d.options.labelsAngle);r.textBaseline="middle";r.textAlign=(Math.abs(j)<0.1?"center":(j<0?"right":"left"));Flotr.drawText(n,q.label,j,h,r)}for(o=0;o<d.minorTicks.length&&d.options.showMinorLabels;++o){q=d.minorTicks[o];q.label+="";if(!q.label||q.label.length==0){continue}var j=Math.cos(o*b+t)*f,h=Math.sin(o*b+t)*f;r.angle=Flotr.toRad(d.options.labelsAngle);r.textBaseline="middle";r.textAlign=(Math.abs(j)<0.1?"center":(j<0?"right":"left"));Flotr.drawText(n,q.label,j,h,r)}d=v.y;r.color=d.options.color||e.grid.color;for(o=0;o<d.ticks.length&&d.options.showLabels;++o){q=d.ticks[o];q.label+="";if(!q.label||q.label.length==0){continue}r.angle=Flotr.toRad(d.options.labelsAngle);r.textBaseline="middle";r.textAlign="left";Flotr.drawText(n,q.label,3,-(d.ticks[o].v/d.max)*(f-e.fontSize),r)}for(o=0;o<d.minorTicks.length&&d.options.showMinorLabels;++o){q=d.minorTicks[o];q.label+="";if(!q.label||q.label.length==0){continue}r.angle=Flotr.toRad(d.options.labelsAngle);r.textBaseline="middle";r.textAlign="left";Flotr.drawText(n,q.label,3,-(d.ticks[o].v/d.max)*(f-e.fontSize),r)}n.restore();return}if(!e.HtmlText&&this.textEnabled){var r={size:e.fontSize};d=v.x;r.color=d.options.color||e.grid.color;for(o=0;o<d.ticks.length&&d.options.showLabels&&d.used;++o){q=d.ticks[o];if(!q.label||q.label.length==0){continue}g=d.d2p(q.v);if(g<0||g>this.plotWidth){continue}r.angle=Flotr.toRad(d.options.labelsAngle);r.textAlign="center";r.textBaseline="top";r=Flotr.getBestTextAlign(r.angle,r);Flotr.drawText(n,q.label,this.plotOffset.left+g,this.plotOffset.top+this.plotHeight+e.grid.labelMargin,r)}d=v.x2;r.color=d.options.color||e.grid.color;for(o=0;o<d.ticks.length&&d.options.showLabels&&d.used;++o){q=d.ticks[o];if(!q.label||q.label.length==0){continue}g=d.d2p(q.v);if(g<0||g>this.plotWidth){continue}r.angle=Flotr.toRad(d.options.labelsAngle);r.textAlign="center";r.textBaseline="bottom";r=Flotr.getBestTextAlign(r.angle,r);Flotr.drawText(n,q.label,this.plotOffset.left+g,this.plotOffset.top+e.grid.labelMargin,r)}d=v.y;r.color=d.options.color||e.grid.color;for(o=0;o<d.ticks.length&&d.options.showLabels&&d.used;++o){q=d.ticks[o];if(!q.label||q.label.length==0){continue}l=d.d2p(q.v);if(l<0||l>this.plotHeight){continue}r.angle=Flotr.toRad(d.options.labelsAngle);r.textAlign="right";r.textBaseline="middle";r=Flotr.getBestTextAlign(r.angle,r);Flotr.drawText(n,q.label,this.plotOffset.left-e.grid.labelMargin,this.plotOffset.top+l,r)}d=v.y2;r.color=d.options.color||e.grid.color;for(o=0;o<d.ticks.length&&d.options.showLabels&&d.used;++o){q=d.ticks[o];if(!q.label||q.label.length==0){continue}l=d.d2p(q.v);if(l<0||l>this.plotHeight){continue}r.angle=Flotr.toRad(d.options.labelsAngle);r.textAlign="left";r.textBaseline="middle";r=Flotr.getBestTextAlign(r.angle,r);Flotr.drawText(n,q.label,this.plotOffset.left+this.plotWidth+e.grid.labelMargin,this.plotOffset.top+l,r);n.save();n.strokeStyle=r.color;n.beginPath();n.moveTo(this.plotOffset.left+this.plotWidth-8,this.plotOffset.top+d.d2p(q.v));n.lineTo(this.plotOffset.left+this.plotWidth,this.plotOffset.top+d.d2p(q.v));n.stroke();n.restore()}}else{if(v.x.options.showLabels||v.x2.options.showLabels||v.y.options.showLabels||v.y2.options.showLabels){k=['<div style="font-size:smaller;color:'+e.grid.color+';" class="flotr-labels">'];d=v.x;if(d.options.showLabels){for(o=0;o<d.ticks.length;++o){q=d.ticks[o];if(!q.label||q.label.length==0||(this.plotOffset.left+d.d2p(q.v)<0)||(this.plotOffset.left+d.d2p(q.v)>this.canvasWidth)){continue}k.push('<div style="position:absolute;top:',(this.plotOffset.top+this.plotHeight+e.grid.labelMargin),"px;left:",(this.plotOffset.left+d.d2p(q.v)-m/2),"px;width:",m,"px;text-align:center;",(d.options.color?("color:"+d.options.color+";"):""),'" class="flotr-grid-label">',q.label,"</div>")}}d=v.x2;if(d.options.showLabels&&d.used){for(o=0;o<d.ticks.length;++o){q=d.ticks[o];if(!q.label||q.label.length==0||(this.plotOffset.left+d.d2p(q.v)<0)||(this.plotOffset.left+d.d2p(q.v)>this.canvasWidth)){continue}k.push('<div style="position:absolute;top:',(this.plotOffset.top-e.grid.labelMargin-d.maxLabel.height),"px;left:",(this.plotOffset.left+d.d2p(q.v)-m/2),"px;width:",m,"px;text-align:center;",(d.options.color?("color:"+d.options.color+";"):""),'" class="flotr-grid-label">',q.label,"</div>")}}d=v.y;if(d.options.showLabels){for(o=0;o<d.ticks.length;++o){q=d.ticks[o];if(!q.label||q.label.length==0||(this.plotOffset.top+d.d2p(q.v)<0)||(this.plotOffset.top+d.d2p(q.v)>this.canvasHeight)){continue}k.push('<div style="position:absolute;top:',(this.plotOffset.top+d.d2p(q.v)-d.maxLabel.height/2),"px;left:0;width:",(this.plotOffset.left-e.grid.labelMargin),"px;text-align:right;",(d.options.color?("color:"+d.options.color+";"):""),'" class="flotr-grid-label flotr-grid-label-y">',q.label,"</div>")}}d=v.y2;if(d.options.showLabels&&d.used){n.save();n.strokeStyle=d.options.color||e.grid.color;n.beginPath();for(o=0;o<d.ticks.length;++o){q=d.ticks[o];if(!q.label||q.label.length==0||(this.plotOffset.top+d.d2p(q.v)<0)||(this.plotOffset.top+d.d2p(q.v)>this.canvasHeight)){continue}k.push('<div style="position:absolute;top:',(this.plotOffset.top+d.d2p(q.v)-d.maxLabel.height/2),"px;right:0;width:",(this.plotOffset.right-e.grid.labelMargin),"px;text-align:left;",(d.options.color?("color:"+d.options.color+";"):""),'" class="flotr-grid-label flotr-grid-label-y">',q.label,"</div>");n.moveTo(this.plotOffset.left+this.plotWidth-8,this.plotOffset.top+d.d2p(q.v));n.lineTo(this.plotOffset.left+this.plotWidth,this.plotOffset.top+d.d2p(q.v))}n.stroke();n.restore()}k.push("</div>");this.el.insert(k.join(""))}}},drawTitles:function(){var e,d=this.options,g=d.grid.labelMargin,c=this.ctx,b=this.axes;if(!d.HtmlText&&this.textEnabled){var f={size:d.fontSize,color:d.grid.color,textAlign:"center"};if(d.subtitle){Flotr.drawText(c,d.subtitle,this.plotOffset.left+this.plotWidth/2,this.titleHeight+this.subtitleHeight-2,f)}f.weight=1.5;f.size*=1.5;if(d.title){Flotr.drawText(c,d.title,this.plotOffset.left+this.plotWidth/2,this.titleHeight-2,f)}f.weight=1.8;f.size*=0.8;if(b.x.options.title&&b.x.used){f.textAlign=b.x.options.titleAlign||"center";f.textBaseline="top";f.angle=Flotr.toRad(b.x.options.titleAngle);f=Flotr.getBestTextAlign(f.angle,f);Flotr.drawText(c,b.x.options.title,this.plotOffset.left+this.plotWidth/2,this.plotOffset.top+b.x.maxLabel.height+this.plotHeight+2*g,f)}if(b.x2.options.title&&b.x2.used){f.textAlign=b.x2.options.titleAlign||"center";f.textBaseline="bottom";f.angle=Flotr.toRad(b.x2.options.titleAngle);f=Flotr.getBestTextAlign(f.angle,f);Flotr.drawText(c,b.x2.options.title,this.plotOffset.left+this.plotWidth/2,this.plotOffset.top-b.x2.maxLabel.height-2*g,f)}if(b.y.options.title&&b.y.used){f.textAlign=b.y.options.titleAlign||"right";f.textBaseline="middle";f.angle=Flotr.toRad(b.y.options.titleAngle);f=Flotr.getBestTextAlign(f.angle,f);Flotr.drawText(c,b.y.options.title,this.plotOffset.left-b.y.maxLabel.width-2*g,this.plotOffset.top+this.plotHeight/2,f)}if(b.y2.options.title&&b.y2.used){f.textAlign=b.y2.options.titleAlign||"left";f.textBaseline="middle";f.angle=Flotr.toRad(b.y2.options.titleAngle);f=Flotr.getBestTextAlign(f.angle,f);Flotr.drawText(c,b.y2.options.title,this.plotOffset.left+this.plotWidth+b.y2.maxLabel.width+2*g,this.plotOffset.top+this.plotHeight/2,f)}}else{e=['<div style="color:'+d.grid.color+';" class="flotr-titles">'];if(d.title){e.push('<div style="position:absolute;top:0;left:',this.plotOffset.left,"px;font-size:1em;font-weight:bold;text-align:center;width:",this.plotWidth,'px;" class="flotr-title">',d.title,"</div>")}if(d.subtitle){e.push('<div style="position:absolute;top:',this.titleHeight,"px;left:",this.plotOffset.left,"px;font-size:smaller;text-align:center;width:",this.plotWidth,'px;" class="flotr-subtitle">',d.subtitle,"</div>")}e.push("</div>");e.push('<div class="flotr-axis-title" style="font-weight:bold;">');if(b.x.options.title&&b.x.used){e.push('<div style="position:absolute;top:',(this.plotOffset.top+this.plotHeight+d.grid.labelMargin+b.x.titleSize.height),"px;left:",this.plotOffset.left,"px;width:",this.plotWidth,'px;text-align:center;" class="flotr-axis-title">',b.x.options.title,"</div>")}if(b.x2.options.title&&b.x2.used){e.push('<div style="position:absolute;top:0;left:',this.plotOffset.left,"px;width:",this.plotWidth,'px;text-align:center;" class="flotr-axis-title">',b.x2.options.title,"</div>")}if(b.y.options.title&&b.y.used){e.push('<div style="position:absolute;top:',(this.plotOffset.top+this.plotHeight/2-b.y.titleSize.height/2),'px;left:0;text-align:right;" class="flotr-axis-title">',b.y.options.title,"</div>")}if(b.y2.options.title&&b.y2.used){e.push('<div style="position:absolute;top:',(this.plotOffset.top+this.plotHeight/2-b.y.titleSize.height/2),'px;right:0;text-align:right;" class="flotr-axis-title">',b.y2.options.title,"</div>")}e.push("</div>");this.el.insert(e.join(""))}},drawSeries:function(a){a=a||this.series;var b=false;for(type in Flotr.graphTypes){if(a[type]&&a[type].show){b=true;this[type].draw(a)}}if(!b){this[this.options.defaultType].draw(a)}},insertLegend:function(){if(!this.options.legend.show){return}var o=this.series,q=this.plotOffset,e=this.options,a=e.legend,N=[],b=false,A=this.ctx,D;var C=o.findAll(function(c){return(c.label&&!c.hide)}).length;if(C){if(!e.HtmlText&&this.textEnabled&&!$(a.container)){var F={size:e.fontSize*1.1,color:e.grid.color};var w=a.position,z=a.margin,v=a.labelBoxWidth,M=a.labelBoxHeight,E=a.labelBoxMargin,I=q.left+z,G=q.top+z;var L=0;for(D=o.length-1;D>-1;--D){if(!o[D].label||o[D].hide){continue}var j=a.labelFormatter(o[D].label);L=Math.max(L,Flotr.measureText(A,j,F).width)}var u=Math.round(v+E*3+L),f=Math.round(C*(E+M)+E);if(w.charAt(0)=="s"){G=q.top+this.plotHeight-(z+f)}if(w.charAt(1)=="e"){I=q.left+this.plotWidth-(z+u)}var B=this.processColor(e.legend.backgroundColor||"rgb(240,240,240)",{opacity:e.legend.backgroundOpacity||0.1});A.fillStyle=B;A.fillRect(I,G,u,f);A.strokeStyle=e.legend.labelBoxBorderColor;A.strokeRect(Flotr.toPixel(I),Flotr.toPixel(G),u,f);var n=I+E;var l=G+E;for(D=0;D<o.length;D++){if(!o[D].label||o[D].hide){continue}var j=a.labelFormatter(o[D].label);A.fillStyle=o[D].color;A.fillRect(n,l,v-1,M-1);A.strokeStyle=a.labelBoxBorderColor;A.lineWidth=1;A.strokeRect(Math.ceil(n)-1.5,Math.ceil(l)-1.5,v+2,M+2);Flotr.drawText(A,j,n+v+E,l+(M+F.size-A.fontDescent(F))/2,F);l+=M+E}}else{for(D=0;D<o.length;++D){if(!o[D].label||o[D].hide){continue}if(D%e.legend.noColumns==0){N.push(b?"</tr><tr>":"<tr>");b=true}var t=o[D],j=a.labelFormatter(t.label),k=a.labelBoxWidth,h=a.labelBoxHeight,d="opacity:"+t.bars.fillOpacity+";filter:alpha(opacity="+t.bars.fillOpacity*100+");",B="background-color:"+((t.bars.show&&t.bars.fillColor&&t.bars.fill)?t.bars.fillColor:t.color)+";";N.push('<td class="flotr-legend-color-box">','<div style="border:1px solid ',a.labelBoxBorderColor,';padding:1px">','<div style="width:',(k-1),"px;height:",(h-1),"px;border:1px solid ",o[D].color,'">','<div style="width:',k,"px;height:",h,"px;",d,B,'"></div>',"</div>","</div>","</td>",'<td class="flotr-legend-label">',j,"</td>")}if(b){N.push("</tr>")}if(N.length>0){var H='<table style="font-size:smaller;color:'+e.grid.color+'">'+N.join("")+"</table>";if(e.legend.container!=null){$(e.legend.container).innerHTML=H}else{var g="",w=e.legend.position,z=e.legend.margin;if(w.charAt(0)=="n"){g+="top:"+(z+q.top)+"px;bottom:auto;"}else{if(w.charAt(0)=="s"){g+="bottom:"+(z+q.bottom)+"px;top:auto;"}}if(w.charAt(1)=="e"){g+="right:"+(z+q.right)+"px;left:auto;"}else{if(w.charAt(1)=="w"){g+="left:"+(z+q.left)+"px;right:auto;"}}var r=this.el.insert('<div class="flotr-legend" style="position:absolute;z-index:2;'+g+'">'+H+"</div>").select("div.flotr-legend")[0];if(e.legend.backgroundOpacity!=0){var K=e.legend.backgroundColor;if(K==null){var J=(e.grid.backgroundColor!=null)?e.grid.backgroundColor:Flotr.Color.extract(r);K=this.processColor(J,null,{opacity:1})}this.el.insert('<div class="flotr-legend-bg" style="position:absolute;width:'+r.getWidth()+"px;height:"+r.getHeight()+"px;"+g+"background-color:"+K+';"> </div>').select("div.flotr-legend-bg")[0].setOpacity(e.legend.backgroundOpacity)}}}}}},getEventPosition:function(a){var e=this.overlay.cumulativeOffset(),d=Event.pointer(a),c=(d.x-e.left-this.plotOffset.left),b=(d.y-e.top-this.plotOffset.top);return{x:this.axes.x.p2d(c),x2:this.axes.x2.p2d(c),y:this.axes.y.p2d(b),y2:this.axes.y2.p2d(b),relX:c,relY:b,absX:d.x,absY:d.y}},clickHandler:function(a){if(this.ignoreClick){return this.ignoreClick=false}this.el.fire("flotr:click",[this.getEventPosition(a),this])},mouseMoveHandler:function(a){var b=this.getEventPosition(a);this.lastMousePos.pageX=b.absX;this.lastMousePos.pageY=b.absY;if(this.options.crosshair.mode){this.clearCrosshair()}if(this.selectionInterval==null&&(this.options.mouse.track||this.series.any(function(c){return c.mouse&&c.mouse.track}))){this.hit(b)}if(this.options.crosshair.mode){this.drawCrosshair(b)}this.el.fire("flotr:mousemove",[a,b,this])},mouseDownHandler:function(c){if(c.isRightClick()){c.stop();var b=this.overlay;b.hide();function a(){b.show();document.stopObserving("mousemove",a)}document.observe("mousemove",a);return}if(!this.options.selection.mode||!c.isLeftClick()){return}this.setSelectionPos(this.selection.first,c);if(this.selectionInterval!=null){clearInterval(this.selectionInterval)}this.lastMousePos.pageX=null;this.selectionInterval=setInterval(this.updateSelection.bindAsEventListener(this),1000/this.options.selection.fps);this.mouseUpHandler=this.mouseUpHandler.bindAsEventListener(this);document.observe("mouseup",this.mouseUpHandler)},fireSelectEvent:function(){var b=this.axes,g=this.selection,d,c,f,e;d=b.x.p2d(g.first.x);c=b.x.p2d(g.second.x);f=b.y.p2d(g.first.y);e=b.y.p2d(g.second.y);this.el.fire("flotr:select",[{x1:Math.min(d,c),y1:Math.min(f,e),x2:Math.max(d,c),y2:Math.max(f,e),xfirst:d,xsecond:c,yfirst:f,ysecond:e},this])},mouseUpHandler:function(a){document.stopObserving("mouseup",this.mouseUpHandler);a.stop();if(this.selectionInterval!=null){clearInterval(this.selectionInterval);this.selectionInterval=null}this.setSelectionPos(this.selection.second,a);this.clearSelection();if(this.selectionIsSane()){this.drawSelection();this.fireSelectEvent();this.ignoreClick=true}},setSelectionPos:function(d,b){var a=this.options,c=this.overlay.cumulativeOffset();if(a.selection.mode.indexOf("x")==-1){d.x=(d==this.selection.first)?0:this.plotWidth}else{d.x=b.pageX-c.left-this.plotOffset.left;d.x=Math.min(Math.max(0,d.x),this.plotWidth)}if(a.selection.mode.indexOf("y")==-1){d.y=(d==this.selection.first)?0:this.plotHeight}else{d.y=b.pageY-c.top-this.plotOffset.top;d.y=Math.min(Math.max(0,d.y),this.plotHeight)}},updateSelection:function(){if(this.lastMousePos.pageX==null){return}this.setSelectionPos(this.selection.second,this.lastMousePos);this.clearSelection();if(this.selectionIsSane()){this.drawSelection()}},clearSelection:function(){if(this.prevSelection==null){return}var g=this.prevSelection,e=this.octx.lineWidth,c=this.plotOffset,a=Math.min(g.first.x,g.second.x),f=Math.min(g.first.y,g.second.y),b=Math.abs(g.second.x-g.first.x),d=Math.abs(g.second.y-g.first.y);this.octx.clearRect(a+c.left-e/2+0.5,f+c.top-e/2+0.5,b+e,d+e);this.prevSelection=null},setSelection:function(b,g){var j=this.options,a=this.axes.x,f=this.axes.y,c=f.scale,h=a.scale,e=j.selection.mode.indexOf("x")!=-1,d=j.selection.mode.indexOf("y")!=-1;this.clearSelection();this.selection.first.y=(e&&!d)?0:(f.max-b.y1)*c;this.selection.second.y=(e&&!d)?this.plotHeight:(f.max-b.y2)*c;this.selection.first.x=(d&&!e)?0:(b.x1-a.min)*h;this.selection.second.x=(d&&!e)?this.plotWidth:(b.x2-a.min)*h;this.drawSelection();if(!g){this.fireSelectEvent()}},drawSelection:function(){var c=this.prevSelection,j=this.selection,g=this.octx,k=this.options,a=this.plotOffset;if(c!=null&&j.first.x==c.first.x&&j.first.y==c.first.y&&j.second.x==c.second.x&&j.second.y==c.second.y){return}g.save();g.strokeStyle=this.processColor(k.selection.color,{opacity:0.8});g.lineWidth=1;g.lineJoin="miter";g.fillStyle=this.processColor(k.selection.color,{opacity:0.4});this.prevSelection={first:{x:j.first.x,y:j.first.y},second:{x:j.second.x,y:j.second.y}};var e=Math.min(j.first.x,j.second.x),d=Math.min(j.first.y,j.second.y),f=Math.abs(j.second.x-j.first.x),b=Math.abs(j.second.y-j.first.y);g.fillRect(e+a.left+0.5,d+a.top+0.5,f,b);g.strokeRect(e+a.left+0.5,d+a.top+0.5,f,b);g.restore()},drawCrosshair:function(f){var d=this.octx,c=this.options,b=this.plotOffset,a=b.left+f.relX+0.5,e=b.top+f.relY+0.5;if(f.relX<0||f.relY<0||f.relX>this.plotWidth||f.relY>this.plotHeight){this.el.style.cursor=null;this.el.removeClassName("flotr-crosshair");return}this.lastMousePos.relX=null;this.lastMousePos.relY=null;if(c.crosshair.hideCursor){this.el.style.cursor=Prototype.Browser.Gecko?"none":"url(blank.cur),crosshair";this.el.addClassName("flotr-crosshair")}d.save();d.strokeStyle=c.crosshair.color;d.lineWidth=1;d.beginPath();if(c.crosshair.mode.indexOf("x")!=-1){d.moveTo(a,b.top);d.lineTo(a,b.top+this.plotHeight);this.lastMousePos.relX=a}if(c.crosshair.mode.indexOf("y")!=-1){d.moveTo(b.left,e);d.lineTo(b.left+this.plotWidth,e);this.lastMousePos.relY=e}d.stroke();d.restore()},clearCrosshair:function(){if(this.lastMousePos.relX!=null){this.octx.clearRect(this.lastMousePos.relX-0.5,this.plotOffset.top,1,this.plotHeight+1)}if(this.lastMousePos.relY!=null){this.octx.clearRect(this.plotOffset.left,this.lastMousePos.relY-0.5,this.plotWidth+1,1)}},selectionIsSane:function(){return Math.abs(this.selection.second.x-this.selection.first.x)>=5&&Math.abs(this.selection.second.y-this.selection.first.y)>=5},clearHit:function(){if(!this.prevHit){return}var e=this.prevHit,f=this.plotOffset,l=e.series,g=l.bars.lineWidth,b=l.pie.lineWidth,a=e.xaxis,j=e.yaxis;if(!l.bars.show&&!l.pie.show&&!l.bubbles.show){var h=l.mouse.radius+g;this.octx.clearRect(f.left+a.d2p(e.x)-h,f.top+j.d2p(e.y)-h,h*2,h*2)}else{if(l.bars.show){var k=l.bars.barWidth;if(!l.bars.horizontal){var c=j.d2p(e.y>=0?e.y:0);if(l.bars.centered){this.octx.clearRect(a.d2p(e.x-k/2)+f.left-g,c+f.top-g,a.d2p(k+a.min)+g*2,j.d2p(e.y<0?e.y:0)-c+g*2)}else{this.octx.clearRect(a.d2p(e.x)+f.left-g,c+f.top-g,a.d2p(k+a.min)+g*2,j.d2p(e.y<0?e.y:0)-c+g*2)}}else{var d=a.d2p(e.x>=0?e.x:0);if(l.bars.centered){this.octx.clearRect(d+f.left+g,j.d2p(e.y+k/2)+f.top-g,a.d2p(e.x<0?e.x:0)-d-g*2,j.d2p(k+j.min)+g*2)}else{this.octx.clearRect(d+f.left+g,j.d2p(e.y+k)+f.top-g,a.d2p(e.x<0?e.x:0)-d-g*2,j.d2p(k+j.min)+g*2)}}}else{if(l.bubbles.show){this.bubbles.clearHit()}else{if(l.pie.show){this.pie.clearHit()}}}}},drawHit:function(f){var l=this.octx,m=f.series,b=f.xaxis,g=f.yaxis;if(m.mouse.lineColor!=null){l.save();l.lineWidth=m.points.lineWidth;l.strokeStyle=m.mouse.lineColor;l.fillStyle=this.processColor(m.mouse.fillColor||"#ffffff",{opacity:m.mouse.fillOpacity});if(!m.bars.show&&!m.pie.show&&!m.bubbles.show){l.translate(this.plotOffset.left,this.plotOffset.top);l.beginPath();l.arc(b.d2p(f.x),g.d2p(f.y),m.mouse.radius,0,2*Math.PI,true);l.fill();l.stroke();l.closePath()}else{if(m.bars.show){l.save();l.translate(this.plotOffset.left,this.plotOffset.top);l.beginPath();if(m.mouse.trackAll){l.moveTo(b.d2p(f.x),g.d2p(0));l.lineTo(b.d2p(f.x),g.d2p(f.yaxis.max))}else{var h=m.bars.barWidth,j=g.d2p(f.y),k=b.d2p(f.x);if(!m.bars.horizontal){var d=g.d2p(g.min<0?0:g.min);if(m.bars.centered){var e=b.d2p(f.x-(h/2)),c=b.d2p(f.x+(h/2));l.moveTo(e,d);l.lineTo(e,j);l.lineTo(c,j);l.lineTo(c,d)}else{var c=b.d2p(f.x+h);l.moveTo(k,d);l.lineTo(k,j);l.lineTo(c,j);l.lineTo(c,d)}}else{var e=b.d2p(b.min<0?0:b.min);if(m.bars.centered){var d=g.d2p(f.y-(h/2)),a=g.d2p(f.y+(h/2));l.moveTo(e,d);l.lineTo(k,d);l.lineTo(k,a);l.lineTo(e,a)}else{var a=g.d2p(f.y+h);l.moveTo(e,j);l.lineTo(k,j);l.lineTo(k,a);l.lineTo(e,a)}}if(m.mouse.fillColor){l.fill()}}l.stroke();l.closePath();l.restore()}else{if(m.bubbles.show){this.bubbles.drawHit(f)}else{if(m.pie.show){this.pie.drawHit(f)}}}}l.restore()}this.prevHit=f},newHit:function(d){var f=this.series,c=this.options,a,b;for(var e=f.length-1;e>-1;--e){s=f[e];if(!s.mouse.track){continue}for(var j in Flotr.graphTypes){if(!this[j].getHit){continue}var g=this[j].getHit(s,d);if(g.index!==undefined){a=s.mouse.trackDecimals;if(a==null||a<0){a=0}b=s.mouse.trackFormatter(g);this.drawTooltip(b,g.x,g.y,s.mouse);this.mouseTrack.fire("flotr:hit",[g,this])}}}},hit:function(O){var h=this.series,I=this.options,e=this.prevHit,G=this.plotOffset,ah=this.octx,ad,D,L,v,S,Q,X,J,g,f,ac,Z={dist:Number.MAX_VALUE,x:null,y:null,relX:O.relX,relY:O.relY,absX:O.absX,absY:O.absY,sAngle:null,eAngle:null,fraction:null,mouse:null,xaxis:null,yaxis:null,series:null,index:null,seriesIndex:null};if(I.mouse.trackAll){for(ac=0;ac<h.length;ac++){U=h[0];ad=U.data;X=U.xaxis;J=U.yaxis;L=(2*I.points.lineWidth)/X.scale*U.mouse.sensibility;g=X.p2d(O.relX);f=J.p2d(O.relY);for(var ab=0;ab<ad.length;ab++){S=ad[ab][0];Q=ad[ab][1];if(Q===null||X.min>S||X.max<S||J.min>Q||J.max<Q||g<X.min||g>X.max||f<J.min||f>J.max){continue}var P=Math.abs(S-g);if((!U.bars.show&&P<L)||(U.bars.show&&P<U.bars.barWidth/2)||(Q<0&&f<0&&f>Q)){var E=P;if(E<Z.dist){Z.dist=E;Z.x=S;Z.y=Q;Z.xaxis=X;Z.yaxis=J;Z.mouse=U.mouse;Z.series=U;Z.allSeries=h;Z.index=ab}}}}}else{if(!I.pie.show){for(ac=0;ac<h.length;ac++){U=h[ac];if(!U.mouse.track){continue}ad=U.data;X=U.xaxis;J=U.yaxis;D=2*I.points.lineWidth*U.mouse.sensibility;L=D/X.scale;v=D/J.scale;g=X.p2d(O.relX);f=J.p2d(O.relY);for(var ab=0,Y,o;ab<ad.length;ab++){S=ad[ab][0];Q=ad[ab][1];if(Q===null||X.min>S||X.max<S||J.min>Q||J.max<Q){continue}var P,F;if(U.bars.show&&!U.bars.centered){if(U.bars.horizontal){P=Math.abs(S-g);F=Math.abs(Q+U.bars.barWidth/2-f)}else{P=Math.abs(S+U.bars.barWidth/2-g);F=Math.abs(Q-f)}}else{P=Math.abs(S-g);F=Math.abs(Q-f)}if(((!U.bars.show)&&P<L&&(!U.mouse.trackY||F<v))||(U.bars.show&&(!U.bars.horizontal&&P<U.bars.barWidth/2+1/X.scale&&(!U.mouse.trackY||(Q>0&&f>0&&f<Q)||(Q<0&&f<0&&f>Q)))||(U.bars.horizontal&&F<U.bars.barWidth/2+1/J.scale&&((S>0&&g>0&&g<S)||(S<0&&g<0&&g>S))))){var E=Math.sqrt(P*P+F*F);if(E<Z.dist){Z.dist=E;Z.x=S;Z.y=Q;Z.xaxis=X;Z.yaxis=J;Z.mouse=U.mouse;Z.series=U;Z.allSeries=h;Z.index=ab;Z.seriesIndex=ac}}}}}else{var V=(Math.min(this.canvasWidth,this.canvasHeight)*I.pie.sizeRatio)/2,u=1,d={x:(this.plotWidth)/2,y:(this.plotHeight)/2},t=this.series.collect(function(b,a){if(b.pie.show&&b.data[0][1]!==null){return{name:(b.label||b.data[0][1]),value:[a,b.data[0][1]],options:b.pie,series:b}}}),A=t.pluck("value").pluck(1).inject(0,function(a,b){return a+b}),z=0,C=I.pie.startAngle,T=0;var r=t.collect(function(a){C+=z;T=parseFloat(a.value[1]);z=T/A;return{name:a.name,fraction:z,x:a.value[0],y:T,value:T,options:a.options,series:a.series,startAngle:2*C*Math.PI,endAngle:2*(C+z)*Math.PI}});for(ac=0;ac<h.length;ac++){U=h[ac];S=U.data[0][0];Q=U.data[0][1];if(Q===null){continue}var ag=(O.relX-d.x),af=(O.relY-d.y),ae=Math.sqrt(Math.pow(ag,2)+Math.pow(af,2)),H=(r[ac].startAngle)%(2*Math.PI),q=(r[ac].endAngle)%(2*Math.PI),H=(H>0)?H:H+(2*Math.PI),q=(q>0)?q:q+(2*Math.PI),l=af/ae,R=Math.asin(l)%(2*Math.PI),R=(R>0)?R:R+(2*Math.PI),w=Math.asin(-l)+(Math.PI);if(ae<V+10&&((((ag>0&&H<R&&q>R))||(ag<0&&H<w&&q>w))||((H>q||r[ac].fraction==1)&&((ag>0&&(H<R||q>R))||(ag<0&&(H<w||q>w)))))){Z.x=S;Z.y=Q;Z.sAngle=H;Z.eAngle=q,Z.mouse=U.mouse;Z.series=U;Z.allSeries=h;Z.seriesIndex=ac;Z.fraction=r[ac].fraction}}}}if(Z.series&&(Z.mouse&&Z.mouse.track&&!e||(e))){var k=this.mouseTrack,N="",U=Z.series,W=Z.mouse.position,aa=Z.mouse.margin,M="opacity:0.7;background-color:#000;color:#fff;display:none;position:absolute;padding:2px 8px;-moz-border-radius:4px;border-radius:4px;white-space:nowrap;";if(!Z.mouse.relative){if(W.charAt(0)=="n"){N+="top:"+(aa+G.top)+"px;bottom:auto;"}else{if(W.charAt(0)=="s"){N+="bottom:"+(aa+G.bottom)+"px;top:auto;"}}if(W.charAt(1)=="e"){N+="right:"+(aa+G.right)+"px;left:auto;"}else{if(W.charAt(1)=="w"){N+="left:"+(aa+G.left)+"px;right:auto;"}}}else{if(!U.bars.show&&!U.pie.show){if(W.charAt(0)=="n"){N+="bottom:"+(aa-G.top-Z.yaxis.d2p(Z.y)+this.canvasHeight)+"px;top:auto;"}else{if(W.charAt(0)=="s"){N+="top:"+(aa+G.top+Z.yaxis.d2p(Z.y))+"px;bottom:auto;"}}if(W.charAt(1)=="e"){N+="left:"+(aa+G.left+Z.xaxis.d2p(Z.x))+"px;right:auto;"}else{if(W.charAt(1)=="w"){N+="right:"+(aa-G.left-Z.xaxis.d2p(Z.x)+this.canvasWidth)+"px;left:auto;"}}}else{if(U.bars.show){N+="bottom:"+(aa-G.top-Z.yaxis.d2p(Z.y/2)+this.canvasHeight)+"px;top:auto;";N+="left:"+(aa+G.left+Z.xaxis.d2p(Z.x-I.bars.barWidth/2))+"px;right:auto;"}else{var d={x:(this.plotWidth)/2,y:(this.plotHeight)/2},V=(Math.min(this.canvasWidth,this.canvasHeight)*U.pie.sizeRatio)/2,B=Z.sAngle<Z.eAngle?(Z.sAngle+Z.eAngle)/2:(Z.sAngle+Z.eAngle+2*Math.PI)/2;N+="bottom:"+(aa-G.top-d.y-Math.sin(B)*V/2+this.canvasHeight)+"px;top:auto;";N+="left:"+(aa+G.left+d.x+Math.cos(B)*V/2)+"px;right:auto;"}}}M+=N;if(!k){this.el.insert('<div class="flotr-mouse-value" style="'+M+'"></div>');k=this.mouseTrack=this.el.select(".flotr-mouse-value")[0]}else{k.style.cssText=M;this.mouseTrack=k}if(Z.x!==null&&Z.y!==null){k.show();this.clearHit();this.drawHit(Z);var K=Z.mouse.trackDecimals;if(K==null||K<0){K=0}k.innerHTML=Z.mouse.trackFormatter({x:Z.x.toFixed(K),y:Z.y.toFixed(K),series:Z.series,index:Z.index,nearest:Z,fraction:Z.fraction});k.fire("flotr:hit",[Z,this])}else{if(e){k.hide();this.clearHit()}}}else{if(this.prevHit){this.mouseTrack.hide();this.clearHit()}}},drawTooltip:function(f,h,g,j){var a=this.mouseTrack,b="opacity:0.7;background-color:#000;color:#fff;display:none;position:absolute;padding:2px 8px;-moz-border-radius:4px;border-radius:4px;white-space:nowrap;",c=j.position,e=j.margin,d=this.plotOffset;if(!a){this.el.insert('<div class="flotr-mouse-value"></div>');a=this.mouseTrack=this.el.select(".flotr-mouse-value")[0]}if(h!==null&&g!==null){if(!j.relative){if(c.charAt(0)=="n"){b+="top:"+(e+d.top)+"px;bottom:auto;"}else{if(c.charAt(0)=="s"){b+="bottom:"+(e+d.bottom)+"px;top:auto;"}}if(c.charAt(1)=="e"){b+="right:"+(e+d.right)+"px;left:auto;"}else{if(c.charAt(1)=="w"){b+="left:"+(e+d.left)+"px;right:auto;"}}}else{if(c.charAt(0)=="n"){b+="bottom:"+(e-d.top-g+this.canvasHeight)+"px;top:auto;"}else{if(c.charAt(0)=="s"){b+="top:"+(e+d.top+g)+"px;bottom:auto;"}}if(c.charAt(1)=="e"){b+="left:"+(e+d.left+h)+"px;right:auto;"}else{if(c.charAt(1)=="w"){b+="right:"+(e-d.left-h+this.canvasWidth)+"px;left:auto;"}}}a.style.cssText=b;a.update(f).show()}else{a.hide()}},saveImage:function(d,c,a,b){var e=null;if(Prototype.Browser.IE&&!Flotr.isIE9){e="<html><body>"+this.canvas.firstChild.innerHTML+"</body></html>";return window.open().document.write(e)}switch(d){case"jpeg":case"jpg":e=Canvas2Image.saveAsJPEG(this.canvas,b,c,a);break;default:case"png":e=Canvas2Image.saveAsPNG(this.canvas,b,c,a);break;case"bmp":e=Canvas2Image.saveAsBMP(this.canvas,b,c,a);break}if(Object.isElement(e)&&b){this.restoreCanvas();this.canvas.hide();this.overlay.hide();this.el.insert(e.setStyle({position:"absolute"}))}},restoreCanvas:function(){this.canvas.show();this.overlay.show();this.el.select("img").invoke("remove")}});Flotr.Color=Class.create({initialize:function(h,f,d,e){this.rgba=["r","g","b","a"];var c=4;while(-1<--c){this[this.rgba[c]]=arguments[c]||((c==3)?1:0)}this.normalize()},adjust:function(d,c,e,b){var a=4;while(-1<--a){if(arguments[a]!=null){this[this.rgba[a]]+=arguments[a]}}return this.normalize()},scale:function(d,c,e,b){var a=4;while(-1<--a){if(arguments[a]!=null){this[this.rgba[a]]*=arguments[a]}}return this.normalize()},clone:function(){return new Flotr.Color(this.r,this.b,this.g,this.a)},limit:function(b,a,c){return Math.max(Math.min(b,c),a)},normalize:function(){var a=this.limit;this.r=a(parseInt(this.r),0,255);this.g=a(parseInt(this.g),0,255);this.b=a(parseInt(this.b),0,255);this.a=a(this.a,0,1);return this},distance:function(b){if(!b){return}b=new Flotr.Color.parse(b);var c=0,a=3;while(-1<--a){c+=Math.abs(this[this.rgba[a]]-b[this.rgba[a]])}return c},toString:function(){return(this.a>=1)?"rgb("+[this.r,this.g,this.b].join(",")+")":"rgba("+[this.r,this.g,this.b,this.a].join(",")+")"}});Object.extend(Flotr.Color,{parse:function(b){if(b instanceof Flotr.Color){return b}var a,d=Flotr.Color;if((a=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(b))){return new d(parseInt(a[1],16),parseInt(a[2],16),parseInt(a[3],16))}if((a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(b))){return new d(parseInt(a[1]),parseInt(a[2]),parseInt(a[3]))}if((a=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(b))){return new d(parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16))}if((a=/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(b))){return new d(parseInt(a[1]),parseInt(a[2]),parseInt(a[3]),parseFloat(a[4]))}if((a=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(b))){return new d(parseFloat(a[1])*2.55,parseFloat(a[2])*2.55,parseFloat(a[3])*2.55)}if((a=/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(b))){return new d(parseFloat(a[1])*2.55,parseFloat(a[2])*2.55,parseFloat(a[3])*2.55,parseFloat(a[4]))}var c=(b+"").strip().toLowerCase();if(c=="transparent"){return new d(255,255,255,0)}return(a=d.names[c])?new d(a[0],a[1],a[2]):new d(0,0,0,0)},extract:function(b){var a;do{a=b.getStyle("background-color").toLowerCase();if(!(a==""||a=="transparent")){break}b=b.up()}while(!b.nodeName.match(/^body$/i));return new Flotr.Color(a=="rgba(0, 0, 0, 0)"?"transparent":a)},names:{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]}});Flotr.Date={format:function(j,h){if(!j){return}var g={h:j.getUTCHours().toString(),H:a(j.getUTCHours()),M:a(j.getUTCMinutes()),S:a(j.getUTCSeconds()),s:j.getUTCMilliseconds(),d:j.getUTCDate().toString(),m:(j.getUTCMonth()+1).toString(),y:j.getUTCFullYear().toString(),b:Flotr.Date.monthNames[j.getUTCMonth()]};function a(c){c+="";return c.length==1?"0"+c:c}var f=[],k,e=false;for(var b=0;b<h.length;++b){k=h.charAt(b);if(e){f.push(g[k]||k);e=false}else{if(k=="%"){e=true}else{f.push(k)}}}return f.join("")},getFormat:function(c,b){var a=Flotr.Date.timeUnits;if(c<a.second){return"%h:%M:%S.%s"}else{if(c<a.minute){return"%h:%M:%S"}else{if(c<a.day){return(b<2*a.day)?"%h:%M":"%b %d %h:%M"}else{if(c<a.month){return"%b %d"}else{if(c<a.year){return(b<a.year)?"%b":"%b %y"}else{return"%y"}}}}}},formatter:function(a,e){var f=new Date(a);if(e.options.timeFormat!=null){return Flotr.Date.format(f,e.options.timeFormat)}var c=e.max-e.min,b=e.tickSize*Flotr.Date.timeUnits[e.tickUnit];return Flotr.Date.format(f,Flotr.Date.getFormat(b,c))},generator:function(c){var j=[],h=new Date(c.min),g=Flotr.Date.timeUnits;var b=c.tickSize*g[c.tickUnit];switch(c.tickUnit){case"millisecond":h.setUTCMilliseconds(Flotr.floorInBase(h.getUTCMilliseconds(),c.tickSize));break;case"second":h.setUTCSeconds(Flotr.floorInBase(h.getUTCSeconds(),c.tickSize));break;case"minute":h.setUTCMinutes(Flotr.floorInBase(h.getUTCMinutes(),c.tickSize));break;case"hour":h.setUTCHours(Flotr.floorInBase(h.getUTCHours(),c.tickSize));break;case"month":h.setUTCMonth(Flotr.floorInBase(h.getUTCMonth(),c.tickSize));break;case"year":h.setUTCFullYear(Flotr.floorInBase(h.getUTCFullYear(),c.tickSize));break}if(b>=g.second){h.setUTCMilliseconds(0)}if(b>=g.minute){h.setUTCSeconds(0)}if(b>=g.hour){h.setUTCMinutes(0)}if(b>=g.day){h.setUTCHours(0)}if(b>=g.day*4){h.setUTCDate(1)}if(b>=g.year){h.setUTCMonth(0)}var l=0,k=Number.NaN,e;do{e=k;k=h.getTime();j.push({v:k,label:Flotr.Date.formatter(k,c)});if(c.tickUnit=="month"){if(c.tickSize<1){h.setUTCDate(1);var a=h.getTime();h.setUTCMonth(h.getUTCMonth()+1);var f=h.getTime();h.setTime(k+l*g.hour+(f-a)*c.tickSize);l=h.getUTCHours();h.setUTCHours(0)}else{h.setUTCMonth(h.getUTCMonth()+c.tickSize)}}else{if(c.tickUnit=="year"){h.setUTCFullYear(h.getUTCFullYear()+c.tickSize)}else{h.setTime(k+b)}}}while(k<c.max&&k!=e);return j},timeUnits:{millisecond:1,second:1000,minute:1000*60,hour:1000*60*60,day:1000*60*60*24,month:1000*60*60*24*30,year:1000*60*60*24*365.2425},spec:[[1,"millisecond"],[20,"millisecond"],[50,"millisecond"],[100,"millisecond"],[200,"millisecond"],[500,"millisecond"],[1,"second"],[2,"second"],[5,"second"],[10,"second"],[30,"second"],[1,"minute"],[2,"minute"],[5,"minute"],[10,"minute"],[30,"minute"],[1,"hour"],[2,"hour"],[4,"hour"],[8,"hour"],[12,"hour"],[1,"day"],[2,"day"],[3,"day"],[0.25,"month"],[0.5,"month"],[1,"month"],[2,"month"],[3,"month"],[6,"month"],[1,"year"]],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]};Flotr.addType("lines",{options:{show:false,lineWidth:2,fill:false,fillColor:null,fillOpacity:0.4,stacked:false},draw:function(c){c=c||this.series;var b=this.ctx;b.save();b.translate(this.plotOffset.left,this.plotOffset.top);b.lineJoin="round";var d=c.lines.lineWidth;var a=c.shadowSize;if(a>0){b.lineWidth=a/2;var e=d/2+b.lineWidth/2;b.strokeStyle="rgba(0,0,0,0.1)";this.lines.plot(c,e+a/2,false);b.strokeStyle="rgba(0,0,0,0.2)";this.lines.plot(c,e,false);if(c.lines.fill){b.fillStyle="rgba(0,0,0,0.05)";this.lines.plotArea(c,e+a/2,false)}}b.lineWidth=d;b.strokeStyle=c.color;if(c.lines.fill){b.fillStyle=this.processColor(c.lines.fillColor||c.color,{opacity:c.lines.fillOpacity});this.lines.plotArea(c,0,true)}this.lines.plot(c,0,true);b.restore()},plot:function(j,f,u){var m=this.ctx,r=j.xaxis,b=j.yaxis,v=j.data,d=v.length-1,o;if(v.length<2){return}var h=this.plotWidth,n=this.plotHeight,l=null,k=null;m.beginPath();for(o=0;o<d;++o){if(v[o][1]===null||v[o+1][1]===null){continue}if(r.options.scaling==="logarithmic"&&(v[o][0]<=0||v[o+1][0]<=0)){continue}if(b.options.scaling=="logarithmic"&&(v[o][1]<=0||v[o+1][1]<=0)){continue}var t=r.d2p(v[o][0]),c,q=r.d2p(v[o+1][0]),a;if(j.lines.stacked){var g=r.values[v[o][0]].stack||0,e=r.values[v[o+1][0]].stack||r.values[v[o][0]].stack||0;c=b.d2p(v[o][1]+g);a=b.d2p(v[o+1][1]+e);if(u){r.values[v[o][0]].stack=v[o][1]+g;if(o==d-1){r.values[v[o+1][0]].stack=v[o+1][1]+e}}}else{c=b.d2p(v[o][1]);a=b.d2p(v[o+1][1])}if(c>=a&&c>=n){if(a>=n){continue}t=t-(c-n-1)/(a-c)*(q-t);c=n-1}else{if(a>=c&&a>=n){if(c>=n){continue}q=t-(c-n-1)/(a-c)*(q-t);a=n-1}}if(c<=a&&c<0){if(a<0){continue}t=t-c/(a-c)*(q-t);c=0}else{if(a<=c&&a<0){if(c<0){continue}q=t-c/(a-c)*(q-t);a=0}}if(t<=q&&t<0){if(q<0){continue}c=c-t/(q-t)*(a-c);t=0}else{if(q<=t&&q<0){if(t<0){continue}a=c-t/(q-t)*(a-c);q=0}}if(t>=q&&t>=h){if(q>=h){continue}c=c+(h-t)/(q-t)*(a-c);t=h-1}else{if(q>=t&&q>=h){if(t>=h){continue}a=c+(h-t)/(q-t)*(a-c);q=h-1}}if((l!=t)||(k!=c+f)){m.moveTo(t,c+f)}l=q;k=a+f;m.lineTo(l,k)}m.stroke();m.closePath()},plotArea:function(t,j,I){var B=this.ctx,F=t.xaxis,b=t.yaxis,J=t.data,g=J.length-1,x,q=Math.min(Math.max(0,b.min),b.max),n=0,m=true,H=[],w=0,k=0,h=0;function K(M,L){if(I){H[w]=[];H[w][0]=M;H[w][1]=L;w++}}if(J.length<2){return}B.beginPath();for(var D=0;D<g;++D){var G=J[D][0],d,E=J[D+1][0],a;if(t.lines.stacked){var k=F.values[J[D][0]].stack||0,h=F.values[J[D+1][0]].stack||F.values[J[D][0]].stack||0;d=J[D][1]+k;a=J[D+1][1]+h}else{d=J[D][1];a=J[D+1][1]}if(G<=E&&G<F.min){if(E<F.min){continue}d=(F.min-G)/(E-G)*(a-d)+d;G=F.min}else{if(E<=G&&E<F.min){if(G<F.min){continue}a=(F.min-G)/(E-G)*(a-d)+d;E=F.min}}if(G>=E&&G>F.max){if(E>F.max){continue}d=(F.max-G)/(E-G)*(a-d)+d;G=F.max}else{if(E>=G&&E>F.max){if(G>F.max){continue}a=(F.max-G)/(E-G)*(a-d)+d;E=F.max}}var c=F.d2p(G),o=F.d2p(E),f=b.d2p(b.max),e=b.d2p(b.min);if(m){B.moveTo(c,b.d2p(q+k)+j);K(c,b.d2p(q+k)+j);m=false}n=Math.max(E,n);if(d>=b.max&&a>=b.max){B.lineTo(c,f+j);B.lineTo(o,f+j);K(c,f+j);K(o,f+j);continue}else{if(d<=b.min&&a<=b.min){B.lineTo(c,e+j);B.lineTo(o,e+j);K(c,e+j);K(o,e+j);continue}}var r=G,v=E;if(d<=a&&d<b.min&&a>=b.min){G=(b.min-d)/(a-d)*(E-G)+G;d=b.min}else{if(a<=d&&a<b.min&&d>=b.min){E=(b.min-d)/(a-d)*(E-G)+G;a=b.min}}if(d>=a&&d>b.max&&a<=b.max){G=(b.max-d)/(a-d)*(E-G)+G;d=b.max}else{if(a>=d&&a>b.max&&d<=b.max){E=(b.max-d)/(a-d)*(E-G)+G;a=b.max}}var A=F.d2p(G),C=F.d2p(E),l=b.d2p(d),u=b.d2p(a);if(G!=r){x=(d<=b.min)?e:f;B.lineTo(c,x+j);B.lineTo(A,x+j);K(c,x+j);K(A,x+j)}B.lineTo(A,l+j);B.lineTo(C,u+j);K(A,l+j);K(C,u+j);if(E!=v){x=(a<=b.min)?e:f;B.lineTo(o,x+j);K(o,x+j)}n=Math.max(E,v,n)}B.lineTo(F.d2p(n),b.d2p(q)+j);K(F.d2p(n),b.d2p(q)+j);var z=F.lastStrokePath;if(t.lines.stacked){if(z){for(var D=z.length-1;D>=0;--D){B.lineTo(z[D][0],z[D][1]-j/2)}}if(I){F.lastStrokePath=H}}B.closePath();B.fill()},extendYRange:function(b){if(b.options.max==null||b.options.min==null){var h=b.max,c=b.min,m,f,e,n,d,a={},k={},g=null;for(f=0;f<this.series.length;++f){n=this.series[f];d=n.lines;if(d.show&&!n.hide&&n.yaxis==b){if(d.stacked){for(e=0;e<n.data.length;e++){m=n.data[e][0]+"";if(n.data[e][1]>0){a[m]=(a[m]||0)+n.data[e][1]}else{k[m]=(k[m]||0)+n.data[e][1]}g=n}for(e in a){h=Math.max(a[e],h)}for(e in k){c=Math.min(k[e],c)}}}}b.lastSerie=g;b.max=h;b.min=c}}});Flotr.addType("bars",{options:{show:false,lineWidth:2,barWidth:1,fill:true,fillColor:null,fillOpacity:0.4,horizontal:false,stacked:false,centered:true},draw:function(c){var a=this.ctx,e=c.bars.barWidth,d=Math.min(c.bars.lineWidth,e);a.save();a.translate(this.plotOffset.left,this.plotOffset.top);a.lineJoin="miter";a.lineWidth=d;a.strokeStyle=c.color;a.save();this.bars.plotShadows(c,e,0,c.bars.fill);a.restore();if(c.bars.fill){var b=c.bars.fillColor||c.color;a.fillStyle=this.processColor(b,{opacity:c.bars.fillOpacity})}this.bars.plot(c,e,0,c.bars.fill);a.restore()},plot:function(m,r,e,u){var D=m.data;if(D.length<1){return}var z=m.xaxis,c=m.yaxis,t=this.ctx,w;for(w=0;w<D.length;w++){var l=D[w][0],j=D[w][1],g=true,n=true,a=true;if(j===null){continue}var o=0;var f=0;if(m.bars.stacked){if(m.bars.horizontal){o=c.values[j].stackPos||0;f=c.values[j].stackNeg||0;if(l>0){c.values[j].stackPos=o+l}else{c.values[j].stackNeg=f+l}}else{o=z.values[l].stackPos||0;f=z.values[l].stackNeg||0;if(j>0){z.values[l].stackPos=o+j}else{z.values[l].stackNeg=f+j}}}var k=m.bars.centered?r/2:0;if(m.bars.horizontal){if(l>0){var d=o,A=l+o}else{var A=f,d=l+f}var h=j-k,q=j+r-k}else{if(j>0){var h=o,q=j+o}else{var q=f,h=j+f}var d=l-k,A=l+r-k}if(A<z.min||d>z.max||q<c.min||h>c.max){continue}if(d<z.min){d=z.min;g=false}if(A>z.max){A=z.max;if(z.lastSerie!=m&&m.bars.horizontal){n=false}}if(h<c.min){h=c.min}if(q>c.max){q=c.max;if(c.lastSerie!=m&&!m.bars.horizontal){n=false}}var b=z.d2p(d),v=z.d2p(A),C=c.d2p(q),B=c.d2p(h);if(u){t.fillRect(b,C,v-b,B-C)}if(m.bars.lineWidth!=0&&(g||a||n)){t.beginPath();t.moveTo(b,B+e);t[g?"lineTo":"moveTo"](b,C+e);t[n?"lineTo":"moveTo"](v,C+e);t[a?"lineTo":"moveTo"](v,B+e);t.stroke();t.closePath()}}},plotShadows:function(j,m,c){var w=j.data;if(w.length<1){return}var t,h,f,u=j.xaxis,a=j.yaxis,r=this.ctx,o=this.options.shadowSize;for(t=0;t<w.length;t++){h=w[t][0];f=w[t][1];if(f===null){continue}var k=0;var d=0;if(j.bars.stacked){if(j.bars.horizontal){k=a.values[f].stackShadowPos||0;d=a.values[f].stackShadowNeg||0;if(h>0){a.values[f].stackShadowPos=k+h}else{a.values[f].stackShadowNeg=d+h}}else{k=u.values[h].stackShadowPos||0;d=u.values[h].stackShadowNeg||0;if(f>0){u.values[h].stackShadowPos=k+f}else{u.values[h].stackShadowNeg=d+f}}}var g=j.bars.centered?m/2:0;if(j.bars.horizontal){if(h>0){var b=k,v=h+k}else{var v=d,b=h+d}var e=f-g,l=f+m-g}else{if(f>0){var e=k,l=f+k}else{var l=d,e=f+d}var b=h-g,v=h+m-g}if(v<u.min||b>u.max||l<a.min||e>a.max){continue}if(b<u.min){b=u.min}if(v>u.max){v=u.max}if(e<a.min){e=a.min}if(l>a.max){l=a.max}var q=u.d2p(v)-u.d2p(b)-((u.d2p(v)+o<=this.plotWidth)?0:o);var n=a.d2p(e)-a.d2p(l)-((a.d2p(e)+o<=this.plotHeight)?0:o);r.fillStyle="rgba(0,0,0,0.05)";r.fillRect(Math.min(u.d2p(b)+o,this.plotWidth),Math.min(a.d2p(l)+o,this.plotHeight),q,n)}},extendXRange:function(c){if(c.options.max==null){var d=c.min,h=c.max,f,e,m,n,k,a={},l={},g=null;for(f=0;f<this.series.length;++f){n=this.series[f];k=n.bars;if(k.show&&n.xaxis==c){if(k.centered&&!k.horizontal){h=Math.max(c.datamax+0.5,h);d=Math.min(c.datamin-0.5,d)}if(!k.horizontal&&(k.barWidth+c.datamax>h)){h=c.max+(k.centered?k.barWidth/2:k.barWidth)}if(k.stacked&&k.horizontal){for(e=0;e<n.data.length;e++){if(k.show&&k.stacked){y=n.data[e][1]+"";if(n.data[e][0]>0){a[y]=(a[y]||0)+n.data[e][0]}else{l[y]=(l[y]||0)+n.data[e][0]}g=n}}for(e in a){h=Math.max(a[e],h)}for(e in l){d=Math.min(l[e],d)}}}}c.lastSerie=g;c.max=h;c.min=d}},extendYRange:function(c){if(c.options.max==null){var h=c.max,d=c.min,m,f,e,n,k,a={},l={},g=null;for(f=0;f<this.series.length;++f){n=this.series[f];k=n.bars;if(k.show&&!n.hide&&n.yaxis==c){if(k.centered&&k.horizontal){h=Math.max(c.datamax+0.5,h);d=Math.min(c.datamin-0.5,d)}if(k.horizontal&&(k.barWidth+c.datamax>h)){h=c.max+k.barWidth}if(k.stacked&&!k.horizontal){for(e=0;e<n.data.length;e++){if(n.bars.show&&n.bars.stacked){m=n.data[e][0]+"";if(n.data[e][1]>0){a[m]=(a[m]||0)+n.data[e][1]}else{l[m]=(l[m]||0)+n.data[e][1]}g=n}}for(e in a){h=Math.max(a[e],h)}for(e in l){d=Math.min(l[e],d)}}}}c.lastSerie=g;c.max=h;c.min=d}}});Flotr.addType("points",{options:{show:false,radius:3,lineWidth:2,fill:true,fillColor:"#FFFFFF",fillOpacity:0.4},draw:function(c){var b=this.ctx,d=c.lines.lineWidth,a=c.shadowSize;b.save();b.translate(this.plotOffset.left,this.plotOffset.top);if(a>0){b.lineWidth=a/2;b.strokeStyle="rgba(0,0,0,0.1)";this.points.plotShadows(c,a/2+b.lineWidth/2,c.points.radius);b.strokeStyle="rgba(0,0,0,0.2)";this.points.plotShadows(c,b.lineWidth/2,c.points.radius)}b.lineWidth=c.points.lineWidth;b.strokeStyle=c.color;b.fillStyle=c.points.fillColor!=null?c.points.fillColor:c.color;this.points.plot(c,c.points.radius,c.points.fill);b.restore()},plot:function(c,e,h){var a=c.xaxis,f=c.yaxis,j=this.ctx,d,g,b=c.data;for(d=b.length-1;d>-1;--d){g=b[d][0],y=b[d][1];if(y===null||g<a.min||g>a.max||y<f.min||y>f.max){continue}j.beginPath();j.arc(a.d2p(g),f.d2p(y),e,0,2*Math.PI,true);if(h){j.fill()}j.stroke();j.closePath()}},plotShadows:function(d,b,f){var a=d.xaxis,g=d.yaxis,j=this.ctx,e,h,c=d.data;for(e=c.length-1;e>-1;--e){h=c[e][0],y=c[e][1];if(y===null||h<a.min||h>a.max||y<g.min||y>g.max){continue}j.beginPath();j.arc(a.d2p(h),g.d2p(y)+b,f,0,Math.PI,false);j.stroke();j.closePath()}},getHit:function(g,n){var e,c,h,j,l,q,m,b=g.points,f=g.data,k=g.mouse.sensibility*(b.lineWidth+b.radius),a={index:null,series:g,distance:Number.MAX_VALUE,x:null,y:null,precision:1};for(h=f.length-1;h>-1;--h){j=f[h];q=g.xaxis.d2p(j[0]);m=g.yaxis.d2p(j[1]);e=q-n.relX;c=m-n.relY;l=Math.sqrt(e*e+c*c);if(l<k&&l<a.distance){a={index:h,series:g,distance:l,data:j,x:q,y:m,precision:1}}}return a},drawHit:function(b,a){},clearHit:function(b,a){}});Flotr.defaultPieLabelFormatter=function(a){return(a.fraction*100).toFixed(2)+"%"};Flotr.addType("pie",{options:{show:false,lineWidth:1,fill:true,fillColor:null,fillOpacity:0.6,explode:6,sizeRatio:0.6,startAngle:Math.PI/4,labelFormatter:Flotr.defaultPieLabelFormatter,pie3D:false,pie3DviewAngle:(Math.PI/2*0.8),pie3DspliceThickness:20},draw:function(g){if(this.options.pie.drawn){return}var m=this.ctx,c=this.options,e=g.pie.lineWidth,k=g.shadowSize,v=g.data,h=this.plotOffset,d=(Math.min(this.canvasWidth,this.canvasHeight)*g.pie.sizeRatio)/2,j=[],n=1,t=Math.sin(g.pie.viewAngle)*g.pie.spliceThickness/n,o={size:c.fontSize*1.2,color:c.grid.color,weight:1.5},u={x:h.left+(this.plotWidth)/2,y:h.top+(this.plotHeight)/2},r=this.series.collect(function(x,w){if(x.pie.show&&x.data[0][1]!==null){return{name:(x.label||x.data[0][1]),value:[w,x.data[0][1]],options:x.pie,series:x}}}),b=r.pluck("value").pluck(1).inject(0,function(w,x){return w+x}),f=0,q=g.pie.startAngle,l=0;var a=r.collect(function(w){q+=f;l=parseFloat(w.value[1]);f=l/b;return{name:w.name,fraction:f,x:w.value[0],y:l,value:l,options:w.options,series:w.series,startAngle:2*q*Math.PI,endAngle:2*(q+f)*Math.PI}});m.save();if(k>0){a.each(function(A){if(A.startAngle==A.endAngle){return}var w=(A.startAngle+A.endAngle)/2,x=u.x+Math.cos(w)*A.options.explode+k,z=u.y+Math.sin(w)*A.options.explode+k;this.pie.plotSlice(x,z,d,A.startAngle,A.endAngle,false,n);if(g.pie.fill){m.fillStyle="rgba(0,0,0,0.1)";m.fill()}},this)}if(c.HtmlText||!this.textEnabled){j=['<div style="color:'+this.options.grid.color+'" class="flotr-labels">']}a.each(function(K,F){if(K.startAngle==K.endAngle){return}var E=(K.startAngle+K.endAngle)/2,C=K.series.color,x=K.options.fillColor||C,G=u.x+Math.cos(E)*K.options.explode,A=u.y+Math.sin(E)*K.options.explode;this.pie.plotSlice(G,A,d,K.startAngle,K.endAngle,false,n);if(g.pie.fill){m.fillStyle=this.processColor(x,{opacity:g.pie.fillOpacity});m.fill()}m.lineWidth=e;m.strokeStyle=C;m.stroke();var J=c.pie.labelFormatter(K),w=(Math.cos(E)<0),L=(Math.sin(E)>0),B=(K.options.explode||g.pie.explode)+d+4,I=u.x+Math.cos(E)*B,H=u.y+Math.sin(E)*B;if(K.fraction&&J){if(c.HtmlText||!this.textEnabled){var D=L?(H-5):(this.plotHeight-H+5),z="position:absolute;"+(L?"top":"bottom")+":"+D+"px;";if(w){z+="right:"+(this.canvasWidth-I)+"px;text-align:right;"}else{z+="left:"+I+"px;text-align:left;"}j.push('<div style="',z,'" class="flotr-grid-label">',J,"</div>")}else{o.textAlign=w?"right":"left";o.textBaseline=L?"top":"bottom";Flotr.drawText(m,J,I,H,o)}}},this);if(c.HtmlText||!this.textEnabled){j.push("</div>");this.el.insert(j.join(""))}m.restore();c.pie.drawn=true},plotSlice:function(b,h,a,e,d,f,g){var c=this.ctx;g=g||1;c.scale(1,g);c.beginPath();c.moveTo(b,h);c.arc(b,h,a,e,d,f);c.lineTo(b,h);c.closePath()},drawHit:function(c){var j=this.octx,k=c.series,a=c.xaxis,h=c.yaxis;j.save();j.translate(this.plotOffset.left,this.plotOffset.top);j.beginPath();if(k.mouse.trackAll){j.moveTo(a.d2p(c.x),h.d2p(0));j.lineTo(a.d2p(c.x),h.d2p(c.yaxis.max))}else{var b={x:(this.plotWidth)/2,y:(this.plotHeight)/2},f=(Math.min(this.canvasWidth,this.canvasHeight)*k.pie.sizeRatio)/2,e=c.sAngle<c.eAngle?(c.sAngle+c.eAngle)/2:(c.sAngle+c.eAngle+2*Math.PI)/2,g=b.x+Math.cos(e)*c.series.pie.explode,d=b.y+Math.sin(e)*c.series.pie.explode;j.beginPath();j.moveTo(g,d);if(c.fraction!=1){j.arc(g,d,f,c.sAngle,c.eAngle,false)}else{j.arc(g,d,f,c.sAngle,c.eAngle-0.00001,false)}j.lineTo(g,d);j.closePath()}j.stroke();j.closePath();j.restore()},clearHit:function(){var b={x:this.plotOffset.left+(this.plotWidth)/2,y:this.plotOffset.top+(this.plotHeight)/2},c=this.prevHit.series.pie,a=(Math.min(this.canvasWidth,this.canvasHeight)*c.sizeRatio)/2,d=(c.explode+c.lineWidth)*4;this.octx.clearRect(b.x-a-d,b.y-a-d,2*(a+d),2*(a+d))}});Flotr.addType("candles",{options:{show:false,lineWidth:1,wickLineWidth:1,candleWidth:0.6,fill:true,upFillColor:"#00A8F0",downFillColor:"#CB4B4B",fillOpacity:0.5,barcharts:false},draw:function(b){var a=this.ctx,c=b.candles.candleWidth;a.save();a.translate(this.plotOffset.left,this.plotOffset.top);a.lineJoin="miter";a.lineWidth=b.candles.lineWidth;this.candles.plotShadows(b,c/2);this.candles.plot(b,c/2);a.restore()},plot:function(l,e){var A=l.data;if(A.length<1){return}var v=l.xaxis,b=l.yaxis,q=this.ctx;for(var u=0;u<A.length;u++){var w=A[u],k=w[0],m=w[1],j=w[2],B=w[3],n=w[4];var c=k-l.candles.candleWidth/2,z=k+l.candles.candleWidth/2,g=Math.max(b.min,B),o=Math.min(b.max,j),a=Math.max(b.min,Math.min(m,n)),t=Math.min(b.max,Math.max(m,n));if(z<v.min||c>v.max||o<b.min||g>b.max){continue}var r=l.candles[m>n?"downFillColor":"upFillColor"];if(l.candles.fill&&!l.candles.barcharts){q.fillStyle=this.processColor(r,{opacity:l.candles.fillOpacity});q.fillRect(v.d2p(c),b.d2p(t)+e,v.d2p(z)-v.d2p(c),b.d2p(a)-b.d2p(t))}if(l.candles.lineWidth||l.candles.wickLineWidth){var k,h,f=(l.candles.wickLineWidth%2)/2;k=Math.floor(v.d2p((c+z)/2))+f;q.save();q.strokeStyle=r;q.lineWidth=l.candles.wickLineWidth;q.lineCap="butt";if(l.candles.barcharts){q.beginPath();q.moveTo(k,Math.floor(b.d2p(o)+e));q.lineTo(k,Math.floor(b.d2p(g)+e));h=Math.floor(b.d2p(m)+e)+0.5;q.moveTo(Math.floor(v.d2p(c))+f,h);q.lineTo(k,h);h=Math.floor(b.d2p(n)+e)+0.5;q.moveTo(Math.floor(v.d2p(z))+f,h);q.lineTo(k,h)}else{q.strokeRect(v.d2p(c),b.d2p(t)+e,v.d2p(z)-v.d2p(c),b.d2p(a)-b.d2p(t));q.beginPath();q.moveTo(k,Math.floor(b.d2p(t)+e));q.lineTo(k,Math.floor(b.d2p(o)+e));q.moveTo(k,Math.floor(b.d2p(a)+e));q.lineTo(k,Math.floor(b.d2p(g)+e))}q.stroke();q.closePath();q.restore()}}},plotShadows:function(h,c){var v=h.data;if(v.length<1||h.candles.barcharts){return}var r=h.xaxis,a=h.yaxis,n=this.options.shadowSize;for(var q=0;q<v.length;q++){var t=v[q],g=t[0],j=t[1],f=t[2],w=t[3],k=t[4];var b=g-h.candles.candleWidth/2,u=g+h.candles.candleWidth/2,e=Math.max(a.min,Math.min(j,k)),l=Math.min(a.max,Math.max(j,k));if(u<r.min||b>r.max||l<a.min||e>a.max){continue}var o=r.d2p(u)-r.d2p(b)-((r.d2p(u)+n<=this.plotWidth)?0:n);var m=Math.max(0,a.d2p(e)-a.d2p(l)-((a.d2p(e)+n<=this.plotHeight)?0:n));this.ctx.fillStyle="rgba(0,0,0,0.05)";this.ctx.fillRect(Math.min(r.d2p(b)+n,this.plotWidth),Math.min(a.d2p(l)+n,this.plotWidth),o,m)}},extendXRange:function(d){if(d.options.max==null){var a=d.min,e=d.max,b,f;for(b=0;b<this.series.length;++b){f=this.series[b].candles;if(f.show&&this.series[b].xaxis==d){e=Math.max(d.datamax+0.5,e);a=Math.min(d.datamin-0.5,a)}}d.max=e;d.min=a}}});Flotr.defaultMarkerFormatter=function(a){return(Math.round(a.y*100)/100)+""};Flotr.addType("markers",{options:{show:false,lineWidth:1,fill:false,fillColor:"#FFFFFF",fillOpacity:0.4,stroke:false,position:"ct",labelFormatter:Flotr.defaultMarkerFormatter,fontSize:Flotr.defaultOptions.fontSize,stacked:false,stackingType:"b",horizontal:false},draw:function(f){f=f||this.series;var o=this.ctx,b=f.xaxis,k=f.yaxis,q=f.markers,e=f.data;o.save();o.translate(this.plotOffset.left,this.plotOffset.top);o.lineJoin="round";o.lineWidth=q.lineWidth;o.strokeStyle="rgba(0,0,0,0.5)";o.fillStyle=this.processColor(q.fillColor,{opacity:q.fillOpacity});for(var g=0;g<e.length;++g){var n=e[g][0],l=e[g][1],m;if(f.markers.stacked){if(f.markers.stackingType=="b"){var j=0,a=0;if(f.markers.horizontal){j=k.values[l].stackMarkPos||0;a=k.values[l].stackMarkNeg||0;if(n>0){k.values[l].stackMarkPos=j+n;n=j+n}else{k.values[l].stackMarkNeg=a+n;n=a+n}}else{j=b.values[n].stackMarkPos||0;a=b.values[n].stackMarkNeg||0;if(l>0){b.values[n].stackMarkPos=j+l;l=j+l}else{b.values[n].stackMarkNeg=a+l;l=a+l}}}else{if(f.markers.stackingType=="a"){var d=b.values[n].stackMark||0;b.values[n].stackMark=d+l;l=d+l}}}var h=b.d2p(n),c=k.d2p(l);m=q.labelFormatter({x:n,y:l,index:g,data:e});this.markers.plot(h,c,m,q)}o.restore()},plot:function(g,e,f,j){var h=this.ctx,c=this.getTextDimensions(f,null,null),b=2,a=g,d=e;c.width=Math.floor(c.width+b*2);c.height=Math.floor(c.height+b*2);if(j.position.indexOf("c")!=-1){a-=c.width/2+b}else{if(j.position.indexOf("l")!=-1){a-=c.width}}if(j.position.indexOf("m")!=-1){d-=c.height/2+b}else{if(j.position.indexOf("t")!=-1){d-=c.height}}a=Math.floor(a)+0.5;d=Math.floor(d)+0.5;if(j.fill){h.fillRect(a,d,c.width,c.height)}if(j.stroke){h.strokeRect(a,d,c.width,c.height)}Flotr.drawText(h,f,a+b,d+b,{textBaseline:"top",textAlign:"left",size:j.fontSize})}});Flotr.addType("radar",{options:{show:false,lineWidth:2,fill:true,fillOpacity:0.4,radiusRatio:0.9},draw:function(c){var a=this.ctx,b=this.options;a.save();a.translate(this.plotOffset.left+this.plotWidth/2,this.plotOffset.top+this.plotHeight/2);a.lineWidth=c.radar.lineWidth;a.fillStyle="rgba(0,0,0,0.05)";a.strokeStyle="rgba(0,0,0,0.05)";this.radar.plot(c,c.shadowSize/2);a.strokeStyle="rgba(0,0,0,0.1)";this.radar.plot(c,c.shadowSize/4);a.strokeStyle=c.color;a.fillStyle=this.processColor(c.color,{opacity:c.radar.fillOpacity});this.radar.plot(c);a.restore()},plot:function(e,b){var l=this.ctx,m=this.options,d=e.data,g=Math.min(this.plotHeight,this.plotWidth)*m.radar.radiusRatio/2,f=2*(Math.PI/d.length),a=-Math.PI/2;b=b||0;l.beginPath();for(var c=0;c<d.length;++c){var k=d[c][0],j=d[c][1],h=j/this.axes.y.max;l[c==0?"moveTo":"lineTo"](Math.cos(c*f+a)*g*h+b,Math.sin(c*f+a)*g*h+b)}l.closePath();if(e.radar.fill){l.fill()}l.stroke()}});Flotr.addType("bubbles",{options:{show:false,lineWidth:2,fill:true,fillOpacity:0.4,baseRadius:2},draw:function(c){var a=this.ctx,b=this.options;a.save();a.translate(this.plotOffset.left,this.plotOffset.top);a.lineWidth=c.bubbles.lineWidth;a.fillStyle="rgba(0,0,0,0.05)";a.strokeStyle="rgba(0,0,0,0.05)";this.bubbles.plot(c,c.shadowSize/2);a.strokeStyle="rgba(0,0,0,0.1)";this.bubbles.plot(c,c.shadowSize/4);a.strokeStyle=c.color;a.fillStyle=this.processColor(c.color,{opacity:c.radar.fillOpacity});this.bubbles.plot(c);a.restore()},plot:function(c,a){var j=this.ctx,k=this.options,b=c.data,e=k.bubbles.baseRadius;a=a||0;for(var d=0;d<b.length;++d){var h=b[d][0],g=b[d][1],f=b[d][2];j.beginPath();j.arc(c.xaxis.d2p(h)+a,c.yaxis.d2p(g)+a,e*f,0,Math.PI*2,true);j.stroke();if(c.bubbles.fill){j.fill()}j.closePath()}},drawHit:function(g){var e=this.octx,b=g.series,f=g.xaxis,a=g.yaxis,d=b.data[0][2],c=this.options.bubbles.baseRadius;e.save();e.lineWidth=b.points.lineWidth;e.strokeStyle=b.mouse.lineColor;e.fillStyle=this.processColor(b.mouse.fillColor||"#ffffff",{opacity:b.mouse.fillOpacity});e.translate(this.plotOffset.left,this.plotOffset.top);e.beginPath();e.arc(f.d2p(g.x),a.d2p(g.y),d*c,0,2*Math.PI,true);e.fill();e.stroke();e.closePath();e.restore()},clearHit:function(){var c=this.prevHit,d=this.plotOffset,j=c.series,e=j.bars.lineWidth,a=c.xaxis,h=c.yaxis,g=j.data[0][2],b=this.options.bubbles.baseRadius,f=g*b+e;this.octx.clearRect(d.left+a.d2p(c.x)-f,d.top+h.d2p(c.y)-f,f*2,f*2)}});Flotr.addPlugin("spreadsheet",{options:{show:false,tabGraphLabel:"Graph",tabDataLabel:"Data",toolbarDownload:"Download CSV",toolbarSelectAll:"Select all",csvFileSeparator:",",decimalSeparator:".",tickFormatter:null},callbacks:{"flotr:afterconstruct":function(){this.el.select(".flotr-tabs-group,.flotr-datagrid-container").invoke("remove");if(!this.options.spreadsheet.show){return}var a=this.spreadsheet;a.tabsContainer=new Element("div",{style:"position:absolute;left:0px;width:"+this.canvasWidth+"px"}).addClassName("flotr-tabs-group");a.tabs={graph:new Element("div",{style:"float:left"}).addClassName("flotr-tab selected").update(this.options.spreadsheet.tabGraphLabel),data:new Element("div",{style:"float:left"}).addClassName("flotr-tab").update(this.options.spreadsheet.tabDataLabel)};a.tabsContainer.insert(a.tabs.graph).insert(a.tabs.data);this.el.insert({bottom:a.tabsContainer});var b=a.tabs.data.getHeight()+2;this.plotOffset.bottom+=b;a.tabsContainer.setStyle({top:this.canvasHeight-b+"px"});a.tabs.graph.observe("click",function(){a.showTab("graph")});a.tabs.data.observe("click",function(){a.showTab("data")})}},constructDataGrid:function(){if(this.spreadsheet.datagrid){return this.spreadsheet.datagrid}var d,b,n=this.series,l=this.loadDataGrid(),m=this.spreadsheet.datagrid=new Element("table").addClassName("flotr-datagrid"),c=["<colgroup><col />"];var f=['<tr class="first-row">'];f.push("<th> </th>");for(d=0;d<n.length;++d){f.push('<th scope="col">'+(n[d].label||String.fromCharCode(65+d))+"</th>");c.push("<col />")}f.push("</tr>");for(b=0;b<l.length;++b){f.push("<tr>");for(d=0;d<n.length+1;++d){var o="td",g=(l[b][d]!=null?Math.round(l[b][d]*100000)/100000:"");if(d==0){o="th";var k;if(this.options.xaxis.ticks){var e=this.options.xaxis.ticks.find(function(j){return j[0]==l[b][d]});if(e){k=e[1]}}else{if(this.options.spreadsheet.tickFormatter){k=this.options.spreadsheet.tickFormatter(g)}else{k=this.options.xaxis.tickFormatter(g)}}if(k){g=k}}f.push("<"+o+(o=="th"?' scope="row"':"")+">"+g+"</"+o+">")}f.push("</tr>")}c.push("</colgroup>");m.update(c.join("")+f.join(""));if(!Prototype.Browser.IE||Flotr.isIE9){m.select("td").each(function(j){j.observe("mouseover",function(q){j=q.element();var r=j.previousSiblings();m.select("th[scope=col]")[r.length-1].addClassName("hover");m.select("colgroup col")[r.length].addClassName("hover")}).observe("mouseout",function(){m.select("colgroup col.hover, th.hover").invoke("removeClassName","hover")})})}var h=new Element("div").addClassName("flotr-datagrid-toolbar").insert(new Element("button",{type:"button"}).addClassName("flotr-datagrid-toolbar-button").update(this.options.spreadsheet.toolbarDownload).observe("click",this.spreadsheet.downloadCSV.bindAsEventListener(this))).insert(new Element("button",{type:"button"}).addClassName("flotr-datagrid-toolbar-button").update(this.options.spreadsheet.toolbarSelectAll).observe("click",this.spreadsheet.selectAllData.bindAsEventListener(this)));var a=new Element("div",{style:"left:0px;top:0px;width:"+this.canvasWidth+"px;height:"+(this.canvasHeight-this.spreadsheet.tabsContainer.getHeight()-2)+"px;overflow:auto;"}).addClassName("flotr-datagrid-container");a.insert(h);m.wrap(a.hide());this.el.insert(a);return m},showTab:function(b){var a="canvas, .flotr-labels, .flotr-legend, .flotr-legend-bg, .flotr-title, .flotr-subtitle";switch(b){case"graph":if(this.spreadsheet.datagrid){this.spreadsheet.datagrid.up().hide()}this.el.select(a).invoke("show");this.spreadsheet.tabs.data.removeClassName("selected");this.spreadsheet.tabs.graph.addClassName("selected");break;case"data":this.spreadsheet.constructDataGrid();this.spreadsheet.datagrid.up().show();this.el.select(a).invoke("hide");this.spreadsheet.tabs.data.addClassName("selected");this.spreadsheet.tabs.graph.removeClassName("selected");break}},selectAllData:function(){if(this.spreadsheet.tabs){var b,a,e,d,c=this.spreadsheet.constructDataGrid();this.spreadsheet.showTab("data");setTimeout(function(){if((e=c.ownerDocument)&&(d=e.defaultView)&&d.getSelection&&e.createRange&&(b=window.getSelection())&&b.removeAllRanges){a=e.createRange();a.selectNode(c);b.removeAllRanges();b.addRange(a)}else{if(document.body&&document.body.createTextRange&&(a=document.body.createTextRange())){a.moveToElementText(c);a.select()}}},0);return true}else{return false}},downloadCSV:function(){var b,a="",c=this.series,j=this.options,f=this.loadDataGrid(),d=encodeURIComponent(j.spreadsheet.csvFileSeparator);if(j.spreadsheet.decimalSeparator===j.spreadsheet.csvFileSeparator){throw"The decimal separator is the same as the column separator ("+j.spreadsheet.decimalSeparator+")"}for(b=0;b<c.length;++b){a+=d+'"'+(c[b].label||String.fromCharCode(65+b)).replace(/\"/g,'\\"')+'"'}a+="%0D%0A";for(b=0;b<f.length;++b){var h="";if(j.xaxis.ticks){var e=j.xaxis.ticks.find(function(k){return k[0]==f[b][0]});if(e){h=e[1]}}else{if(j.spreadsheet.tickFormatter){h=j.spreadsheet.tickFormatter(f[b][0])}else{h=j.xaxis.tickFormatter(f[b][0])}}h='"'+(h+"").replace(/\"/g,'\\"')+'"';var g=f[b].slice(1).join(d);if(j.spreadsheet.decimalSeparator!=="."){g=g.replace(/\./g,j.spreadsheet.decimalSeparator)}a+=h+d+g+"%0D%0A"}if(Prototype.Browser.IE&&!Flotr.isIE9){a=a.replace(new RegExp(d,"g"),decodeURIComponent(d)).replace(/%0A/g,"\n").replace(/%0D/g,"\r");window.open().document.write(a)}else{window.open("data:text/csv,"+a)}}});Flotr.addType("gantt",{options:{show:false,lineWidth:2,barWidth:1,fill:true,fillColor:null,fillOpacity:0.4,centered:true},draw:function(c){var a=this.ctx,e=c.gantt.barWidth,d=Math.min(c.gantt.lineWidth,e);a.save();a.translate(this.plotOffset.left,this.plotOffset.top);a.lineJoin="miter";a.lineWidth=d;a.strokeStyle=c.color;a.save();this.gantt.plotShadows(c,e,0,c.gantt.fill);a.restore();if(c.gantt.fill){var b=c.gantt.fillColor||c.color;a.fillStyle=this.processColor(b,{opacity:c.gantt.fillOpacity})}this.gantt.plot(c,e,0,c.gantt.fill);a.restore()},plot:function(j,n,e,q){var w=j.data;if(w.length<1){return}var t=j.xaxis,b=j.yaxis,o=this.ctx,r;for(r=0;r<w.length;r++){var h=w[r][0],l=w[r][1],u=w[r][2],f=true,k=true,a=true;if(l===null||u===null){continue}var c=l,v=l+u,g=h-(j.gantt.centered?n/2:0),m=h+n-(j.gantt.centered?n/2:0);if(v<t.min||c>t.max||m<b.min||g>b.max){continue}if(c<t.min){c=t.min;f=false}if(v>t.max){v=t.max;if(t.lastSerie!=j){k=false}}if(g<b.min){g=b.min}if(m>b.max){m=b.max;if(b.lastSerie!=j){k=false}}if(q){o.beginPath();o.moveTo(t.d2p(c),b.d2p(g)+e);o.lineTo(t.d2p(c),b.d2p(m)+e);o.lineTo(t.d2p(v),b.d2p(m)+e);o.lineTo(t.d2p(v),b.d2p(g)+e);o.fill();o.closePath()}if(j.gantt.lineWidth!=0&&(f||a||k)){o.beginPath();o.moveTo(t.d2p(c),b.d2p(g)+e);o[f?"lineTo":"moveTo"](t.d2p(c),b.d2p(m)+e);o[k?"lineTo":"moveTo"](t.d2p(v),b.d2p(m)+e);o[a?"lineTo":"moveTo"](t.d2p(v),b.d2p(g)+e);o.stroke();o.closePath()}}},plotShadows:function(g,j,c){var v=g.data;if(v.length<1){return}var q,f,h,t,r=g.xaxis,a=g.yaxis,o=this.ctx,m=this.options.shadowSize;for(q=0;q<v.length;q++){f=v[q][0];h=v[q][1];t=v[q][2];if(h===null||t===null){continue}var b=h,u=h+t,e=f-(g.gantt.centered?j/2:0),k=f+j-(g.gantt.centered?j/2:0);if(u<r.min||b>r.max||k<a.min||e>a.max){continue}if(b<r.min){b=r.min}if(u>r.max){u=r.max}if(e<a.min){e=a.min}if(k>a.max){k=a.max}var n=r.d2p(u)-r.d2p(b)-((r.d2p(u)+m<=this.plotWidth)?0:m);var l=a.d2p(e)-a.d2p(k)-((a.d2p(e)+m<=this.plotHeight)?0:m);o.fillStyle="rgba(0,0,0,0.05)";o.fillRect(Math.min(r.d2p(b)+m,this.plotWidth),Math.min(a.d2p(k)+m,this.plotHeight),n,l)}},extendXRange:function(b){if(b.options.max==null){var c=b.min,k=b.max,e,d,m,n,h,a={},l={},f=null;for(e=0;e<this.series.length;++e){n=this.series[e];h=n.gantt;if(h.show&&n.xaxis==b){for(d=0;d<n.data.length;d++){if(h.show){y=n.data[d][0]+"";a[y]=Math.max((a[y]||0),n.data[d][1]+n.data[d][2]);f=n}}for(d in a){k=Math.max(a[d],k)}}}b.lastSerie=f;b.max=k;b.min=c}},extendYRange:function(b){if(b.options.max==null){var l=Number.MIN_VALUE,d=Number.MAX_VALUE,f,e,o,k,a={},m={},h=null;for(f=0;f<this.series.length;++f){o=this.series[f];k=o.gantt;if(k.show&&!o.hide&&o.yaxis==b){var c=Number.MIN_VALUE,n=Number.MAX_VALUE;for(e=0;e<o.data.length;e++){c=Math.max(c,o.data[e][0]);n=Math.min(n,o.data[e][0])}if(k.centered){l=Math.max(c+0.5,l);d=Math.min(n-0.5,d)}else{l=Math.max(c+1,l);d=Math.min(n,d)}if(k.barWidth+c>l){l=b.max+k.barWidth}}}b.lastSerie=h;b.max=l;b.min=d;b.tickSize=Flotr.getTickSize(b.options.noTicks,d,l,b.options.tickDecimals)}}});
|