From 144092128c1eeb46c660827e36f3abb2f468938d Mon Sep 17 00:00:00 2001 From: Olly Smith Date: Thu, 15 Mar 2012 21:06:21 +0000 Subject: [PATCH] Timestamp refactor, 2/2. --- examples/decimal.html | 3 ++- morris.coffee | 46 ++++++++++++++++++++++++++++--------------- morris.js | 33 +++++++++++++++++++++++++++---- morris.min.js | 2 +- 4 files changed, 62 insertions(+), 22 deletions(-) diff --git a/examples/decimal.html b/examples/decimal.html index 3445df3..8cfe084 100644 --- a/examples/decimal.html +++ b/examples/decimal.html @@ -24,7 +24,8 @@ window.m = Morris.Line({ data: decimal_data, xkey: 'x', ykeys: ['y'], - labels: ['sin(x)'] + labels: ['sin(x)'], + parseTime: false }); diff --git a/morris.coffee b/morris.coffee index 51fbed1..c038cee 100644 --- a/morris.coffee +++ b/morris.coffee @@ -146,19 +146,31 @@ class Morris.Line .attr('stroke-width', @options.gridStrokeWidth) ## draw x axis labels - #prevLabelMargin = null - #xLabelMargin = 50 # make this an option? - #for i in [Math.ceil(@xmin)..Math.floor(@xmax)] - # labelText = if @options.parseTime then i else @columnLabels[@columnLabels.length-i-1] - # label = @r.text(transX(i), @options.marginTop + height + @options.marginBottom / 2, labelText) - # .attr('font-size', @options.gridTextSize) - # .attr('fill', @options.gridTextColor) - # labelBox = label.getBBox() - # # ensure a minimum of `xLabelMargin` pixels between labels - # if prevLabelMargin is null or prevLabelMargin <= labelBox.x - # prevLabelMargin = labelBox.x + labelBox.width + xLabelMargin - # else - # label.remove() + prevLabelMargin = null + xLabelMargin = 50 # make this an option? + if @options.parseTime + x1 = new Date(@xmin).getFullYear() + x2 = new Date(@xmax).getFullYear() + else + x1 = @xmin + x2 = @xmax + for i in [x1..x2] + if @options.parseTime + xpos = new Date(i, 0, 1).getTime() + if xpos < @xmin + continue + else + xpos = i + labelText = if @options.parseTime then i else @columnLabels[@columnLabels.length-i-1] + label = @r.text(transX(xpos), @options.marginTop + height + @options.marginBottom / 2, labelText) + .attr('font-size', @options.gridTextSize) + .attr('fill', @options.gridTextColor) + labelBox = label.getBBox() + # ensure a minimum of `xLabelMargin` pixels between labels + if prevLabelMargin is null or prevLabelMargin <= labelBox.x + prevLabelMargin = labelBox.x + labelBox.width + xLabelMargin + else + label.remove() # draw the actual series columns = (transX(x) for x in @xvals) @@ -315,11 +327,13 @@ class Morris.Line if m new Date( parseInt(m[1], 10), - parseInt(m[2], 10) * 3 - 1).getTime() + parseInt(m[2], 10) * 3 - 1, + 1).getTime() else if n new Date( parseInt(n[1], 10), - parseInt(n[2], 10) - 1).getTime() + parseInt(n[2], 10) - 1, + 1).getTime() else if o new Date( parseInt(o[1], 10), @@ -334,7 +348,7 @@ class Morris.Line # add weeks ret.getTime() + parseInt(p[2], 10) * 604800000 else - new Date(parseInt(date, 10)) + new Date(parseInt(date, 10), 0, 1) # make long numbers prettier by inserting commas # eg: commas(1234567) -> '1,234,567' diff --git a/morris.js b/morris.js index 84ca600..04de222 100644 --- a/morris.js +++ b/morris.js @@ -105,7 +105,7 @@ }; Line.prototype.redraw = function() { - var c, circle, columns, coords, dx, dy, firstY, height, hideHover, hilight, hover, hoverHeight, hoverMargins, hoverSet, i, lastY, left, lineY, maxYLabelWidth, path, pointGrow, pointShrink, prevHilight, s, seriesCoords, seriesPoints, touchHandler, transX, transY, updateHilight, updateHover, v, width, x, xLabel, y, yInterval, yLabel, yLabels, _i, _j, _len, _len2, _ref, _ref2, _ref3, _ref4, _ref5, + var c, circle, columns, coords, dx, dy, firstY, height, hideHover, hilight, hover, hoverHeight, hoverMargins, hoverSet, i, label, labelBox, labelText, lastY, left, lineY, maxYLabelWidth, path, pointGrow, pointShrink, prevHilight, prevLabelMargin, s, seriesCoords, seriesPoints, touchHandler, transX, transY, updateHilight, updateHover, v, width, x, x1, x2, xLabel, xLabelMargin, xpos, y, yInterval, yLabel, yLabels, _i, _j, _len, _len2, _ref, _ref2, _ref3, _ref4, _ref5, _this = this; this.el.empty(); this.r = new Raphael(this.el[0]); @@ -134,6 +134,31 @@ this.r.text(left - this.options.marginLeft / 2, y, v + this.options.units).attr('font-size', this.options.gridTextSize).attr('fill', this.options.gridTextColor).attr('text-anchor', 'end'); this.r.path("M" + left + "," + y + 'H' + (left + width)).attr('stroke', this.options.gridLineColor).attr('stroke-width', this.options.gridStrokeWidth); } + prevLabelMargin = null; + xLabelMargin = 50; + if (this.options.parseTime) { + x1 = new Date(this.xmin).getFullYear(); + x2 = new Date(this.xmax).getFullYear(); + } else { + x1 = this.xmin; + x2 = this.xmax; + } + for (i = x1; x1 <= x2 ? i <= x2 : i >= x2; x1 <= x2 ? i++ : i--) { + if (this.options.parseTime) { + xpos = new Date(i, 0, 1).getTime(); + if (xpos < this.xmin) continue; + } else { + xpos = i; + } + labelText = this.options.parseTime ? i : this.columnLabels[this.columnLabels.length - i - 1]; + label = this.r.text(transX(xpos), this.options.marginTop + height + this.options.marginBottom / 2, labelText).attr('font-size', this.options.gridTextSize).attr('fill', this.options.gridTextColor); + labelBox = label.getBBox(); + if (prevLabelMargin === null || prevLabelMargin <= labelBox.x) { + prevLabelMargin = labelBox.x + labelBox.width + xLabelMargin; + } else { + label.remove(); + } + } columns = (function() { var _i, _len, _ref, _results; _ref = this.xvals; @@ -338,9 +363,9 @@ o = date.match(/^(\d+)-(\d+)-(\d+)$/); p = date.match(/^(\d+) W(\d+)$/); if (m) { - return new Date(parseInt(m[1], 10), parseInt(m[2], 10) * 3 - 1).getTime(); + return new Date(parseInt(m[1], 10), parseInt(m[2], 10) * 3 - 1, 1).getTime(); } else if (n) { - return new Date(parseInt(n[1], 10), parseInt(n[2], 10) - 1).getTime(); + return new Date(parseInt(n[1], 10), parseInt(n[2], 10) - 1, 1).getTime(); } else if (o) { return new Date(parseInt(o[1], 10), parseInt(o[2], 10) - 1, parseInt(o[3], 10)).getTime(); } else if (p) { @@ -348,7 +373,7 @@ if (ret.getDay() !== 4) ret.setMonth(0, 1 + ((4 - ret.getDay()) + 7) % 7); return ret.getTime() + parseInt(p[2], 10) * 604800000; } else { - return new Date(parseInt(date, 10)); + return new Date(parseInt(date, 10), 0, 1); } }; diff --git a/morris.min.js b/morris.min.js index 86f48d8..2d5927a 100644 --- a/morris.min.js +++ b/morris.min.js @@ -1 +1 @@ -((function(){var a,b;a=jQuery,b={},b.Line=function(){function c(c){if(!(this instanceof b.Line))return new b.Line(c);typeof c.element=="string"?this.el=a(document.getElementById(c.element)):this.el=a(c.element),this.options=a.extend({},this.defaults,c);if(this.options.data===void 0||this.options.data.length===0)return;this.el.addClass("graph-initialised"),this.precalc(),this.redraw()}return c.prototype.defaults={lineWidth:3,pointSize:4,lineColors:["#0b62a4","#7A92A3","#4da74d","#afd8f8","#edc240","#cb4b4b","#9440ed"],ymax:"auto",ymin:"auto 0",marginTop:25,marginRight:25,marginBottom:30,marginLeft:25,numLines:5,gridLineColor:"#aaa",gridTextColor:"#888",gridTextSize:12,gridStrokeWidth:.5,hoverPaddingX:10,hoverPaddingY:5,hoverMargin:10,hoverFillColor:"#fff",hoverBorderColor:"#ccc",hoverBorderWidth:2,hoverOpacity:.95,hoverLabelColor:"#444",hoverFontSize:12,smooth:!0,hideHover:!1,parseTime:!0,units:""},c.prototype.precalc=function(){var b,c,d,e,f,g,h,i,j,k=this;this.options.data.sort(function(a,b){return(a[k.options.xkey]=0;i<=0?a++:a--)j.push(a);return j}.apply(this),this.xmin=Math.min.apply(null,this.xvals),this.xmax=Math.max.apply(null,this.xvals),this.xmin===this.xmax&&(this.xmin-=1,this.xmax+=1),typeof this.options.ymax=="string"&&this.options.ymax.slice(0,4)==="auto"&&(c=Math.max.apply(null,Array.prototype.concat.apply([],this.series)),this.options.ymax.length>5?this.options.ymax=Math.max(parseInt(this.options.ymax.slice(5),10),c):this.options.ymax=c);if(typeof this.options.ymin=="string"&&this.options.ymin.slice(0,4)==="auto")return d=Math.min.apply(null,Array.prototype.concat.apply([],this.series)),this.options.ymin.length>5?this.options.ymin=Math.min(parseInt(this.options.ymin.slice(5),10),d):this.options.ymin=d},c.prototype.redraw=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X=this;this.el.empty(),this.r=new Raphael(this.el[0]),t=Math.max(this.measureText(this.options.ymin+this.options.units,this.options.gridTextSize).width,this.measureText(this.options.ymax+this.options.units,this.options.gridTextSize).width),r=t+this.options.marginLeft,H=this.el.width()-r-this.options.marginRight,i=this.el.height()-this.options.marginTop-this.options.marginBottom,f=H/(this.xmax-this.xmin),g=i/(this.options.ymax-this.options.ymin),C=function(a){return X.xvals.length===1?r+H/2:r+(a-X.xmin)*f},D=function(a){return X.options.marginTop+i-(a-X.options.ymin)*g},L=(this.options.ymax-this.options.ymin)/(this.options.numLines-1),h=Math.ceil(this.options.ymin/L)*L,q=Math.floor(this.options.ymax/L)*L;for(s=h;h<=q?s<=q:s>=q;s+=L)G=Math.floor(s),K=D(G),this.r.text(r-this.options.marginLeft/2,K,G+this.options.units).attr("font-size",this.options.gridTextSize).attr("fill",this.options.gridTextColor).attr("text-anchor","end"),this.r.path("M"+r+","+K+"H"+(r+H)).attr("stroke",this.options.gridLineColor).attr("stroke-width",this.options.gridStrokeWidth);d=function(){var a,b,c,d;c=this.xvals,d=[];for(a=0,b=c.length;a=0;T<=0?p++:p--)e=z[p],e.length>1&&(u=this.createPath(e,this.options.marginTop,r,this.options.marginTop+i,r+H),this.r.path(u).attr("stroke",this.options.lineColors[p]).attr("stroke-width",this.options.lineWidth));A=function(){var a,b;b=[];for(p=0,a=z.length-1;0<=a?p<=a:p>=a;0<=a?p++:p--)b.push([]);return b}();for(p=U=z.length-1;U<=0?p<=0:p>=0;U<=0?p++:p--){V=z[p];for(P=0,R=V.length;P=W;0<=W?p++:p--)M=this.r.text(0,this.options.hoverFontSize*1.5*(p+1.5)-m/2,"").attr("fill",this.options.lineColors[p]).attr("font-size",this.options.hoverFontSize),N.push(M),o.push(M);return F=function(b){var c,e,f,g,h;o.show(),J.attr("text",X.columnLabels[b]);for(c=0,h=X.series.length-1;0<=h?c<=h:c>=h;0<=h?c++:c--)N[c].attr("text",""+X.seriesLabels[c]+": "+X.commas(X.series[c][b])+X.options.units);return e=Math.max.apply(null,a.map(N,function(a){return a.getBBox().width})),e=Math.max(e,J.getBBox().width),l.attr("width",e+X.options.hoverPaddingX*2),l.attr("x",-X.options.hoverPaddingX-e/2),g=Math.min.apply(null,a.map(X.series,function(a){return D(a[b])})),g>m+X.options.hoverPaddingY*2+X.options.hoverMargin+X.options.marginTop?g=g-m/2-X.options.hoverPaddingY-X.options.hoverMargin:g=g+m/2+X.options.hoverPaddingY+X.options.hoverMargin,g=Math.max(X.options.marginTop+m/2+X.options.hoverPaddingY,g),g=Math.min(X.options.marginTop+i-m/2-X.options.hoverPaddingY,g),f=Math.min(r+H-e/2-X.options.hoverPaddingX,d[b]),f=Math.max(r+e/2+X.options.hoverPaddingX,f),o.attr("transform","t"+f+","+g)},j=function(){return o.hide()},n=a.map(d.slice(1),function(a,b){return(a+d[b])/2}),x=null,v=Raphael.animation({r:this.options.pointSize+3},25,"linear"),w=Raphael.animation({r:this.options.pointSize},25,"linear"),k=function(a){var b,c,d;if(x!==null&&x!==a)for(b=0,c=A.length-1;0<=c?b<=c:b>=c;0<=c?b++:b--)A[b][x].animate(w);if(a!==null&&x!==a){for(b=0,d=A.length-1;0<=d?b<=d:b>=d;0<=d?b++:b--)A[b][a].animate(v);F(a)}x=a;if(a===null)return j()},E=function(a){var b,c,d;a-=X.el.offset().left,d=[];for(b=c=n.length;c<=0?b<=0:b>=0;c<=0?b++:b--){if(b===0||n[b-1]>a){k(b);break}d.push(void 0)}return d},this.el.mousemove(function(a){return E(a.pageX)}),this.options.hideHover&&this.el.mouseout(function(a){return k(null)}),B=function(a){var b;return b=a.originalEvent.touches[0]||a.originalEvent.changedTouches[0],E(b.pageX),b},this.el.bind("touchstart",B),this.el.bind("touchmove",B),this.el.bind("touchend",B),k(this.options.hideHover?null:0)},c.prototype.createPath=function(b,c,d,e,f){var g,h,i,j,k,l,m,n,o,p,q,r,s;n="";if(this.options.smooth){i=this.gradients(b);for(j=0,s=b.length-1;0<=s?j<=s:j>=s;0<=s?j++:j--)g=b[j],j===0?n+="M"+g.x+","+g.y:(h=i[j],l=b[j-1],m=i[j-1],k=(g.x-l.x)/4,o=l.x+k,q=Math.min(e,l.y+k*m),p=g.x-k,r=Math.min(e,g.y-k*h),n+="C"+o+","+q+","+p+","+r+","+g.x+","+g.y)}else n="M"+a.map(b,function(a){return""+a.x+","+a.y}).join("L");return n},c.prototype.gradients=function(b){return a.map(b,function(a,c){return c===0?(b[1].y-a.y)/(b[1].x-a.x):c===b.length-1?(a.y-b[c-1].y)/(a.x-b[c-1].x):(b[c+1].y-b[c-1].y)/(b[c+1].x-b[c-1].x)})},c.prototype.measureText=function(a,b){var c,d;return b==null&&(b=12),d=this.r.text(100,100,a).attr("font-size",b),c=d.getBBox(),d.remove(),c},c.prototype.parseYear=function(a){var b,c,d,e,f;return typeof a=="number"?a:(b=a.match(/^(\d+) Q(\d)$/),c=a.match(/^(\d+)-(\d+)$/),d=a.match(/^(\d+)-(\d+)-(\d+)$/),e=a.match(/^(\d+) W(\d+)$/),b?(new Date(parseInt(b[1],10),parseInt(b[2],10)*3-1)).getTime():c?(new Date(parseInt(c[1],10),parseInt(c[2],10)-1)).getTime():d?(new Date(parseInt(d[1],10),parseInt(d[2],10)-1,parseInt(d[3],10))).getTime():e?(f=new Date(parseInt(e[1],10),0,1),f.getDay()!==4&&f.setMonth(0,1+(4-f.getDay()+7)%7),f.getTime()+parseInt(e[2],10)*6048e5):new Date(parseInt(a,10)))},c.prototype.commas=function(a){var b,c,d,e;return d=a<0?"-":"",b=Math.abs(a),c=Math.floor(b).toFixed(0),d+=c.replace(/(?=(?:\d{3})+$)(?!^)/g,","),e=b.toString(),e.length>c.length&&(d+=e.slice(c.length)),d},c}(),window.Morris=b})).call(this); \ No newline at end of file +((function(){var a,b;a=jQuery,b={},b.Line=function(){function c(c){if(!(this instanceof b.Line))return new b.Line(c);typeof c.element=="string"?this.el=a(document.getElementById(c.element)):this.el=a(c.element),this.options=a.extend({},this.defaults,c);if(this.options.data===void 0||this.options.data.length===0)return;this.el.addClass("graph-initialised"),this.precalc(),this.redraw()}return c.prototype.defaults={lineWidth:3,pointSize:4,lineColors:["#0b62a4","#7A92A3","#4da74d","#afd8f8","#edc240","#cb4b4b","#9440ed"],ymax:"auto",ymin:"auto 0",marginTop:25,marginRight:25,marginBottom:30,marginLeft:25,numLines:5,gridLineColor:"#aaa",gridTextColor:"#888",gridTextSize:12,gridStrokeWidth:.5,hoverPaddingX:10,hoverPaddingY:5,hoverMargin:10,hoverFillColor:"#fff",hoverBorderColor:"#ccc",hoverBorderWidth:2,hoverOpacity:.95,hoverLabelColor:"#444",hoverFontSize:12,smooth:!0,hideHover:!1,parseTime:!0,units:""},c.prototype.precalc=function(){var b,c,d,e,f,g,h,i,j,k=this;this.options.data.sort(function(a,b){return(a[k.options.xkey]=0;i<=0?a++:a--)j.push(a);return j}.apply(this),this.xmin=Math.min.apply(null,this.xvals),this.xmax=Math.max.apply(null,this.xvals),this.xmin===this.xmax&&(this.xmin-=1,this.xmax+=1),typeof this.options.ymax=="string"&&this.options.ymax.slice(0,4)==="auto"&&(c=Math.max.apply(null,Array.prototype.concat.apply([],this.series)),this.options.ymax.length>5?this.options.ymax=Math.max(parseInt(this.options.ymax.slice(5),10),c):this.options.ymax=c);if(typeof this.options.ymin=="string"&&this.options.ymin.slice(0,4)==="auto")return d=Math.min.apply(null,Array.prototype.concat.apply([],this.series)),this.options.ymin.length>5?this.options.ymin=Math.min(parseInt(this.options.ymin.slice(5),10),d):this.options.ymin=d},c.prototype.redraw=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,_,ba,bb,bc,bd,be=this;this.el.empty(),this.r=new Raphael(this.el[0]),w=Math.max(this.measureText(this.options.ymin+this.options.units,this.options.gridTextSize).width,this.measureText(this.options.ymax+this.options.units,this.options.gridTextSize).width),u=w+this.options.marginLeft,L=this.el.width()-u-this.options.marginRight,i=this.el.height()-this.options.marginTop-this.options.marginBottom,f=L/(this.xmax-this.xmin),g=i/(this.options.ymax-this.options.ymin),G=function(a){return be.xvals.length===1?u+L/2:u+(a-be.xmin)*f},H=function(a){return be.options.marginTop+i-(a-be.options.ymin)*g},T=(this.options.ymax-this.options.ymin)/(this.options.numLines-1),h=Math.ceil(this.options.ymin/T)*T,t=Math.floor(this.options.ymax/T)*T;for(v=h;h<=t?v<=t:v>=t;v+=T)K=Math.floor(v),S=H(K),this.r.text(u-this.options.marginLeft/2,S,K+this.options.units).attr("font-size",this.options.gridTextSize).attr("fill",this.options.gridTextColor).attr("text-anchor","end"),this.r.path("M"+u+","+S+"H"+(u+L)).attr("stroke",this.options.gridLineColor).attr("stroke-width",this.options.gridStrokeWidth);B=null,Q=50,this.options.parseTime?(N=(new Date(this.xmin)).getFullYear(),O=(new Date(this.xmax)).getFullYear()):(N=this.xmin,O=this.xmax);for(p=N;N<=O?p<=O:p>=O;N<=O?p++:p--){if(this.options.parseTime){R=(new Date(p,0,1)).getTime();if(R=0;ba<=0?p++:p--)e=D[p],e.length>1&&(x=this.createPath(e,this.options.marginTop,u,this.options.marginTop+i,u+L),this.r.path(x).attr("stroke",this.options.lineColors[p]).attr("stroke-width",this.options.lineWidth));E=function(){var a,b;b=[];for(p=0,a=D.length-1;0<=a?p<=a:p>=a;0<=a?p++:p--)b.push([]);return b}();for(p=bb=D.length-1;bb<=0?p<=0:p>=0;bb<=0?p++:p--){bc=D[p];for(X=0,Z=bc.length;X=bd;0<=bd?p++:p--)U=this.r.text(0,this.options.hoverFontSize*1.5*(p+1.5)-m/2,"").attr("fill",this.options.lineColors[p]).attr("font-size",this.options.hoverFontSize),V.push(U),o.push(U);return J=function(b){var c,e,f,g,h;o.show(),P.attr("text",be.columnLabels[b]);for(c=0,h=be.series.length-1;0<=h?c<=h:c>=h;0<=h?c++:c--)V[c].attr("text",""+be.seriesLabels[c]+": "+be.commas(be.series[c][b])+be.options.units);return e=Math.max.apply(null,a.map(V,function(a){return a.getBBox().width})),e=Math.max(e,P.getBBox().width),l.attr("width",e+be.options.hoverPaddingX*2),l.attr("x",-be.options.hoverPaddingX-e/2),g=Math.min.apply(null,a.map(be.series,function(a){return H(a[b])})),g>m+be.options.hoverPaddingY*2+be.options.hoverMargin+be.options.marginTop?g=g-m/2-be.options.hoverPaddingY-be.options.hoverMargin:g=g+m/2+be.options.hoverPaddingY+be.options.hoverMargin,g=Math.max(be.options.marginTop+m/2+be.options.hoverPaddingY,g),g=Math.min(be.options.marginTop+i-m/2-be.options.hoverPaddingY,g),f=Math.min(u+L-e/2-be.options.hoverPaddingX,d[b]),f=Math.max(u+e/2+be.options.hoverPaddingX,f),o.attr("transform","t"+f+","+g)},j=function(){return o.hide()},n=a.map(d.slice(1),function(a,b){return(a+d[b])/2}),A=null,y=Raphael.animation({r:this.options.pointSize+3},25,"linear"),z=Raphael.animation({r:this.options.pointSize},25,"linear"),k=function(a){var b,c,d;if(A!==null&&A!==a)for(b=0,c=E.length-1;0<=c?b<=c:b>=c;0<=c?b++:b--)E[b][A].animate(z);if(a!==null&&A!==a){for(b=0,d=E.length-1;0<=d?b<=d:b>=d;0<=d?b++:b--)E[b][a].animate(y);J(a)}A=a;if(a===null)return j()},I=function(a){var b,c,d;a-=be.el.offset().left,d=[];for(b=c=n.length;c<=0?b<=0:b>=0;c<=0?b++:b--){if(b===0||n[b-1]>a){k(b);break}d.push(void 0)}return d},this.el.mousemove(function(a){return I(a.pageX)}),this.options.hideHover&&this.el.mouseout(function(a){return k(null)}),F=function(a){var b;return b=a.originalEvent.touches[0]||a.originalEvent.changedTouches[0],I(b.pageX),b},this.el.bind("touchstart",F),this.el.bind("touchmove",F),this.el.bind("touchend",F),k(this.options.hideHover?null:0)},c.prototype.createPath=function(b,c,d,e,f){var g,h,i,j,k,l,m,n,o,p,q,r,s;n="";if(this.options.smooth){i=this.gradients(b);for(j=0,s=b.length-1;0<=s?j<=s:j>=s;0<=s?j++:j--)g=b[j],j===0?n+="M"+g.x+","+g.y:(h=i[j],l=b[j-1],m=i[j-1],k=(g.x-l.x)/4,o=l.x+k,q=Math.min(e,l.y+k*m),p=g.x-k,r=Math.min(e,g.y-k*h),n+="C"+o+","+q+","+p+","+r+","+g.x+","+g.y)}else n="M"+a.map(b,function(a){return""+a.x+","+a.y}).join("L");return n},c.prototype.gradients=function(b){return a.map(b,function(a,c){return c===0?(b[1].y-a.y)/(b[1].x-a.x):c===b.length-1?(a.y-b[c-1].y)/(a.x-b[c-1].x):(b[c+1].y-b[c-1].y)/(b[c+1].x-b[c-1].x)})},c.prototype.measureText=function(a,b){var c,d;return b==null&&(b=12),d=this.r.text(100,100,a).attr("font-size",b),c=d.getBBox(),d.remove(),c},c.prototype.parseYear=function(a){var b,c,d,e,f;return typeof a=="number"?a:(b=a.match(/^(\d+) Q(\d)$/),c=a.match(/^(\d+)-(\d+)$/),d=a.match(/^(\d+)-(\d+)-(\d+)$/),e=a.match(/^(\d+) W(\d+)$/),b?(new Date(parseInt(b[1],10),parseInt(b[2],10)*3-1,1)).getTime():c?(new Date(parseInt(c[1],10),parseInt(c[2],10)-1,1)).getTime():d?(new Date(parseInt(d[1],10),parseInt(d[2],10)-1,parseInt(d[3],10))).getTime():e?(f=new Date(parseInt(e[1],10),0,1),f.getDay()!==4&&f.setMonth(0,1+(4-f.getDay()+7)%7),f.getTime()+parseInt(e[2],10)*6048e5):new Date(parseInt(a,10),0,1))},c.prototype.commas=function(a){var b,c,d,e;return d=a<0?"-":"",b=Math.abs(a),c=Math.floor(b).toFixed(0),d+=c.replace(/(?=(?:\d{3})+$)(?!^)/g,","),e=b.toString(),e.length>c.length&&(d+=e.slice(c.length)),d},c}(),window.Morris=b})).call(this); \ No newline at end of file