diff --git a/lib/morris.donut.coffee b/lib/morris.donut.coffee index ad34b0f..6aca8dd 100644 --- a/lib/morris.donut.coffee +++ b/lib/morris.donut.coffee @@ -85,13 +85,14 @@ class Morris.Donut idx = 0 for d in @data if d.value == max_value - @select @segments[idx] + @select idx break idx += 1 - # @private - select: (segment) => + # Select the segment at the given index. + select: (idx) => s.deselect() for s in @segments + segment = @segments[idx] segment.select() @setLabels segment.data.label, @options.formatter(segment.data.value) diff --git a/morris.js b/morris.js index 112e3b2..5b61c7c 100644 --- a/morris.js +++ b/morris.js @@ -143,7 +143,7 @@ for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { d = _ref2[_k]; if (d.value === max_value) { - this.select(this.segments[idx]); + this.select(idx); break; } _results.push(idx += 1); @@ -151,13 +151,14 @@ return _results; }; - Donut.prototype.select = function(segment) { - var s, _i, _len, _ref; + Donut.prototype.select = function(idx) { + var s, segment, _i, _len, _ref; _ref = this.segments; for (_i = 0, _len = _ref.length; _i < _len; _i++) { s = _ref[_i]; s.deselect(); } + segment = this.segments[idx]; segment.select(); return this.setLabels(segment.data.label, this.options.formatter(segment.data.value)); }; diff --git a/morris.min.js b/morris.min.js index dea11eb..c5245c9 100644 --- a/morris.min.js +++ b/morris.min.js @@ -1 +1 @@ -(function(){var e,t,n,r,i=[].slice,s=function(e,t){return function(){return e.apply(t,arguments)}},o={}.hasOwnProperty,u=function(e,t){function r(){this.constructor=e}for(var n in t)o.call(t,n)&&(e[n]=t[n]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e};t=window.Morris={},e=jQuery,t.EventEmitter=function(){function e(){}return e.prototype.on=function(e,t){return this.handlers==null&&(this.handlers={}),this.handlers[e]==null&&(this.handlers[e]=[]),this.handlers[e].push(t)},e.prototype.fire=function(){var e,t,n,r,s,o,u;n=arguments[0],e=2<=arguments.length?i.call(arguments,1):[];if(this.handlers!=null&&this.handlers[n]!=null){o=this.handlers[n],u=[];for(r=0,s=o.length;rn.length&&(r+=i.slice(n.length)),r)},t.pad2=function(e){return(e<10?"0":"")+e},t.Donut=function(){function n(n){this.select=s(this.select,this);if(!(this instanceof t.Donut))return new t.Donut(n);typeof n.element=="string"?this.el=e(document.getElementById(n.element)):this.el=e(n.element),this.options=e.extend({},this.defaults,n);if(this.el===null||this.el.length===0)throw new Error("Graph placeholder not found.");if(n.data===void 0||n.data.length===0)return;this.data=n.data,this.el.addClass("graph-initialised"),this.redraw()}return n.prototype.defaults={colors:["#0B62A4","#3980B5","#679DC6","#95BBD7","#B0CCE1","#095791","#095085","#083E67","#052C48","#042135"],formatter:t.commas},n.prototype.redraw=function(){var e,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x;this.el.empty(),this.r=new Raphael(this.el[0]),n=this.el.width()/2,r=this.el.height()/2,h=(Math.min(n,r)-10)/3,c=0,w=this.data;for(d=0,g=w.length;dMath.PI?1:0,this.path=this.calcSegment(this.inner+3,this.inner+this.outer-5),this.selectedPath=this.calcSegment(this.inner+3,this.inner+this.outer),this.hilight=this.calcArc(this.inner)}return u(t,e),t.prototype.calcArcPoints=function(e){return[this.cx+e*this.sin_p0,this.cy+e*this.cos_p0,this.cx+e*this.sin_p1,this.cy+e*this.cos_p1]},t.prototype.calcSegment=function(e,t){var n,r,i,s,o,u,a,f,l,c;return l=this.calcArcPoints(e),n=l[0],i=l[1],r=l[2],s=l[3],c=this.calcArcPoints(t),o=c[0],a=c[1],u=c[2],f=c[3],"M"+n+","+i+("A"+e+","+e+",0,"+this.long+",0,"+r+","+s)+("L"+u+","+f)+("A"+t+","+t+",0,"+this.long+",1,"+o+","+a)+"Z"},t.prototype.calcArc=function(e){var t,n,r,i,s;return s=this.calcArcPoints(e),t=s[0],r=s[1],n=s[2],i=s[3],"M"+t+","+r+("A"+e+","+e+",0,"+this.long+",0,"+n+","+i)},t.prototype.render=function(e){var t=this;return this.arc=e.path(this.hilight).attr({stroke:this.color,"stroke-width":2,opacity:0}),this.seg=e.path(this.path).attr({fill:this.color,stroke:"white","stroke-width":3}).hover(function(){return t.fire("hover",t)})},t.prototype.select=function(){if(!this.selected)return this.seg.animate({path:this.selectedPath},150,"<>"),this.arc.animate({opacity:1},150,"<>"),this.selected=!0},t.prototype.deselect=function(){if(this.selected)return this.seg.animate({path:this.path},150,"<>"),this.arc.animate({opacity:0},150,"<>"),this.selected=!1},t}(t.EventEmitter),t.Line=function(){function n(n){this.updateHilight=s(this.updateHilight,this),this.hilight=s(this.hilight,this),this.updateHover=s(this.updateHover,this),this.transY=s(this.transY,this),this.transX=s(this.transX,this);var r,i=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 i.updateHilight(e.pageX)}),this.options.hideHover&&this.el.mouseout(function(e){return i.hilight(null)}),r=function(e){var t;return t=e.originalEvent.touches[0]||e.originalEvent.changedTouches[0],i.updateHilight(t.pageX),t},this.el.bind("touchstart",r),this.el.bind("touchmove",r),this.el.bind("touchend",r),this.seriesLabels=this.options.labels,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.ymax=Math.max(parseInt(this.options.ymax.slice(5),10),u):this.ymax=u):typeof this.options.ymax=="string"?this.ymax=parseInt(this.options.ymax,10):this.ymax=this.options.ymax,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.ymin=Math.min(parseInt(this.options.ymin.slice(5),10),a):this.ymin=a):typeof this.options.ymin=="string"?this.ymin=parseInt(this.options.ymin,10):this.ymin=this.options.ymin,this.ymin===this.ymax&&(this.ymin===!0&&(this.ymin-=1),this.ymax+=1),this.yInterval=(this.ymax-this.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.ymin),this.options.gridTextSize).width,this.measureText(this.yLabelFormat(this.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.ymax-this.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.colorForSeries(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.colorForSeries(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.prototype.colorForSeries=function(e){return this.options.lineColors[e%this.options.lineColors.length]},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.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"]}).call(this); \ No newline at end of file +(function(){var e,t,n,r,i=[].slice,s=function(e,t){return function(){return e.apply(t,arguments)}},o={}.hasOwnProperty,u=function(e,t){function r(){this.constructor=e}for(var n in t)o.call(t,n)&&(e[n]=t[n]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e};t=window.Morris={},e=jQuery,t.EventEmitter=function(){function e(){}return e.prototype.on=function(e,t){return this.handlers==null&&(this.handlers={}),this.handlers[e]==null&&(this.handlers[e]=[]),this.handlers[e].push(t)},e.prototype.fire=function(){var e,t,n,r,s,o,u;n=arguments[0],e=2<=arguments.length?i.call(arguments,1):[];if(this.handlers!=null&&this.handlers[n]!=null){o=this.handlers[n],u=[];for(r=0,s=o.length;rn.length&&(r+=i.slice(n.length)),r)},t.pad2=function(e){return(e<10?"0":"")+e},t.Donut=function(){function n(n){this.select=s(this.select,this);if(!(this instanceof t.Donut))return new t.Donut(n);typeof n.element=="string"?this.el=e(document.getElementById(n.element)):this.el=e(n.element),this.options=e.extend({},this.defaults,n);if(this.el===null||this.el.length===0)throw new Error("Graph placeholder not found.");if(n.data===void 0||n.data.length===0)return;this.data=n.data,this.el.addClass("graph-initialised"),this.redraw()}return n.prototype.defaults={colors:["#0B62A4","#3980B5","#679DC6","#95BBD7","#B0CCE1","#095791","#095085","#083E67","#052C48","#042135"],formatter:t.commas},n.prototype.redraw=function(){var e,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x;this.el.empty(),this.r=new Raphael(this.el[0]),n=this.el.width()/2,r=this.el.height()/2,h=(Math.min(n,r)-10)/3,c=0,w=this.data;for(d=0,g=w.length;dMath.PI?1:0,this.path=this.calcSegment(this.inner+3,this.inner+this.outer-5),this.selectedPath=this.calcSegment(this.inner+3,this.inner+this.outer),this.hilight=this.calcArc(this.inner)}return u(t,e),t.prototype.calcArcPoints=function(e){return[this.cx+e*this.sin_p0,this.cy+e*this.cos_p0,this.cx+e*this.sin_p1,this.cy+e*this.cos_p1]},t.prototype.calcSegment=function(e,t){var n,r,i,s,o,u,a,f,l,c;return l=this.calcArcPoints(e),n=l[0],i=l[1],r=l[2],s=l[3],c=this.calcArcPoints(t),o=c[0],a=c[1],u=c[2],f=c[3],"M"+n+","+i+("A"+e+","+e+",0,"+this.long+",0,"+r+","+s)+("L"+u+","+f)+("A"+t+","+t+",0,"+this.long+",1,"+o+","+a)+"Z"},t.prototype.calcArc=function(e){var t,n,r,i,s;return s=this.calcArcPoints(e),t=s[0],r=s[1],n=s[2],i=s[3],"M"+t+","+r+("A"+e+","+e+",0,"+this.long+",0,"+n+","+i)},t.prototype.render=function(e){var t=this;return this.arc=e.path(this.hilight).attr({stroke:this.color,"stroke-width":2,opacity:0}),this.seg=e.path(this.path).attr({fill:this.color,stroke:"white","stroke-width":3}).hover(function(){return t.fire("hover",t)})},t.prototype.select=function(){if(!this.selected)return this.seg.animate({path:this.selectedPath},150,"<>"),this.arc.animate({opacity:1},150,"<>"),this.selected=!0},t.prototype.deselect=function(){if(this.selected)return this.seg.animate({path:this.path},150,"<>"),this.arc.animate({opacity:0},150,"<>"),this.selected=!1},t}(t.EventEmitter),t.Line=function(){function n(n){this.updateHilight=s(this.updateHilight,this),this.hilight=s(this.hilight,this),this.updateHover=s(this.updateHover,this),this.transY=s(this.transY,this),this.transX=s(this.transX,this);var r,i=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 i.updateHilight(e.pageX)}),this.options.hideHover&&this.el.mouseout(function(e){return i.hilight(null)}),r=function(e){var t;return t=e.originalEvent.touches[0]||e.originalEvent.changedTouches[0],i.updateHilight(t.pageX),t},this.el.bind("touchstart",r),this.el.bind("touchmove",r),this.el.bind("touchend",r),this.seriesLabels=this.options.labels,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.ymax=Math.max(parseInt(this.options.ymax.slice(5),10),u):this.ymax=u):typeof this.options.ymax=="string"?this.ymax=parseInt(this.options.ymax,10):this.ymax=this.options.ymax,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.ymin=Math.min(parseInt(this.options.ymin.slice(5),10),a):this.ymin=a):typeof this.options.ymin=="string"?this.ymin=parseInt(this.options.ymin,10):this.ymin=this.options.ymin,this.ymin===this.ymax&&(this.ymin===!0&&(this.ymin-=1),this.ymax+=1),this.yInterval=(this.ymax-this.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.ymin),this.options.gridTextSize).width,this.measureText(this.yLabelFormat(this.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.ymax-this.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.colorForSeries(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.colorForSeries(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.prototype.colorForSeries=function(e){return this.options.lineColors[e%this.options.lineColors.length]},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.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"]}).call(this); \ No newline at end of file