"),n.push(""),s=!0),n.push(' | '+u.label+" | ")}s&&n.push("
");if(0==n.length)return;var d='";if(null!=l.legend.container)t(l.legend.container).html(d);else{var p="",x=l.legend.position,g=l.legend.margin;null==g[0]&&(g=[g,g]),"n"==x.charAt(0)?p+="top:"+(g[1]+m.top)+"px;":"s"==x.charAt(0)&&(p+="bottom:"+(g[1]+m.bottom)+"px;"),"e"==x.charAt(1)?p+="right:"+(g[0]+m.right)+"px;":"w"==x.charAt(1)&&(p+="left:"+(g[0]+m.left)+"px;");var b=t(''+d.replace('style="','style="position:absolute;'+p+";")+"
").appendTo(i);if(0!=l.legend.backgroundOpacity){var v=l.legend.backgroundColor;null==v&&((v=(v=l.grid.backgroundColor)&&"string"==typeof v?t.color.parse(v):t.color.extract(b,"background-color")).a=1,v=v.toString());var k=b.children();t('
').prependTo(b).css("opacity",l.legend.backgroundOpacity)}}}()}function z(){s.clear(),k(b.drawBackground,[h]);var t=l.grid;t.show&&t.backgroundColor&&(h.save(),h.translate(m.left,m.top),h.fillStyle=q(l.grid.backgroundColor,g,0,"rgba(255, 255, 255, 0)"),h.fillRect(0,0,x,g),h.restore()),t.show&&!t.aboveData&&A();for(var i=0;in){var s=o;o=n,n=s}return{from:o,to:n,axis:e}}function A(){var t,i,e,o;h.save(),h.translate(m.left,m.top);var n=l.grid.markings;if(n)for("function"==typeof n&&((i=v.getAxes()).xmin=i.xaxis.min,i.xmax=i.xaxis.max,i.ymin=i.yaxis.min,i.ymax=i.yaxis.max,n=n(i)),t=0;ta.axis.max||s.tos.axis.max||(a.from=Math.max(a.from,a.axis.min),a.to=Math.min(a.to,a.axis.max),s.from=Math.max(s.from,s.axis.min),s.to=Math.min(s.to,s.axis.max),a.from==a.to&&s.from==s.to||(a.from=a.axis.p2c(a.from),a.to=a.axis.p2c(a.to),s.from=s.axis.p2c(s.from),s.to=s.axis.p2c(s.to),a.from==a.to||s.from==s.to?(h.beginPath(),h.strokeStyle=r.color||l.grid.markingsColor,h.lineWidth=r.lineWidth||l.grid.markingsLineWidth,h.moveTo(a.from,s.from),h.lineTo(a.to,s.to),h.stroke()):(h.fillStyle=r.color||l.grid.markingsColor,h.fillRect(a.from,s.to,a.to-a.from,s.from-s.to))))}i=T(),e=l.grid.borderWidth;for(var c=0;cb.max||"full"==y&&("object"==typeof e&&e[b.position]>0||e>0)&&(w==b.min||w==b.max)||("x"==b.direction?(f=b.p2c(w),p="full"==y?-g:y,"top"==b.position&&(p=-p)):(u=b.p2c(w),d="full"==y?-x:y,"left"==b.position&&(d=-d)),1==h.lineWidth&&("x"==b.direction?f=Math.floor(f)+.5:u=Math.floor(u)+.5),h.moveTo(f,u),h.lineTo(f+d,u+p))}h.stroke()}}e&&(o=l.grid.borderColor,"object"==typeof e||"object"==typeof o?("object"!=typeof e&&(e={top:e,right:e,bottom:e,left:e}),"object"!=typeof o&&(o={top:o,right:o,bottom:o,left:o}),e.top>0&&(h.strokeStyle=o.top,h.lineWidth=e.top,h.beginPath(),h.moveTo(0-e.left,0-e.top/2),h.lineTo(x,0-e.top/2),h.stroke()),e.right>0&&(h.strokeStyle=o.right,h.lineWidth=e.right,h.beginPath(),h.moveTo(x+e.right/2,0-e.top),h.lineTo(x+e.right/2,g),h.stroke()),e.bottom>0&&(h.strokeStyle=o.bottom,h.lineWidth=e.bottom,h.beginPath(),h.moveTo(x+e.right,g+e.bottom/2),h.lineTo(0,g+e.bottom/2),h.stroke()),e.left>0&&(h.strokeStyle=o.left,h.lineWidth=e.left,h.beginPath(),h.moveTo(0-e.left/2,g+e.bottom),h.lineTo(0-e.left/2,0),h.stroke())):(h.lineWidth=e,h.strokeStyle=l.grid.borderColor,h.strokeRect(-e/2,-e/2,x+e,g+e))),h.restore()}function P(t){t.lines.show&&function(t){function i(t,i,e,o,n){var r=t.points,a=t.pointsize,l=null,s=null;h.beginPath();for(var c=a;c=p&&u>n.max){if(p>n.max)continue;f=(n.max-u)/(p-u)*(d-f)+f,u=n.max}else if(p>=u&&p>n.max){if(u>n.max)continue;d=(n.max-u)/(p-u)*(d-f)+f,p=n.max}if(f<=d&&f=d&&f>o.max){if(d>o.max)continue;u=(o.max-f)/(d-f)*(p-u)+u,f=o.max}else if(d>=f&&d>o.max){if(f>o.max)continue;p=(o.max-f)/(d-f)*(p-u)+u,d=o.max}f==l&&u==s||h.moveTo(o.p2c(f)+i,n.p2c(u)+e),l=d,s=p,h.lineTo(o.p2c(d)+i,n.p2c(p)+e)}}h.stroke()}h.save(),h.translate(m.left,m.top),h.lineJoin="round";var e=t.lines.lineWidth,o=t.shadowSize;if(e>0&&o>0){h.lineWidth=o,h.strokeStyle="rgba(0,0,0,0.1)";var n=Math.PI/18;i(t.datapoints,Math.sin(n)*(e/2+o/2),Math.cos(n)*(e/2+o/2),t.xaxis,t.yaxis),h.lineWidth=o/2,i(t.datapoints,Math.sin(n)*(e/2+o/4),Math.cos(n)*(e/2+o/4),t.xaxis,t.yaxis)}h.lineWidth=e,h.strokeStyle=t.color;var r=N(t.lines,t.color,0,g);r&&(h.fillStyle=r,function(t,i,e){var o=t.points,n=t.pointsize,r=Math.min(Math.max(0,e.min),e.max),a=0,l=!1,s=1,c=0,f=0;for(;!(n>0&&a>o.length+n);){var u=o[(a+=n)-n],d=o[a-n+s],p=o[a],m=o[a+s];if(l){if(n>0&&null!=u&&null==p){f=a,n=-n,s=2;continue}if(n<0&&a==c+n){h.fill(),l=!1,s=1,a=c=f+(n=-n);continue}}if(null!=u&&null!=p){if(u<=p&&u=p&&u>i.max){if(p>i.max)continue;d=(i.max-u)/(p-u)*(m-d)+d,u=i.max}else if(p>=u&&p>i.max){if(u>i.max)continue;m=(i.max-u)/(p-u)*(m-d)+d,p=i.max}if(l||(h.beginPath(),h.moveTo(i.p2c(u),e.p2c(r)),l=!0),d>=e.max&&m>=e.max)h.lineTo(i.p2c(u),e.p2c(e.max)),h.lineTo(i.p2c(p),e.p2c(e.max));else if(d<=e.min&&m<=e.min)h.lineTo(i.p2c(u),e.p2c(e.min)),h.lineTo(i.p2c(p),e.p2c(e.min));else{var x=u,g=p;d<=m&&d=e.min?(u=(e.min-d)/(m-d)*(p-u)+u,d=e.min):m<=d&&m=e.min&&(p=(e.min-d)/(m-d)*(p-u)+u,m=e.min),d>=m&&d>e.max&&m<=e.max?(u=(e.max-d)/(m-d)*(p-u)+u,d=e.max):m>=d&&m>e.max&&d<=e.max&&(p=(e.max-d)/(m-d)*(p-u)+u,m=e.max),u!=x&&h.lineTo(i.p2c(x),e.p2c(d)),h.lineTo(i.p2c(u),e.p2c(d)),h.lineTo(i.p2c(p),e.p2c(m)),p!=g&&(h.lineTo(i.p2c(p),e.p2c(m)),h.lineTo(i.p2c(g),e.p2c(m)))}}}}(t.datapoints,t.xaxis,t.yaxis));e>0&&i(t.datapoints,0,0,t.xaxis,t.yaxis);h.restore()}(t),t.bars.show&&function(t){var i;switch(h.save(),h.translate(m.left,m.top),h.lineWidth=t.bars.lineWidth,h.strokeStyle=t.color,t.bars.align){case"left":i=0;break;case"right":i=-t.bars.barWidth;break;case"center":i=-t.bars.barWidth/2;break;default:throw new Error("Invalid bar alignment: "+t.bars.align)}var e=t.bars.fill?function(i,e){return N(t.bars,t.color,i,e)}:null;(function(i,e,o,n,r,a,l){for(var s=i.points,c=i.pointsize,f=0;fr.max||da.max||(h.beginPath(),u=r.p2c(u),d=a.p2c(d)+o,"circle"==l?h.arc(u,d,i,0,n?Math.PI:2*Math.PI,!1):l(h,u,d,i,n),h.closePath(),e&&(h.fillStyle=e,h.fill()),h.stroke())}}h.save(),h.translate(m.left,m.top);var e=t.points.lineWidth,o=t.shadowSize,n=t.points.radius,r=t.points.symbol;0==e&&(e=1e-4);if(e>0&&o>0){var a=o/2;h.lineWidth=a,h.strokeStyle="rgba(0,0,0,0.1)",i(t.datapoints,n,null,a+a/2,!0,t.xaxis,t.yaxis,r),h.strokeStyle="rgba(0,0,0,0.2)",i(t.datapoints,n,null,a/2,!0,t.xaxis,t.yaxis,r)}h.lineWidth=e,h.strokeStyle=t.color,i(t.datapoints,n,N(t.points,t.color),0,!1,t.xaxis,t.yaxis,r),h.restore()}(t)}function F(t,i,e,o,n,r,a,l,s,c,f,h){var u,d,p,m,x,g,b,v,k;f?(v=g=b=!0,x=!1,m=i+o,p=i+n,(d=t)<(u=e)&&(k=d,d=u,u=k,x=!0,g=!1)):(x=g=b=!0,v=!1,u=t+o,d=t+n,(m=i)<(p=e)&&(k=m,m=p,p=k,v=!0,b=!1)),dl.max||ms.max||(ul.max&&(d=l.max,g=!1),ps.max&&(m=s.max,b=!1),u=l.p2c(u),p=s.p2c(p),d=l.p2c(d),m=s.p2c(m),a&&(c.beginPath(),c.moveTo(u,p),c.lineTo(u,m),c.lineTo(d,m),c.lineTo(d,p),c.fillStyle=a(p,m),c.fill()),h>0&&(x||g||b||v)&&(c.beginPath(),c.moveTo(u,p+r),x?c.lineTo(u,m+r):c.moveTo(u,m+r),b?c.lineTo(d,m+r):c.moveTo(d,m+r),g?c.lineTo(d,p+r):c.moveTo(d,p+r),v?c.lineTo(u,p+r):c.moveTo(u,p+r),c.stroke()))}function N(i,e,o,n){var r=i.fill;if(!r)return null;if(i.fillColor)return q(i.fillColor,o,n,e);var a=t.color.parse(e);return a.a="number"==typeof r?r:.4,a.normalize(),a.toString()}v.setData=y,v.setupGrid=W,v.draw=z,v.getPlaceholder=function(){return i},v.getCanvas=function(){return s.element},v.getPlotOffset=function(){return m},v.width=function(){return x},v.height=function(){return g},v.offset=function(){var t=f.offset();return t.left+=m.left,t.top+=m.top,t},v.getData=function(){return a},v.getAxes=function(){var i={};return t.each(d.concat(p),function(t,e){e&&(i[e.direction+(1!=e.n?e.n:"")+"axis"]=e)}),i},v.getXAxes=function(){return d},v.getYAxes=function(){return p},v.c2p=M,v.p2c=function(t){var i,e,o,n={};for(i=0;i=0;--o)if(e(a[o])){var h=a[o],u=h.xaxis,d=h.yaxis,p=h.datapoints.points,m=u.c2p(t),x=d.c2p(i),g=s/u.scale,b=s/d.scale;if(r=h.datapoints.pointsize,u.options.inverseTransform&&(g=Number.MAX_VALUE),d.options.inverseTransform&&(b=Number.MAX_VALUE),h.lines.show||h.points.show)for(n=0;ng||v-m<-g||k-x>b||k-x<-b)){var y=Math.abs(u.p2c(v)-t),w=Math.abs(d.p2c(k)-i),T=y*y+w*w;T=Math.min(S,v)&&x>=k+M&&x<=k+C:m>=v+M&&m<=v+C&&x>=Math.min(S,k)&&x<=Math.max(S,k))&&(f=[o,n/r])}}}return f?(o=f[0],n=f[1],r=a[o].datapoints.pointsize,{datapoint:a[o].datapoints.points.slice(n*r,(n+1)*r),dataIndex:n,series:a[o],seriesIndex:o}):null}(r,s,o);if(h&&(h.pageX=parseInt(h.series.xaxis.p2c(h.datapoint[0])+n.left+m.left,10),h.pageY=parseInt(h.series.yaxis.p2c(h.datapoint[1])+n.top+m.top,10)),l.grid.autoHighlight){for(var u=0;ur.max||na.max)){var s=i.points.radius+i.points.lineWidth/2;u.lineWidth=s,u.strokeStyle=l;var c=1.5*s;o=r.p2c(o),n=a.p2c(n),u.beginPath(),"circle"==i.points.symbol?u.arc(o,n,c,0,2*Math.PI,!1):i.points.symbol(u,o,n,c,!1),u.closePath(),u.stroke()}}function Y(i,e){var o="string"==typeof i.highlightColor?i.highlightColor:t.color.parse(i.color).scale("a",.5).toString(),n=o,r="left"==i.bars.align?0:-i.bars.barWidth/2;u.lineWidth=i.bars.lineWidth,u.strokeStyle=o,F(e[0],e[1],e[2]||0,r,r+i.bars.barWidth,0,function(){return n},i.xaxis,i.yaxis,u,i.bars.horizontal,i.bars.lineWidth)}function q(i,e,o,n){if("string"==typeof i)return i;for(var r=h.createLinearGradient(0,o,0,e),a=0,l=i.colors.length;a