diff --git a/examples/negative.html b/examples/negative.html index 073ae6a..d1ee1a2 100644 --- a/examples/negative.html +++ b/examples/negative.html @@ -28,7 +28,8 @@ Morris.Line({ data: neg_data, xkey: 'period', ykeys: ['a'], - labels: ['Series A'] + labels: ['Series A'], + units: '%' }); diff --git a/morris.coffee b/morris.coffee index 87dd540..3f1da69 100644 --- a/morris.coffee +++ b/morris.coffee @@ -59,6 +59,7 @@ class Morris.Line smooth: true hideHover: false parseTime: true + units: '' # Do any necessary pre-processing for a new dataset # @@ -112,8 +113,8 @@ class Morris.Line # calculate grid dimensions maxYLabelWidth = Math.max( - @measureText(@options.ymin, @options.gridTextSize).width, - @measureText(@options.ymax, @options.gridTextSize).width) + @measureText(@options.ymin + @options.units, @options.gridTextSize).width, + @measureText(@options.ymax + @options.units, @options.gridTextSize).width) left = maxYLabelWidth + @options.marginLeft width = @el.width() - left - @options.marginRight height = @el.height() - @options.marginTop - @options.marginBottom @@ -136,7 +137,7 @@ class Morris.Line for lineY in [firstY..lastY] by yInterval v = Math.floor(lineY) y = transY(v) - @r.text(left - @options.marginLeft/2, y, v) + @r.text(left - @options.marginLeft/2, y, v + @options.units) .attr('font-size', @options.gridTextSize) .attr('fill', @options.gridTextColor) .attr('text-anchor', 'end') @@ -205,7 +206,7 @@ class Morris.Line hoverSet.show() xLabel.attr('text', @columnLabels[index]) for i in [0..@series.length-1] - yLabels[i].attr('text', "#{@seriesLabels[i]}: #{@commas(@series[i][index])}") + yLabels[i].attr('text', "#{@seriesLabels[i]}: #{@commas(@series[i][index])}#{@options.units}") # recalculate hover box width maxLabelWidth = Math.max.apply null, $.map yLabels, (l) -> l.getBBox().width @@ -346,7 +347,8 @@ class Morris.Line # eg: commas(1234567) -> '1,234,567' # commas: (num) -> - num.toFixed(0).replace(/(?=(?:\d{3})+$)(?!^)/g, ',') + ret = if num < 0 then "-" else "" + ret + Math.abs(num).toFixed(0).replace(/(?=(?:\d{3})+$)(?!^)/g, ',') window.Morris = Morris # vim: set et ts=2 sw=2 sts=2 diff --git a/morris.js b/morris.js index b762f64..9399202 100644 --- a/morris.js +++ b/morris.js @@ -47,7 +47,8 @@ hoverFontSize: 12, smooth: true, hideHover: false, - parseTime: true + parseTime: true, + units: '' }; Line.prototype.precalc = function() { @@ -108,7 +109,7 @@ _this = this; this.el.empty(); this.r = new Raphael(this.el[0]); - maxYLabelWidth = Math.max(this.measureText(this.options.ymin, this.options.gridTextSize).width, this.measureText(this.options.ymax, this.options.gridTextSize).width); + maxYLabelWidth = 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); left = maxYLabelWidth + this.options.marginLeft; width = this.el.width() - left - this.options.marginRight; height = this.el.height() - this.options.marginTop - this.options.marginBottom; @@ -130,7 +131,7 @@ for (lineY = firstY; firstY <= lastY ? lineY <= lastY : lineY >= lastY; lineY += yInterval) { v = Math.floor(lineY); y = transY(v); - this.r.text(left - this.options.marginLeft / 2, y, v).attr('font-size', this.options.gridTextSize).attr('fill', this.options.gridTextColor).attr('text-anchor', 'end'); + 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; @@ -206,7 +207,7 @@ hoverSet.show(); xLabel.attr('text', _this.columnLabels[index]); for (i = 0, _ref8 = _this.series.length - 1; 0 <= _ref8 ? i <= _ref8 : i >= _ref8; 0 <= _ref8 ? i++ : i--) { - yLabels[i].attr('text', "" + _this.seriesLabels[i] + ": " + (_this.commas(_this.series[i][index]))); + yLabels[i].attr('text', "" + _this.seriesLabels[i] + ": " + (_this.commas(_this.series[i][index])) + _this.options.units); } maxLabelWidth = Math.max.apply(null, $.map(yLabels, function(l) { return l.getBBox().width; @@ -374,7 +375,9 @@ }; Line.prototype.commas = function(num) { - return num.toFixed(0).replace(/(?=(?:\d{3})+$)(?!^)/g, ','); + var ret; + ret = num < 0 ? "-" : ""; + return ret + Math.abs(num).toFixed(0).replace(/(?=(?:\d{3})+$)(?!^)/g, ','); }; return Line; diff --git a/morris.min.js b/morris.min.js index b1708da..2e56e26 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},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=this;this.el.empty(),this.r=new Raphael(this.el[0]),w=Math.max(this.measureText(this.options.ymin,this.options.gridTextSize).width,this.measureText(this.options.ymax,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 bd.xvals.length===1?u+L/2:u+(a-bd.xmin)*f},H=function(a){return bd.options.marginTop+i-(a-bd.options.ymin)*g},Q=(this.options.ymax-this.options.ymin)/(this.options.numLines-1),h=Math.ceil(this.options.ymin/Q)*Q,t=Math.floor(this.options.ymax/Q)*Q;for(v=h;h<=t?v<=t:v>=t;v+=Q)K=Math.floor(v),P=H(K),this.r.text(u-this.options.marginLeft/2,P,K).attr("font-size",this.options.gridTextSize).attr("fill",this.options.gridTextColor).attr("text-anchor","end"),this.r.path("M"+u+","+P+"H"+(u+L)).attr("stroke",this.options.gridLineColor).attr("stroke-width",this.options.gridStrokeWidth);B=null,O=50;for(p=X=Math.ceil(this.xmin),Y=Math.floor(this.xmax);X<=Y?p<=Y:p>=Y;X<=Y?p++:p--)s=this.options.parseTime?p:this.columnLabels[this.columnLabels.length-p-1],q=this.r.text(G(p),this.options.marginTop+i+this.options.marginBottom/2,s).attr("font-size",this.options.gridTextSize).attr("fill",this.options.gridTextColor),r=q.getBBox(),B===null||B<=r.x?B=r.x+r.width+O:q.remove();d=function(){var a,b,c,d;c=this.xvals,d=[];for(a=0,b=c.length;a=0;_<=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=ba=D.length-1;ba<=0?p<=0:p>=0;ba<=0?p++:p--){bb=D[p];for(U=0,W=bb.length;U=bc;0<=bc?p++:p--)R=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),S.push(R),o.push(R);return J=function(b){var c,e,f,g,h;o.show(),N.attr("text",bd.columnLabels[b]);for(c=0,h=bd.series.length-1;0<=h?c<=h:c>=h;0<=h?c++:c--)S[c].attr("text",""+bd.seriesLabels[c]+": "+bd.commas(bd.series[c][b]));return e=Math.max.apply(null,a.map(S,function(a){return a.getBBox().width})),e=Math.max(e,N.getBBox().width),l.attr("width",e+bd.options.hoverPaddingX*2),l.attr("x",-bd.options.hoverPaddingX-e/2),g=Math.min.apply(null,a.map(bd.series,function(a){return H(a[b])})),g>m+bd.options.hoverPaddingY*2+bd.options.hoverMargin+bd.options.marginTop?g=g-m/2-bd.options.hoverPaddingY-bd.options.hoverMargin:g=g+m/2+bd.options.hoverPaddingY+bd.options.hoverMargin,g=Math.max(bd.options.marginTop+m/2+bd.options.hoverPaddingY,g),g=Math.min(bd.options.marginTop+i-m/2-bd.options.hoverPaddingY,g),f=Math.min(u+L-e/2-bd.options.hoverPaddingX,d[b]),f=Math.max(u+e/2+bd.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-=bd.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,g,h,i,j,k,l,m;return h=a.toString(),c=h.match(/^(\d+) Q(\d)$/),e=h.match(/^(\d+)-(\d+)$/),f=h.match(/^(\d+)-(\d+)-(\d+)$/),g=h.match(/^(\d+) W(\d+)$/),c?parseInt(c[1],10)+(parseInt(c[2],10)*3-1)/12:g?(m=parseInt(g[1],10),k=new Date(m,0,1),l=new Date(m+1,0,1),k.getDay()!==4&&k.setMonth(0,1+(4-k.getDay()+7)%7),l.getDay()!==4&&l.setMonth(0,1+(4-l.getDay()+7)%7),j=Math.ceil((l-k)/6048e5),parseInt(g[1],10)+(parseInt(g[2],10)-1)/j):e?parseInt(e[1],10)+(parseInt(e[2],10)-1)/12:f?(m=parseInt(f[1],10),d=parseInt(f[2],10),b=parseInt(f[3],10),i=(new Date(m,d-1,b)).getTime(),k=(new Date(m,0,1)).getTime(),l=(new Date(m+1,0,1)).getTime(),m+(i-k)/(l-k)):parseInt(a,10)},c.prototype.commas=function(a){return a.toFixed(0).replace(/(?=(?:\d{3})+$)(?!^)/g,",")},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=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 bd.xvals.length===1?u+L/2:u+(a-bd.xmin)*f},H=function(a){return bd.options.marginTop+i-(a-bd.options.ymin)*g},Q=(this.options.ymax-this.options.ymin)/(this.options.numLines-1),h=Math.ceil(this.options.ymin/Q)*Q,t=Math.floor(this.options.ymax/Q)*Q;for(v=h;h<=t?v<=t:v>=t;v+=Q)K=Math.floor(v),P=H(K),this.r.text(u-this.options.marginLeft/2,P,K+this.options.units).attr("font-size",this.options.gridTextSize).attr("fill",this.options.gridTextColor).attr("text-anchor","end"),this.r.path("M"+u+","+P+"H"+(u+L)).attr("stroke",this.options.gridLineColor).attr("stroke-width",this.options.gridStrokeWidth);B=null,O=50;for(p=X=Math.ceil(this.xmin),Y=Math.floor(this.xmax);X<=Y?p<=Y:p>=Y;X<=Y?p++:p--)s=this.options.parseTime?p:this.columnLabels[this.columnLabels.length-p-1],q=this.r.text(G(p),this.options.marginTop+i+this.options.marginBottom/2,s).attr("font-size",this.options.gridTextSize).attr("fill",this.options.gridTextColor),r=q.getBBox(),B===null||B<=r.x?B=r.x+r.width+O:q.remove();d=function(){var a,b,c,d;c=this.xvals,d=[];for(a=0,b=c.length;a=0;_<=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=ba=D.length-1;ba<=0?p<=0:p>=0;ba<=0?p++:p--){bb=D[p];for(U=0,W=bb.length;U=bc;0<=bc?p++:p--)R=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),S.push(R),o.push(R);return J=function(b){var c,e,f,g,h;o.show(),N.attr("text",bd.columnLabels[b]);for(c=0,h=bd.series.length-1;0<=h?c<=h:c>=h;0<=h?c++:c--)S[c].attr("text",""+bd.seriesLabels[c]+": "+bd.commas(bd.series[c][b])+bd.options.units);return e=Math.max.apply(null,a.map(S,function(a){return a.getBBox().width})),e=Math.max(e,N.getBBox().width),l.attr("width",e+bd.options.hoverPaddingX*2),l.attr("x",-bd.options.hoverPaddingX-e/2),g=Math.min.apply(null,a.map(bd.series,function(a){return H(a[b])})),g>m+bd.options.hoverPaddingY*2+bd.options.hoverMargin+bd.options.marginTop?g=g-m/2-bd.options.hoverPaddingY-bd.options.hoverMargin:g=g+m/2+bd.options.hoverPaddingY+bd.options.hoverMargin,g=Math.max(bd.options.marginTop+m/2+bd.options.hoverPaddingY,g),g=Math.min(bd.options.marginTop+i-m/2-bd.options.hoverPaddingY,g),f=Math.min(u+L-e/2-bd.options.hoverPaddingX,d[b]),f=Math.max(u+e/2+bd.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-=bd.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,g,h,i,j,k,l,m;return h=a.toString(),c=h.match(/^(\d+) Q(\d)$/),e=h.match(/^(\d+)-(\d+)$/),f=h.match(/^(\d+)-(\d+)-(\d+)$/),g=h.match(/^(\d+) W(\d+)$/),c?parseInt(c[1],10)+(parseInt(c[2],10)*3-1)/12:g?(m=parseInt(g[1],10),k=new Date(m,0,1),l=new Date(m+1,0,1),k.getDay()!==4&&k.setMonth(0,1+(4-k.getDay()+7)%7),l.getDay()!==4&&l.setMonth(0,1+(4-l.getDay()+7)%7),j=Math.ceil((l-k)/6048e5),parseInt(g[1],10)+(parseInt(g[2],10)-1)/j):e?parseInt(e[1],10)+(parseInt(e[2],10)-1)/12:f?(m=parseInt(f[1],10),d=parseInt(f[2],10),b=parseInt(f[3],10),i=(new Date(m,d-1,b)).getTime(),k=(new Date(m,0,1)).getTime(),l=(new Date(m+1,0,1)).getTime(),m+(i-k)/(l-k)):parseInt(a,10)},c.prototype.commas=function(a){var b;return b=a<0?"-":"",b+Math.abs(a).toFixed(0).replace(/(?=(?:\d{3})+$)(?!^)/g,",")},c}(),window.Morris=b})).call(this); \ No newline at end of file