diff --git a/morris.coffee b/morris.coffee index 49f14904..059934f6 100644 --- a/morris.coffee +++ b/morris.coffee @@ -267,7 +267,7 @@ class Morris.Line # drawSeries: -> for i in [@seriesCoords.length-1..0] - coords = @seriesCoords[i] + coords = $.map(@seriesCoords[i], (c) -> c) if coords.length > 1 path = @createPath coords, @options.marginTop, @left, @options.marginTop + @height, @left + @width @r.path(path) @@ -287,9 +287,8 @@ class Morris.Line # create a path for a data series # - createPath: (all_coords, top, left, bottom, right) -> + createPath: (coords, top, left, bottom, right) -> path = "" - coords = $.map(all_coords, (c) -> c) if @options.smooth grads = @gradients coords for i in [0..coords.length-1] diff --git a/morris.js b/morris.js index e2038b5a..a60b535a 100644 --- a/morris.js +++ b/morris.js @@ -315,7 +315,9 @@ Line.prototype.drawSeries = function() { var c, circle, coords, i, path, _i, _j, _ref, _ref1, _results; for (i = _i = _ref = this.seriesCoords.length - 1; _ref <= 0 ? _i <= 0 : _i >= 0; i = _ref <= 0 ? ++_i : --_i) { - coords = this.seriesCoords[i]; + coords = $.map(this.seriesCoords[i], function(c) { + return c; + }); if (coords.length > 1) { path = this.createPath(coords, this.options.marginTop, this.left, this.options.marginTop + this.height, this.left + this.width); this.r.path(path).attr('stroke', this.options.lineColors[i]).attr('stroke-width', this.options.lineWidth); @@ -350,12 +352,9 @@ return _results; }; - Line.prototype.createPath = function(all_coords, top, left, bottom, right) { - var c, coords, g, grads, i, ix, lc, lg, path, x1, x2, y1, y2, _i, _ref; + Line.prototype.createPath = function(coords, top, left, bottom, right) { + var c, g, grads, i, ix, lc, lg, path, x1, x2, y1, y2, _i, _ref; path = ""; - coords = $.map(all_coords, function(c) { - return c; - }); if (this.options.smooth) { grads = this.gradients(coords); for (i = _i = 0, _ref = coords.length - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) { diff --git a/morris.min.js b/morris.min.js index 236dec6b..1d34e131 100644 --- a/morris.min.js +++ b/morris.min.js @@ -1,2 +1,2 @@ // Generated by CoffeeScript 1.3.3 -(function(){var a,b,c,d,e=function(a,b){return function(){return a.apply(b,arguments)}};a=jQuery,b={},b.Line=function(){function c(c){this.updateHilight=e(this.updateHilight,this),this.hilight=e(this.hilight,this),this.updateHover=e(this.updateHover,this),this.transY=e(this.transY,this),this.transX=e(this.transX,this);var d,f=this;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);if(this.el===null||this.el.length===0)throw new Error("Graph placeholder not found.");this.options=a.extend({},this.defaults,c),typeof this.options.units=="string"&&(this.options.postUnits=c.units);if(this.options.data===void 0||this.options.data.length===0)return;this.el.addClass("graph-initialised"),this.r=new Raphael(this.el[0]),this.pointGrow=Raphael.animation({r:this.options.pointSize+3},25,"linear"),this.pointShrink=Raphael.animation({r:this.options.pointSize},25,"linear"),this.elementWidth=null,this.elementHeight=null,this.dirty=!1,this.prevHilight=null,this.el.mousemove(function(a){return f.updateHilight(a.pageX)}),this.options.hideHover&&this.el.mouseout(function(a){return f.hilight(null)}),d=function(a){var b;return b=a.originalEvent.touches[0]||a.originalEvent.changedTouches[0],f.updateHilight(b.pageX),b},this.el.bind("touchstart",d),this.el.bind("touchmove",d),this.el.bind("touchend",d),this.setData(this.options.data)}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,preUnits:"",postUnits:"",dateFormat:function(a){return(new Date(a)).toString()},xLabels:"auto",xLabelFormat:null},c.prototype.setData=function(c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s=this;d==null&&(d=!0),this.options.data=c.slice(0),this.options.data.sort(function(a,b){return(a[s.options.xkey]=0;q<=0?a++:a--)r.push(a);return r}.apply(this),this.options.parseTime&&(this.columnLabels=a.map(this.columnLabels,function(a){return typeof a=="number"?s.options.dateFormat(a):a})),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"&&(h=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),h):this.options.ymax=h),typeof this.options.ymin=="string"&&this.options.ymin.slice(0,4)==="auto"&&(i=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),i):this.options.ymin=i),this.yInterval=(this.options.ymax-this.options.ymin)/(this.options.numLines-1),this.yInterval>0&&this.yInterval<1?this.precision=-Math.floor(Math.log(this.yInterval)/Math.log(10)):this.precision=0,this.dirty=!0;if(d)return this.redraw()},c.prototype.calc=function(){var b,c,d,e,f,g,h,i,j=this;e=this.el.width(),b=this.el.height();if(this.elementWidth!==e||this.elementHeight!==b||this.dirty){this.elementWidth=e,this.elementHeight=b,this.dirty=!1,this.maxYLabelWidth=Math.max(this.measureText(this.yLabelFormat(this.options.ymin),this.options.gridTextSize).width,this.measureText(this.yLabelFormat(this.options.ymax),this.options.gridTextSize).width),this.left=this.maxYLabelWidth+this.options.marginLeft,this.width=this.el.width()-this.left-this.options.marginRight,this.height=this.el.height()-this.options.marginTop-this.options.marginBottom,this.dx=this.width/(this.xmax-this.xmin),this.dy=this.height/(this.options.ymax-this.options.ymin),this.columns=function(){var a,b,c,d;c=this.xvals,d=[];for(a=0,b=c.length;a=g;h=n+=r)j=parseFloat(h.toFixed(this.precision)),l=this.transY(j),this.r.text(this.left-this.options.marginLeft/2,l,this.yLabelFormat(j)).attr("font-size",this.options.gridTextSize).attr("fill",this.options.gridTextColor).attr("text-anchor","end"),this.r.path("M"+this.left+","+l+"H"+(this.left+this.width)).attr("stroke",this.options.gridLineColor).attr("stroke-width",this.options.gridStrokeWidth);m=this.options.marginTop+this.height+this.options.marginBottom/2,k=50,i=null,a=function(a,b){var c,d;return c=w.r.text(w.transX(b),m,a).attr("font-size",w.options.gridTextSize).attr("fill",w.options.gridTextColor),d=c.getBBox(),(i===null||i<=d.x)&&d.x>=0&&d.x+d.width=t;d=0<=t?++p:--p)f=this.columnLabels[this.columnLabels.length-d-1],v.push(a(f,d));return v},c.prototype.drawSeries=function(){var a,b,c,d,e,f,g,h,i,j;for(d=f=h=this.seriesCoords.length-1;h<=0?f<=0:f>=0;d=h<=0?++f:--f)c=this.seriesCoords[d],c.length>1&&(e=this.createPath(c,this.options.marginTop,this.left,this.options.marginTop+this.height,this.left+this.width),this.r.path(e).attr("stroke",this.options.lineColors[d]).attr("stroke-width",this.options.lineWidth));this.seriesPoints=function(){var a,b,c;c=[];for(d=a=0,b=this.seriesCoords.length-1;0<=b?a<=b:a>=b;d=0<=b?++a:--a)c.push([]);return c}.call(this),j=[];for(d=g=i=this.seriesCoords.length-1;i<=0?g<=0:g>=0;d=i<=0?++g:--g)j.push(function(){var c,e,f,g;f=this.seriesCoords[d],g=[];for(c=0,e=f.length;c=u;k=0<=u?++t:--t)g=h[k],k===0?o+="M"+g.x+","+g.y:(i=j[k],m=h[k-1],n=j[k-1],l=(g.x-m.x)/4,p=m.x+l,r=Math.min(e,m.y+l*n),q=g.x-l,s=Math.min(e,g.y-l*i),o+="C"+p+","+r+","+q+","+s+","+g.x+","+g.y)}else o="M"+a.map(h,function(a){return""+a.x+","+a.y}).join("L");return o},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.drawHover=function(){var a,b,c,d,e;this.hoverHeight=this.options.hoverFontSize*1.5*(this.series.length+1),this.hover=this.r.rect(-10,-this.hoverHeight/2-this.options.hoverPaddingY,20,this.hoverHeight+this.options.hoverPaddingY*2,10).attr("fill",this.options.hoverFillColor).attr("stroke",this.options.hoverBorderColor).attr("stroke-width",this.options.hoverBorderWidth).attr("opacity",this.options.hoverOpacity),this.xLabel=this.r.text(0,this.options.hoverFontSize*.75-this.hoverHeight/2,"").attr("fill",this.options.hoverLabelColor).attr("font-weight","bold").attr("font-size",this.options.hoverFontSize),this.hoverSet=this.r.set(),this.hoverSet.push(this.hover),this.hoverSet.push(this.xLabel),this.yLabels=[],e=[];for(a=c=0,d=this.series.length-1;0<=d?c<=d:c>=d;a=0<=d?++c:--c)b=this.r.text(0,this.options.hoverFontSize*1.5*(a+1.5)-this.hoverHeight/2,"").attr("fill",this.options.lineColors[a]).attr("font-size",this.options.hoverFontSize),this.yLabels.push(b),e.push(this.hoverSet.push(b));return e},c.prototype.updateHover=function(b){var c,d,e,f,g,h,i=this;this.hoverSet.show(),this.xLabel.attr("text",this.columnLabels[b]);for(c=g=0,h=this.series.length-1;0<=h?g<=h:g>=h;c=0<=h?++g:--g)this.yLabels[c].attr("text",""+this.seriesLabels[c]+": "+this.yLabelFormat(this.series[c][b]));return d=Math.max.apply(null,a.map(this.yLabels,function(a){return a.getBBox().width})),d=Math.max(d,this.xLabel.getBBox().width),this.hover.attr("width",d+this.options.hoverPaddingX*2),this.hover.attr("x",-this.options.hoverPaddingX-d/2),f=Math.min.apply(null,a.map(this.series,function(a){return i.transY(a[b])})),f>this.hoverHeight+this.options.hoverPaddingY*2+this.options.hoverMargin+this.options.marginTop?f=f-this.hoverHeight/2-this.options.hoverPaddingY-this.options.hoverMargin:f=f+this.hoverHeight/2+this.options.hoverPaddingY+this.options.hoverMargin,f=Math.max(this.options.marginTop+this.hoverHeight/2+this.options.hoverPaddingY,f),f=Math.min(this.options.marginTop+this.height-this.hoverHeight/2-this.options.hoverPaddingY,f),e=Math.min(this.left+this.width-d/2-this.options.hoverPaddingX,this.columns[b]),e=Math.max(this.left+d/2+this.options.hoverPaddingX,e),this.hoverSet.attr("transform","t"+e+","+f)},c.prototype.hideHover=function(){return this.hoverSet.hide()},c.prototype.hilight=function(a){var b,c,d,e,f;if(this.prevHilight!==null&&this.prevHilight!==a)for(b=c=0,e=this.seriesPoints.length-1;0<=e?c<=e:c>=e;b=0<=e?++c:--c)this.seriesPoints[b][this.prevHilight]&&this.seriesPoints[b][this.prevHilight].animate(this.pointShrink);if(a!==null&&this.prevHilight!==a){for(b=d=0,f=this.seriesPoints.length-1;0<=f?d<=f:d>=f;b=0<=f?++d:--d)this.seriesPoints[b][a]&&this.seriesPoints[b][a].animate(this.pointGrow);this.updateHover(a)}this.prevHilight=a;if(a===null)return this.hideHover()},c.prototype.updateHilight=function(a){var b,c,d,e;a-=this.el.offset().left,e=[];for(b=c=d=this.hoverMargins.length;d<=0?c<=0:c>=0;b=d<=0?++c:--c){if(b===0||this.hoverMargins[b-1]>a){this.hilight(b);break}e.push(void 0)}return e},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.yLabelFormat=function(a){return""+this.options.preUnits+b.commas(a)+this.options.postUnits},c}(),b.parseDate=function(a){var b,c,d,e,f,g,h,i,j,k,l;return typeof a=="number"?a:(c=a.match(/^(\d+) Q(\d)$/),e=a.match(/^(\d+)-(\d+)$/),f=a.match(/^(\d+)-(\d+)-(\d+)$/),h=a.match(/^(\d+) W(\d+)$/),i=a.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+)(Z|([+-])(\d\d):?(\d\d))?$/),j=a.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+):(\d+(\.\d+)?)(Z|([+-])(\d\d):?(\d\d))?$/),c?(new Date(parseInt(c[1],10),parseInt(c[2],10)*3-1,1)).getTime():e?(new Date(parseInt(e[1],10),parseInt(e[2],10)-1,1)).getTime():f?(new Date(parseInt(f[1],10),parseInt(f[2],10)-1,parseInt(f[3],10))).getTime():h?(k=new Date(parseInt(h[1],10),0,1),k.getDay()!==4&&k.setMonth(0,1+(4-k.getDay()+7)%7),k.getTime()+parseInt(h[2],10)*6048e5):i?i[6]?(g=0,i[6]!=="Z"&&(g=parseInt(i[8],10)*60+parseInt(i[9],10),i[7]==="+"&&(g=0-g)),Date.UTC(parseInt(i[1],10),parseInt(i[2],10)-1,parseInt(i[3],10),parseInt(i[4],10),parseInt(i[5],10)+g)):(new Date(parseInt(i[1],10),parseInt(i[2],10)-1,parseInt(i[3],10),parseInt(i[4],10),parseInt(i[5],10))).getTime():j?(l=parseFloat(j[6]),b=Math.floor(l),d=Math.round((l-b)*1e3),j[8]?(g=0,j[8]!=="Z"&&(g=parseInt(j[10],10)*60+parseInt(j[11],10),j[9]==="+"&&(g=0-g)),Date.UTC(parseInt(j[1],10),parseInt(j[2],10)-1,parseInt(j[3],10),parseInt(j[4],10),parseInt(j[5],10)+g,b,d)):(new Date(parseInt(j[1],10),parseInt(j[2],10)-1,parseInt(j[3],10),parseInt(j[4],10),parseInt(j[5],10),b,d)).getTime()):(new Date(parseInt(a,10),0,1)).getTime())},b.commas=function(a){var b,c,d,e;return a===null?"n/a":(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)},b.pad2=function(a){return(a<10?"0":"")+a},b.labelSeries=function(c,d,e,f,g){var h,i,j,k,l,m,n,o,p,q,r;j=200*(d-c)/e,i=new Date(c),n=b.LABEL_SPECS[f];if(n===void 0){r=b.AUTO_LABEL_ORDER;for(p=0,q=r.length;p=m.span){n=m;break}}}n===void 0&&(n=b.LABEL_SPECS.second),g&&(n=a.extend({},n,{fmt:g})),h=n.start(i),l=[];while((o=h.getTime())<=d)o>=c&&l.push([n.fmt(h),o]),n.incr(h);return l},c=function(a){return{span:a*60*1e3,start:function(a){return new Date(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours())},fmt:function(a){return""+b.pad2(a.getHours())+":"+b.pad2(a.getMinutes())},incr:function(b){return b.setMinutes(b.getMinutes()+a)}}},d=function(a){return{span:a*1e3,start:function(a){return new Date(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours(),a.getMinutes())},fmt:function(a){return""+b.pad2(a.getHours())+":"+b.pad2(a.getMinutes())+":"+b.pad2(a.getSeconds())},incr:function(b){return b.setSeconds(b.getSeconds()+a)}}},b.LABEL_SPECS={year:{span:1728e7,start:function(a){return new Date(a.getFullYear(),0,1)},fmt:function(a){return""+a.getFullYear()},incr:function(a){return a.setFullYear(a.getFullYear()+1)}},month:{span:24192e5,start:function(a){return new Date(a.getFullYear(),a.getMonth(),1)},fmt:function(a){return""+a.getFullYear()+"-"+b.pad2(a.getMonth()+1)},incr:function(a){return a.setMonth(a.getMonth()+1)}},day:{span:864e5,start:function(a){return new Date(a.getFullYear(),a.getMonth(),a.getDate())},fmt:function(a){return""+a.getFullYear()+"-"+b.pad2(a.getMonth()+1)+"-"+b.pad2(a.getDate())},incr:function(a){return a.setDate(a.getDate()+1)}},hour:c(60),"30min":c(30),"15min":c(15),"10min":c(10),"5min":c(5),minute:c(1),"30sec":d(30),"15sec":d(15),"10sec":d(10),"5sec":d(5),second:d(1)},b.AUTO_LABEL_ORDER=["year","month","day","hour","30min","15min","10min","5min","minute","30sec","15sec","10sec","5sec","second"],window.Morris=b}).call(this); \ No newline at end of file +(function(){var e,t,n,r,i=function(e,t){return function(){return e.apply(t,arguments)}};e=jQuery,t={},t.Line=function(){function n(n){this.updateHilight=i(this.updateHilight,this),this.hilight=i(this.hilight,this),this.updateHover=i(this.updateHover,this),this.transY=i(this.transY,this),this.transX=i(this.transX,this);var r,s=this;if(!(this instanceof t.Line))return new t.Line(n);typeof n.element=="string"?this.el=e(document.getElementById(n.element)):this.el=e(n.element);if(this.el===null||this.el.length===0)throw new Error("Graph placeholder not found.");this.options=e.extend({},this.defaults,n),typeof this.options.units=="string"&&(this.options.postUnits=n.units);if(this.options.data===void 0||this.options.data.length===0)return;this.el.addClass("graph-initialised"),this.r=new Raphael(this.el[0]),this.pointGrow=Raphael.animation({r:this.options.pointSize+3},25,"linear"),this.pointShrink=Raphael.animation({r:this.options.pointSize},25,"linear"),this.elementWidth=null,this.elementHeight=null,this.dirty=!1,this.prevHilight=null,this.el.mousemove(function(e){return s.updateHilight(e.pageX)}),this.options.hideHover&&this.el.mouseout(function(e){return s.hilight(null)}),r=function(e){var t;return t=e.originalEvent.touches[0]||e.originalEvent.changedTouches[0],s.updateHilight(t.pageX),t},this.el.bind("touchstart",r),this.el.bind("touchmove",r),this.el.bind("touchend",r),this.setData(this.options.data)}return n.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,preUnits:"",postUnits:"",dateFormat:function(e){return(new Date(e)).toString()},xLabels:"auto",xLabelFormat:null},n.prototype.setData=function(n,r){var i,s,o,u,a,f,l,c,h,p,d,v,m,g,y=this;r==null&&(r=!0),this.options.data=n.slice(0),this.options.data.sort(function(e,t){return(e[y.options.xkey]=0;m<=0?e++:e--)g.push(e);return g}.apply(this),this.options.parseTime&&(this.columnLabels=e.map(this.columnLabels,function(e){return typeof e=="number"?y.options.dateFormat(e):e})),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"&&(u=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),u):this.options.ymax=u),typeof this.options.ymin=="string"&&this.options.ymin.slice(0,4)==="auto"&&(a=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),a):this.options.ymin=a),this.yInterval=(this.options.ymax-this.options.ymin)/(this.options.numLines-1),this.yInterval>0&&this.yInterval<1?this.precision=-Math.floor(Math.log(this.yInterval)/Math.log(10)):this.precision=0,this.dirty=!0;if(r)return this.redraw()},n.prototype.calc=function(){var t,n,r,i,s,o,u,a,f=this;i=this.el.width(),t=this.el.height();if(this.elementWidth!==i||this.elementHeight!==t||this.dirty){this.elementWidth=i,this.elementHeight=t,this.dirty=!1,this.maxYLabelWidth=Math.max(this.measureText(this.yLabelFormat(this.options.ymin),this.options.gridTextSize).width,this.measureText(this.yLabelFormat(this.options.ymax),this.options.gridTextSize).width),this.left=this.maxYLabelWidth+this.options.marginLeft,this.width=this.el.width()-this.left-this.options.marginRight,this.height=this.el.height()-this.options.marginTop-this.options.marginBottom,this.dx=this.width/(this.xmax-this.xmin),this.dy=this.height/(this.options.ymax-this.options.ymin),this.columns=function(){var e,t,n,r;n=this.xvals,r=[];for(e=0,t=n.length;e=o;u=p+=g)f=parseFloat(u.toFixed(this.precision)),c=this.transY(f),this.r.text(this.left-this.options.marginLeft/2,c,this.yLabelFormat(f)).attr("font-size",this.options.gridTextSize).attr("fill",this.options.gridTextColor).attr("text-anchor","end"),this.r.path("M"+this.left+","+c+"H"+(this.left+this.width)).attr("stroke",this.options.gridLineColor).attr("stroke-width",this.options.gridStrokeWidth);h=this.options.marginTop+this.height+this.options.marginBottom/2,l=50,a=null,e=function(e,t){var n,r;return n=S.r.text(S.transX(t),h,e).attr("font-size",S.options.gridTextSize).attr("fill",S.options.gridTextColor),r=n.getBBox(),(a===null||a<=r.x)&&r.x>=0&&r.x+r.width=b;r=0<=b?++v:--v)s=this.columnLabels[this.columnLabels.length-r-1],E.push(e(s,r));return E},n.prototype.drawSeries=function(){var t,n,r,i,s,o,u,a,f,l;for(i=o=a=this.seriesCoords.length-1;a<=0?o<=0:o>=0;i=a<=0?++o:--o)r=e.map(this.seriesCoords[i],function(e){return e}),r.length>1&&(s=this.createPath(r,this.options.marginTop,this.left,this.options.marginTop+this.height,this.left+this.width),this.r.path(s).attr("stroke",this.options.lineColors[i]).attr("stroke-width",this.options.lineWidth));this.seriesPoints=function(){var e,t,n;n=[];for(i=e=0,t=this.seriesCoords.length-1;0<=t?e<=t:e>=t;i=0<=t?++e:--e)n.push([]);return n}.call(this),l=[];for(i=u=f=this.seriesCoords.length-1;f<=0?u<=0:u>=0;i=f<=0?++u:--u)l.push(function(){var e,r,s,o;s=this.seriesCoords[i],o=[];for(e=0,r=s.length;e=b;f=0<=b?++y:--y)o=t[f],f===0?p+="M"+o.x+","+o.y:(u=a[f],c=t[f-1],h=a[f-1],l=(o.x-c.x)/4,d=c.x+l,m=Math.min(i,c.y+l*h),v=o.x-l,g=Math.min(i,o.y-l*u),p+="C"+d+","+m+","+v+","+g+","+o.x+","+o.y)}else p="M"+e.map(t,function(e){return""+e.x+","+e.y}).join("L");return p},n.prototype.gradients=function(t){return e.map(t,function(e,n){return n===0?(t[1].y-e.y)/(t[1].x-e.x):n===t.length-1?(e.y-t[n-1].y)/(e.x-t[n-1].x):(t[n+1].y-t[n-1].y)/(t[n+1].x-t[n-1].x)})},n.prototype.drawHover=function(){var e,t,n,r,i;this.hoverHeight=this.options.hoverFontSize*1.5*(this.series.length+1),this.hover=this.r.rect(-10,-this.hoverHeight/2-this.options.hoverPaddingY,20,this.hoverHeight+this.options.hoverPaddingY*2,10).attr("fill",this.options.hoverFillColor).attr("stroke",this.options.hoverBorderColor).attr("stroke-width",this.options.hoverBorderWidth).attr("opacity",this.options.hoverOpacity),this.xLabel=this.r.text(0,this.options.hoverFontSize*.75-this.hoverHeight/2,"").attr("fill",this.options.hoverLabelColor).attr("font-weight","bold").attr("font-size",this.options.hoverFontSize),this.hoverSet=this.r.set(),this.hoverSet.push(this.hover),this.hoverSet.push(this.xLabel),this.yLabels=[],i=[];for(e=n=0,r=this.series.length-1;0<=r?n<=r:n>=r;e=0<=r?++n:--n)t=this.r.text(0,this.options.hoverFontSize*1.5*(e+1.5)-this.hoverHeight/2,"").attr("fill",this.options.lineColors[e]).attr("font-size",this.options.hoverFontSize),this.yLabels.push(t),i.push(this.hoverSet.push(t));return i},n.prototype.updateHover=function(t){var n,r,i,s,o,u,a=this;this.hoverSet.show(),this.xLabel.attr("text",this.columnLabels[t]);for(n=o=0,u=this.series.length-1;0<=u?o<=u:o>=u;n=0<=u?++o:--o)this.yLabels[n].attr("text",""+this.seriesLabels[n]+": "+this.yLabelFormat(this.series[n][t]));return r=Math.max.apply(null,e.map(this.yLabels,function(e){return e.getBBox().width})),r=Math.max(r,this.xLabel.getBBox().width),this.hover.attr("width",r+this.options.hoverPaddingX*2),this.hover.attr("x",-this.options.hoverPaddingX-r/2),s=Math.min.apply(null,e.map(this.series,function(e){return a.transY(e[t])})),s>this.hoverHeight+this.options.hoverPaddingY*2+this.options.hoverMargin+this.options.marginTop?s=s-this.hoverHeight/2-this.options.hoverPaddingY-this.options.hoverMargin:s=s+this.hoverHeight/2+this.options.hoverPaddingY+this.options.hoverMargin,s=Math.max(this.options.marginTop+this.hoverHeight/2+this.options.hoverPaddingY,s),s=Math.min(this.options.marginTop+this.height-this.hoverHeight/2-this.options.hoverPaddingY,s),i=Math.min(this.left+this.width-r/2-this.options.hoverPaddingX,this.columns[t]),i=Math.max(this.left+r/2+this.options.hoverPaddingX,i),this.hoverSet.attr("transform","t"+i+","+s)},n.prototype.hideHover=function(){return this.hoverSet.hide()},n.prototype.hilight=function(e){var t,n,r,i,s;if(this.prevHilight!==null&&this.prevHilight!==e)for(t=n=0,i=this.seriesPoints.length-1;0<=i?n<=i:n>=i;t=0<=i?++n:--n)this.seriesPoints[t][this.prevHilight]&&this.seriesPoints[t][this.prevHilight].animate(this.pointShrink);if(e!==null&&this.prevHilight!==e){for(t=r=0,s=this.seriesPoints.length-1;0<=s?r<=s:r>=s;t=0<=s?++r:--r)this.seriesPoints[t][e]&&this.seriesPoints[t][e].animate(this.pointGrow);this.updateHover(e)}this.prevHilight=e;if(e===null)return this.hideHover()},n.prototype.updateHilight=function(e){var t,n,r,i;e-=this.el.offset().left,i=[];for(t=n=r=this.hoverMargins.length;r<=0?n<=0:n>=0;t=r<=0?++n:--n){if(t===0||this.hoverMargins[t-1]>e){this.hilight(t);break}i.push(void 0)}return i},n.prototype.measureText=function(e,t){var n,r;return t==null&&(t=12),r=this.r.text(100,100,e).attr("font-size",t),n=r.getBBox(),r.remove(),n},n.prototype.yLabelFormat=function(e){return""+this.options.preUnits+t.commas(e)+this.options.postUnits},n}(),t.parseDate=function(e){var t,n,r,i,s,o,u,a,f,l,c;return typeof e=="number"?e:(n=e.match(/^(\d+) Q(\d)$/),i=e.match(/^(\d+)-(\d+)$/),s=e.match(/^(\d+)-(\d+)-(\d+)$/),u=e.match(/^(\d+) W(\d+)$/),a=e.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+)(Z|([+-])(\d\d):?(\d\d))?$/),f=e.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+):(\d+(\.\d+)?)(Z|([+-])(\d\d):?(\d\d))?$/),n?(new Date(parseInt(n[1],10),parseInt(n[2],10)*3-1,1)).getTime():i?(new Date(parseInt(i[1],10),parseInt(i[2],10)-1,1)).getTime():s?(new Date(parseInt(s[1],10),parseInt(s[2],10)-1,parseInt(s[3],10))).getTime():u?(l=new Date(parseInt(u[1],10),0,1),l.getDay()!==4&&l.setMonth(0,1+(4-l.getDay()+7)%7),l.getTime()+parseInt(u[2],10)*6048e5):a?a[6]?(o=0,a[6]!=="Z"&&(o=parseInt(a[8],10)*60+parseInt(a[9],10),a[7]==="+"&&(o=0-o)),Date.UTC(parseInt(a[1],10),parseInt(a[2],10)-1,parseInt(a[3],10),parseInt(a[4],10),parseInt(a[5],10)+o)):(new Date(parseInt(a[1],10),parseInt(a[2],10)-1,parseInt(a[3],10),parseInt(a[4],10),parseInt(a[5],10))).getTime():f?(c=parseFloat(f[6]),t=Math.floor(c),r=Math.round((c-t)*1e3),f[8]?(o=0,f[8]!=="Z"&&(o=parseInt(f[10],10)*60+parseInt(f[11],10),f[9]==="+"&&(o=0-o)),Date.UTC(parseInt(f[1],10),parseInt(f[2],10)-1,parseInt(f[3],10),parseInt(f[4],10),parseInt(f[5],10)+o,t,r)):(new Date(parseInt(f[1],10),parseInt(f[2],10)-1,parseInt(f[3],10),parseInt(f[4],10),parseInt(f[5],10),t,r)).getTime()):(new Date(parseInt(e,10),0,1)).getTime())},t.commas=function(e){var t,n,r,i;return e===null?"n/a":(r=e<0?"-":"",t=Math.abs(e),n=Math.floor(t).toFixed(0),r+=n.replace(/(?=(?:\d{3})+$)(?!^)/g,","),i=t.toString(),i.length>n.length&&(r+=i.slice(n.length)),r)},t.pad2=function(e){return(e<10?"0":"")+e},t.labelSeries=function(n,r,i,s,o){var u,a,f,l,c,h,p,d,v,m,g;f=200*(r-n)/i,a=new Date(n),p=t.LABEL_SPECS[s];if(p===void 0){g=t.AUTO_LABEL_ORDER;for(v=0,m=g.length;v=h.span){p=h;break}}}p===void 0&&(p=t.LABEL_SPECS.second),o&&(p=e.extend({},p,{fmt:o})),u=p.start(a),c=[];while((d=u.getTime())<=r)d>=n&&c.push([p.fmt(u),d]),p.incr(u);return c},n=function(e){return{span:e*60*1e3,start:function(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours())},fmt:function(e){return""+t.pad2(e.getHours())+":"+t.pad2(e.getMinutes())},incr:function(t){return t.setMinutes(t.getMinutes()+e)}}},r=function(e){return{span:e*1e3,start:function(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes())},fmt:function(e){return""+t.pad2(e.getHours())+":"+t.pad2(e.getMinutes())+":"+t.pad2(e.getSeconds())},incr:function(t){return t.setSeconds(t.getSeconds()+e)}}},t.LABEL_SPECS={year:{span:1728e7,start:function(e){return new Date(e.getFullYear(),0,1)},fmt:function(e){return""+e.getFullYear()},incr:function(e){return e.setFullYear(e.getFullYear()+1)}},month:{span:24192e5,start:function(e){return new Date(e.getFullYear(),e.getMonth(),1)},fmt:function(e){return""+e.getFullYear()+"-"+t.pad2(e.getMonth()+1)},incr:function(e){return e.setMonth(e.getMonth()+1)}},day:{span:864e5,start:function(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())},fmt:function(e){return""+e.getFullYear()+"-"+t.pad2(e.getMonth()+1)+"-"+t.pad2(e.getDate())},incr:function(e){return e.setDate(e.getDate()+1)}},hour:n(60),"30min":n(30),"15min":n(15),"10min":n(10),"5min":n(5),minute:n(1),"30sec":r(30),"15sec":r(15),"10sec":r(10),"5sec":r(5),second:r(1)},t.AUTO_LABEL_ORDER=["year","month","day","hour","30min","15min","10min","5min","minute","30sec","15sec","10sec","5sec","second"],window.Morris=t}).call(this); \ No newline at end of file