@ninjamsp/ninja-morris
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -1,1 +0,1 @@ | ||
var Morris=function(){"use strict";return $(document).ready(function(){if($("#sales-graph").length&&Morris.Area({element:"sales-graph",data:[{period:"2010 Q1",iphone:2666,ipad:null,itouch:2647},{period:"2010 Q2",iphone:2778,ipad:2294,itouch:2441},{period:"2010 Q3",iphone:4912,ipad:1969,itouch:2501},{period:"2010 Q4",iphone:3767,ipad:3597,itouch:5689},{period:"2011 Q1",iphone:6810,ipad:1914,itouch:2293},{period:"2011 Q2",iphone:5670,ipad:4293,itouch:1881},{period:"2011 Q3",iphone:4820,ipad:3795,itouch:1588},{period:"2011 Q4",iphone:15073,ipad:5967,itouch:5175},{period:"2012 Q1",iphone:10687,ipad:4460,itouch:2028},{period:"2012 Q2",iphone:8432,ipad:5713,itouch:1791}],xkey:"period",ykeys:["iphone","ipad","itouch"],labels:["iPhone","iPad","iPod Touch"],pointSize:2,hideHover:"auto"}),$("#area-graph").length&&Morris.Area({element:"area-graph",data:[{x:"2011 Q1",y:3,z:3},{x:"2011 Q2",y:2,z:0},{x:"2011 Q3",y:0,z:2},{x:"2011 Q4",y:4,z:4}],xkey:"x",ykeys:["y","z"],labels:["Y","Z"]}),$("#bar-graph").length&&Morris.Bar({element:"bar-graph",data:[{x:"2011 Q1",y:0},{x:"2011 Q2",y:1},{x:"2011 Q3",y:2},{x:"2011 Q4",y:3},{x:"2012 Q1",y:4},{x:"2012 Q2",y:5},{x:"2012 Q3",y:6},{x:"2012 Q4",y:7},{x:"2013 Q1",y:8}],xkey:"x",ykeys:["y"],labels:["Y"],barColors:function(e,r,d){return"bar"===d?"rgb("+Math.ceil(255*e.y/this.ymax)+",0,0)":"#000"}}),$("#normal-bar-graph").length&&Morris.Bar({element:"normal-bar-graph",data:[{x:"2011 Q1",y:3,z:2,a:3},{x:"2011 Q2",y:2,z:null,a:1},{x:"2011 Q3",y:0,z:2,a:4},{x:"2011 Q4",y:2,z:4,a:3}],xkey:"x",ykeys:["y","z","a"],labels:["Y","Z","A"]}),$("#noline-bar-graph").length&&Morris.Bar({element:"noline-bar-graph",axes:!1,data:[{x:"2011 Q1",y:3,z:2,a:3},{x:"2011 Q2",y:2,z:null,a:1},{x:"2011 Q3",y:0,z:2,a:4},{x:"2011 Q4",y:2,z:4,a:3}],xkey:"x",ykeys:["y","z","a"],labels:["Y","Z","A"]}),$("#year-graph").length){n=[{period:"2012-10-01",licensed:3407,sorned:660},{period:"2012-09-30",licensed:3351,sorned:629},{period:"2012-09-29",licensed:3269,sorned:618},{period:"2012-09-20",licensed:3246,sorned:661},{period:"2012-09-19",licensed:3257,sorned:667},{period:"2012-09-18",licensed:3248,sorned:627},{period:"2012-09-17",licensed:3171,sorned:660},{period:"2012-09-16",licensed:3171,sorned:676},{period:"2012-09-15",licensed:3201,sorned:656},{period:"2012-09-10",licensed:3215,sorned:622}];Morris.Line({element:"year-graph",data:n,xkey:"period",ykeys:["licensed","sorned"],labels:["Licensed","SORN"]})}if($("#decimal-graph").length){for(var e=[],r=0;r<=360;r+=10)e.push({x:r,y:Math.sin(Math.PI*r/180).toFixed(4)});window.m=Morris.Line({element:"decimal-graph",data:e,xkey:"x",ykeys:["y"],labels:["sin(x)"],parseTime:!1,hoverCallback:function(e,r){var d=r.data[e];return"sin("+d.x+") = "+d.y},xLabelMargin:10})}if($("#donut-graph").length&&Morris.Donut({element:"donut-graph",data:[{value:70,label:"foo"},{value:15,label:"bar"},{value:10,label:"baz"},{value:5,label:"A really really long label"}],formatter:function(e){return e+"%"}}),$("#time-graph").length){var d=[{period:"2011 W27",licensed:3407,sorned:660},{period:"2011 W26",licensed:3351,sorned:629},{period:"2011 W25",licensed:3269,sorned:618},{period:"2011 W24",licensed:3246,sorned:661},{period:"2011 W23",licensed:3257,sorned:667},{period:"2011 W22",licensed:3248,sorned:627},{period:"2011 W21",licensed:3171,sorned:660},{period:"2011 W20",licensed:3171,sorned:676},{period:"2011 W19",licensed:3201,sorned:656},{period:"2011 W18",licensed:3215,sorned:622},{period:"2011 W17",licensed:3148,sorned:632},{period:"2011 W16",licensed:3155,sorned:681},{period:"2011 W15",licensed:3190,sorned:667},{period:"2011 W14",licensed:3226,sorned:620},{period:"2011 W13",licensed:3245,sorned:null},{period:"2011 W12",licensed:3289,sorned:null},{period:"2011 W11",licensed:3263,sorned:null},{period:"2011 W10",licensed:3189,sorned:null},{period:"2011 W09",licensed:3079,sorned:null},{period:"2011 W08",licensed:3085,sorned:null},{period:"2011 W07",licensed:3055,sorned:null},{period:"2011 W06",licensed:3063,sorned:null},{period:"2011 W05",licensed:2943,sorned:null},{period:"2011 W04",licensed:2806,sorned:null},{period:"2011 W03",licensed:2674,sorned:null},{period:"2011 W02",licensed:1702,sorned:null},{period:"2011 W01",licensed:1732,sorned:null}];Morris.Line({element:"time-graph",data:d,xkey:"period",ykeys:["licensed","sorned"],labels:["Licensed","SORN"],events:["2011-04","2011-08"]})}if($("#graph-B").length){var i=[{period:"2011-08-12",a:100},{period:"2011-03-03",a:75},{period:"2010-08-08",a:50},{period:"2010-05-10",a:25},{period:"2010-03-14",a:0},{period:"2010-01-10",a:-25},{period:"2009-12-10",a:-50},{period:"2009-10-07",a:-75},{period:"2009-09-25",a:-100}];Morris.Line({element:"graph-B",data:i,xkey:"period",ykeys:["a"],labels:["Series A"],units:"%"})}if($("#nogrid-graph").length){n=[{period:"2012-10-01",licensed:3407,sorned:660},{period:"2012-09-30",licensed:3351,sorned:629},{period:"2012-09-29",licensed:3269,sorned:618},{period:"2012-09-20",licensed:3246,sorned:661},{period:"2012-09-19",licensed:3257,sorned:667},{period:"2012-09-18",licensed:3248,sorned:627},{period:"2012-09-17",licensed:3171,sorned:660},{period:"2012-09-16",licensed:3171,sorned:676},{period:"2012-09-15",licensed:3201,sorned:656},{period:"2012-09-10",licensed:3215,sorned:622}];Morris.Line({element:"nogrid-graph",grid:!1,data:n,xkey:"period",ykeys:["licensed","sorned"],labels:["Licensed","SORN"]})}if($("#non-continu-graph").length){n=[{period:"2012-10-01",licensed:3407},{period:"2012-09-30",sorned:0},{period:"2012-09-29",sorned:618},{period:"2012-09-20",licensed:3246,sorned:661},{period:"2012-09-19",licensed:3257,sorned:null},{period:"2012-09-18",licensed:3248,other:1e3},{period:"2012-09-17",sorned:0},{period:"2012-09-16",sorned:0},{period:"2012-09-15",licensed:3201,sorned:656},{period:"2012-09-10",licensed:3215}];Morris.Line({element:"non-continu-graph",data:n,xkey:"period",ykeys:["licensed","sorned","other"],labels:["Licensed","SORN","Other"],xLabelFormat:function(e){return e.getMonth()+1+"/"+e.getDate()+"/"+e.getFullYear()},xLabels:"day"})}if($("#non-date-graph").length){var n=[{elapsed:"I",value:34},{elapsed:"II",value:24},{elapsed:"III",value:3},{elapsed:"IV",value:12},{elapsed:"V",value:13},{elapsed:"VI",value:22},{elapsed:"VII",value:5},{elapsed:"VIII",value:26},{elapsed:"IX",value:12},{elapsed:"X",value:19}];Morris.Line({element:"non-date-graph",data:n,xkey:"elapsed",ykeys:["value"],labels:["value"],parseTime:!1})}if($("#stacked-bar-graph").length&&Morris.Bar({element:"stacked-bar-graph",axes:!1,grid:!1,data:[{x:"2011 Q1",y:3,z:2,a:3},{x:"2011 Q2",y:2,z:null,a:1},{x:"2011 Q3",y:0,z:2,a:4},{x:"2011 Q4",y:2,z:4,a:3}],xkey:"x",ykeys:["y","z","a"],labels:["Y","Z","A"],stacked:!0}),$("#interval-graph").length){var o=0;function a(e){for(var r=[],d=0;d<=360;d+=10){var i=(e+d)%360;r.push({x:d,y:Math.sin(Math.PI*i/180).toFixed(4),z:Math.cos(Math.PI*i/180).toFixed(4)})}return r}var s=Morris.Line({element:"interval-graph",data:a(0),xkey:"x",ykeys:["y","z"],labels:["sin()","cos()"],parseTime:!1,ymin:-1,ymax:1,hideHover:!0});function l(){o++,s.setData(a(5*o)),$("#reloadStatus").text(o+" reloads")}setInterval(l,100)}}),Morris.Donut.prototype.setFormatter=function(e){this.options.formatter=e},Morris.Donut.prototype.setColors=function(e){this.options.colors=e},Morris}(); | ||
var Morris=function(){"use strict";return function(){var t,e,i,o,n=[].slice,s=function(t,e){return function(){return t.apply(e,arguments)}},r={}.hasOwnProperty,a=function(t,e){function i(){this.constructor=t}for(var o in e)r.call(e,o)&&(t[o]=e[o]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},h=[].indexOf||function(t){for(var e=0,i=this.length;i>e;e++)if(e in this&&this[e]===t)return e;return-1};e=window.Morris={},t=jQuery,e.EventEmitter=function(){function t(){}return t.prototype.on=function(t,e){return null==this.handlers&&(this.handlers={}),null==this.handlers[t]&&(this.handlers[t]=[]),this.handlers[t].push(e),this},t.prototype.fire=function(){var t,e,i,o,s,r,a;if(i=arguments[0],t=2<=arguments.length?n.call(arguments,1):[],null!=this.handlers&&null!=this.handlers[i]){for(a=[],o=0,s=(r=this.handlers[i]).length;s>o;o++)e=r[o],a.push(e.apply(null,t));return a}},t}(),e.commas=function(t){var e,i,o,n;return null!=t?(o=0>t?"-":"",e=Math.abs(t),i=Math.floor(e).toFixed(0),o+=i.replace(/(?=(?:\d{3})+$)(?!^)/g,","),(n=e.toString()).length>i.length&&(o+=n.slice(i.length)),o):"-"},e.pad2=function(t){return(10>t?"0":"")+t},e.Grid=function(i){function o(e){this.resizeHandler=s(this.resizeHandler,this);var i=this;if(this.el=t("string"==typeof e.element?document.getElementById(e.element):e.element),null==this.el||0===this.el.length)throw new Error("Graph container element not found");"static"===this.el.css("position")&&this.el.css("position","relative"),this.options=t.extend({},this.gridDefaults,this.defaults||{},e),"string"==typeof this.options.units&&(this.options.postUnits=e.units),this.raphael=new Raphael(this.el[0]),this.elementWidth=null,this.elementHeight=null,this.dirty=!1,this.selectFrom=null,this.init&&this.init(),this.setData(this.options.data),this.el.bind("mousemove",function(t){var e,o,n,s,r;return o=i.el.offset(),r=t.pageX-o.left,i.selectFrom?(e=i.data[i.hitTest(Math.min(r,i.selectFrom))]._x,n=i.data[i.hitTest(Math.max(r,i.selectFrom))]._x,s=n-e,i.selectionRect.attr({x:e,width:s})):i.fire("hovermove",r,t.pageY-o.top)}),this.el.bind("mouseleave",function(){return i.selectFrom&&(i.selectionRect.hide(),i.selectFrom=null),i.fire("hoverout")}),this.el.bind("touchstart touchmove touchend",function(t){var e,o;return o=t.originalEvent.touches[0]||t.originalEvent.changedTouches[0],e=i.el.offset(),i.fire("hovermove",o.pageX-e.left,o.pageY-e.top)}),this.el.bind("click",function(t){var e;return e=i.el.offset(),i.fire("gridclick",t.pageX-e.left,t.pageY-e.top)}),this.options.rangeSelect&&(this.selectionRect=this.raphael.rect(0,0,0,this.el.innerHeight()).attr({fill:this.options.rangeSelectColor,stroke:!1}).toBack().hide(),this.el.bind("mousedown",function(t){var e;return e=i.el.offset(),i.startRange(t.pageX-e.left)}),this.el.bind("mouseup",function(t){var e;return e=i.el.offset(),i.endRange(t.pageX-e.left),i.fire("hovermove",t.pageX-e.left,t.pageY-e.top)})),this.options.resize&&t(window).bind("resize",function(){return null!=i.timeoutId&&window.clearTimeout(i.timeoutId),i.timeoutId=window.setTimeout(i.resizeHandler,100)}),this.el.css("-webkit-tap-highlight-color","rgba(0,0,0,0)"),this.postInit&&this.postInit()}return a(o,i),o.prototype.gridDefaults={dateFormat:null,axes:!0,grid:!0,gridLineColor:"#aaa",gridStrokeWidth:.5,gridTextColor:"#888",gridTextSize:12,gridTextFamily:"sans-serif",gridTextWeight:"normal",hideHover:!1,yLabelFormat:null,xLabelAngle:0,numLines:5,padding:25,parseTime:!0,postUnits:"",preUnits:"",ymax:"auto",ymin:"auto 0",goals:[],goalStrokeWidth:1,goalLineColors:["#666633","#999966","#cc6666","#663333"],events:[],eventStrokeWidth:1,eventLineColors:["#005a04","#ccffbb","#3a5f0b","#005502"],rangeSelect:null,rangeSelectColor:"#eef",resize:!1},o.prototype.setData=function(t,i){var o,n,s,r,a,h,l,p,d,u,c,f,g,y,m;return null==i&&(i=!0),this.options.data=t,null==t||0===t.length?(this.data=[],this.raphael.clear(),void(null!=this.hover&&this.hover.hide())):(f=this.cumulative?0:null,g=this.cumulative?0:null,this.options.goals.length>0&&(a=Math.min.apply(Math,this.options.goals),r=Math.max.apply(Math,this.options.goals),g=null!=g?Math.min(g,a):a,f=null!=f?Math.max(f,r):r),this.data=function(){var i,o,r;for(r=[],s=i=0,o=t.length;o>i;s=++i)l=t[s],h={src:l},h.label=l[this.options.xkey],this.options.parseTime?(h.x=e.parseDate(h.label),this.options.dateFormat?h.label=this.options.dateFormat(h.x):"number"==typeof h.label&&(h.label=new Date(h.label).toString())):(h.x=s,this.options.xLabelFormat&&(h.label=this.options.xLabelFormat(h))),d=0,h.y=function(){var t,e,i,o;for(i=this.options.ykeys,o=[],n=t=0,e=i.length;e>t;n=++t)c=i[n],"string"==typeof(y=l[c])&&(y=parseFloat(y)),null!=y&&"number"!=typeof y&&(y=null),null!=y&&(this.cumulative?d+=y:null!=f?(f=Math.max(y,f),g=Math.min(y,g)):f=g=y),this.cumulative&&null!=d&&(f=Math.max(d,f),g=Math.min(d,g)),o.push(y);return o}.call(this),r.push(h);return r}.call(this),this.options.parseTime&&(this.data=this.data.sort(function(t,e){return(t.x>e.x)-(e.x>t.x)})),this.xmin=this.data[0].x,this.xmax=this.data[this.data.length-1].x,this.events=[],this.options.events.length>0&&(this.events=this.options.parseTime?function(){var t,i,n,s;for(s=[],t=0,i=(n=this.options.events).length;i>t;t++)o=n[t],s.push(e.parseDate(o));return s}.call(this):this.options.events,this.xmax=Math.max(this.xmax,Math.max.apply(Math,this.events)),this.xmin=Math.min(this.xmin,Math.min.apply(Math,this.events))),this.xmin===this.xmax&&(this.xmin-=1,this.xmax+=1),this.ymin=this.yboundary("min",g),this.ymax=this.yboundary("max",f),this.ymin===this.ymax&&(g&&(this.ymin-=1),this.ymax+=1),(!0===(m=this.options.axes)||"both"===m||"y"===m||!0===this.options.grid)&&(this.options.ymax===this.gridDefaults.ymax&&this.options.ymin===this.gridDefaults.ymin?(this.grid=this.autoGridLines(this.ymin,this.ymax,this.options.numLines),this.ymin=Math.min(this.ymin,this.grid[0]),this.ymax=Math.max(this.ymax,this.grid[this.grid.length-1])):(p=(this.ymax-this.ymin)/(this.options.numLines-1),this.grid=function(){var t,e,i;for(i=[],u=t=this.ymin,e=this.ymax;p>0?e>=t:t>=e;u=t+=p)i.push(u);return i}.call(this))),this.dirty=!0,i?this.redraw():void 0)},o.prototype.yboundary=function(t,e){var i,o;return i=this.options["y"+t],"string"==typeof i?"auto"===i.slice(0,4)?i.length>5?(o=parseInt(i.slice(5),10),null==e?o:Math[t](e,o)):null!=e?e:0:parseInt(i,10):i},o.prototype.autoGridLines=function(t,e,i){var o,n,s,r,a,h,l,p,d;return a=e-t,d=Math.floor(Math.log(a)/Math.log(10)),l=Math.pow(10,d),n=Math.floor(t/l)*l,o=Math.ceil(e/l)*l,h=(o-n)/(i-1),1===l&&h>1&&Math.ceil(h)!==h&&(h=Math.ceil(h),o=n+h*(i-1)),0>n&&o>0&&(n=Math.floor(t/h)*h,o=Math.ceil(e/h)*h),1>h?(r=Math.floor(Math.log(h)/Math.log(10)),s=function(){var t,e;for(e=[],p=t=n;h>0?o>=t:t>=o;p=t+=h)e.push(parseFloat(p.toFixed(1-r)));return e}()):s=function(){var t,e;for(e=[],p=t=n;h>0?o>=t:t>=o;p=t+=h)e.push(p);return e}(),s},o.prototype._calc=function(){var t,e,i,o,n,s,r,a;return n=this.el.width(),i=this.el.height(),(this.elementWidth!==n||this.elementHeight!==i||this.dirty)&&(this.elementWidth=n,this.elementHeight=i,this.dirty=!1,this.left=this.options.padding,this.right=this.elementWidth-this.options.padding,this.top=this.options.padding,this.bottom=this.elementHeight-this.options.padding,(!0===(r=this.options.axes)||"both"===r||"y"===r)&&(s=function(){var t,i,o,n;for(n=[],t=0,i=(o=this.grid).length;i>t;t++)e=o[t],n.push(this.measureText(this.yAxisFormat(e)).width);return n}.call(this),this.left+=Math.max.apply(Math,s)),(!0===(a=this.options.axes)||"both"===a||"x"===a)&&(t=function(){var t,e,i;for(i=[],o=t=0,e=this.data.length;e>=0?e>t:t>e;o=e>=0?++t:--t)i.push(this.measureText(this.data[o].text,-this.options.xLabelAngle).height);return i}.call(this),this.bottom-=Math.max.apply(Math,t)),this.width=Math.max(1,this.right-this.left),this.height=Math.max(1,this.bottom-this.top),this.dx=this.width/(this.xmax-this.xmin),this.dy=this.height/(this.ymax-this.ymin),this.calc)?this.calc():void 0},o.prototype.transY=function(t){return this.bottom-(t-this.ymin)*this.dy},o.prototype.transX=function(t){return 1===this.data.length?(this.left+this.right)/2:this.left+(t-this.xmin)*this.dx},o.prototype.redraw=function(){return this.raphael.clear(),this._calc(),this.drawGrid(),this.drawGoals(),this.drawEvents(),this.draw?this.draw():void 0},o.prototype.measureText=function(t,e){var i,o;return null==e&&(e=0),o=this.raphael.text(100,100,t).attr("font-size",this.options.gridTextSize).attr("font-family",this.options.gridTextFamily).attr("font-weight",this.options.gridTextWeight).rotate(e),i=o.getBBox(),o.remove(),i},o.prototype.yAxisFormat=function(t){return this.yLabelFormat(t)},o.prototype.yLabelFormat=function(t){return"function"==typeof this.options.yLabelFormat?this.options.yLabelFormat(t):""+this.options.preUnits+e.commas(t)+this.options.postUnits},o.prototype.drawGrid=function(){var t,e,i,o,n,s,r,a;if(!1!==this.options.grid||!0===(n=this.options.axes)||"both"===n||"y"===n){for(a=[],i=0,o=(s=this.grid).length;o>i;i++)t=s[i],e=this.transY(t),(!0===(r=this.options.axes)||"both"===r||"y"===r)&&this.drawYAxisLabel(this.left-this.options.padding/2,e,this.yAxisFormat(t)),this.options.grid?a.push(this.drawGridLine("M"+this.left+","+e+"H"+(this.left+this.width))):a.push(void 0);return a}},o.prototype.drawGoals=function(){var t,e,i,o,n,s,r;for(r=[],i=o=0,n=(s=this.options.goals).length;n>o;i=++o)e=s[i],t=this.options.goalLineColors[i%this.options.goalLineColors.length],r.push(this.drawGoal(e,t));return r},o.prototype.drawEvents=function(){var t,e,i,o,n,s,r;for(r=[],i=o=0,n=(s=this.events).length;n>o;i=++o)e=s[i],t=this.options.eventLineColors[i%this.options.eventLineColors.length],r.push(this.drawEvent(e,t));return r},o.prototype.drawGoal=function(t,e){return this.raphael.path("M"+this.left+","+this.transY(t)+"H"+this.right).attr("stroke",e).attr("stroke-width",this.options.goalStrokeWidth)},o.prototype.drawEvent=function(t,e){return this.raphael.path("M"+this.transX(t)+","+this.bottom+"V"+this.top).attr("stroke",e).attr("stroke-width",this.options.eventStrokeWidth)},o.prototype.drawYAxisLabel=function(t,e,i){return this.raphael.text(t,e,i).attr("font-size",this.options.gridTextSize).attr("font-family",this.options.gridTextFamily).attr("font-weight",this.options.gridTextWeight).attr("fill",this.options.gridTextColor).attr("text-anchor","end")},o.prototype.drawGridLine=function(t){return this.raphael.path(t).attr("stroke",this.options.gridLineColor).attr("stroke-width",this.options.gridStrokeWidth)},o.prototype.startRange=function(t){return this.hover.hide(),this.selectFrom=t,this.selectionRect.attr({x:t,width:0}).show()},o.prototype.endRange=function(t){var e,i;return this.selectFrom?(i=Math.min(this.selectFrom,t),e=Math.max(this.selectFrom,t),this.options.rangeSelect.call(this.el,{start:this.data[this.hitTest(i)].x,end:this.data[this.hitTest(e)].x}),this.selectFrom=null):void 0},o.prototype.resizeHandler=function(){return this.timeoutId=null,this.raphael.setSize(this.el.width(),this.el.height()),this.redraw()},o}(e.EventEmitter),e.parseDate=function(t){var e,i,o,n,s,r,a,h,l,p,d;return"number"==typeof t?t:(i=t.match(/^(\d+) Q(\d)$/),n=t.match(/^(\d+)-(\d+)$/),s=t.match(/^(\d+)-(\d+)-(\d+)$/),a=t.match(/^(\d+) W(\d+)$/),h=t.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+)(Z|([+-])(\d\d):?(\d\d))?$/),l=t.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+):(\d+(\.\d+)?)(Z|([+-])(\d\d):?(\d\d))?$/),i?new Date(parseInt(i[1],10),3*parseInt(i[2],10)-1,1).getTime():n?new Date(parseInt(n[1],10),parseInt(n[2],10)-1,1).getTime():s?new Date(parseInt(s[1],10),parseInt(s[2],10)-1,parseInt(s[3],10)).getTime():a?(4!==(p=new Date(parseInt(a[1],10),0,1)).getDay()&&p.setMonth(0,1+(4-p.getDay()+7)%7),p.getTime()+6048e5*parseInt(a[2],10)):h?h[6]?(r=0,"Z"!==h[6]&&(r=60*parseInt(h[8],10)+parseInt(h[9],10),"+"===h[7]&&(r=0-r)),Date.UTC(parseInt(h[1],10),parseInt(h[2],10)-1,parseInt(h[3],10),parseInt(h[4],10),parseInt(h[5],10)+r)):new Date(parseInt(h[1],10),parseInt(h[2],10)-1,parseInt(h[3],10),parseInt(h[4],10),parseInt(h[5],10)).getTime():l?(d=parseFloat(l[6]),e=Math.floor(d),o=Math.round(1e3*(d-e)),l[8]?(r=0,"Z"!==l[8]&&(r=60*parseInt(l[10],10)+parseInt(l[11],10),"+"===l[9]&&(r=0-r)),Date.UTC(parseInt(l[1],10),parseInt(l[2],10)-1,parseInt(l[3],10),parseInt(l[4],10),parseInt(l[5],10)+r,e,o)):new Date(parseInt(l[1],10),parseInt(l[2],10)-1,parseInt(l[3],10),parseInt(l[4],10),parseInt(l[5],10),e,o).getTime()):new Date(parseInt(t,10),0,1).getTime())},e.Hover=function(){function i(i){null==i&&(i={}),this.options=t.extend({},e.Hover.defaults,i),this.el=t("<div class='"+this.options.class+"'></div>"),this.el.hide(),this.options.parent.append(this.el)}return i.defaults={class:"morris-hover morris-default-style"},i.prototype.update=function(t,e,i){return t?(this.html(t),this.show(),this.moveTo(e,i)):this.hide()},i.prototype.html=function(t){return this.el.html(t)},i.prototype.moveTo=function(t,e){var i,o,n,s,r,a;return r=this.options.parent.innerWidth(),s=this.options.parent.innerHeight(),o=this.el.outerWidth(),i=this.el.outerHeight(),n=Math.min(Math.max(0,t-o/2),r-o),null!=e?0>(a=e-i-10)&&(a=e+10)+i>s&&(a=s/2-i/2):a=s/2-i/2,this.el.css({left:n+"px",top:parseInt(a)+"px"})},i.prototype.show=function(){return this.el.show()},i.prototype.hide=function(){return this.el.hide()},i}(),e.Line=function(t){function i(t){return this.hilight=s(this.hilight,this),this.onHoverOut=s(this.onHoverOut,this),this.onHoverMove=s(this.onHoverMove,this),this.onGridClick=s(this.onGridClick,this),this instanceof e.Line?void i.__super__.constructor.call(this,t):new e.Line(t)}return a(i,t),i.prototype.init=function(){return"always"!==this.options.hideHover?(this.hover=new e.Hover({parent:this.el}),this.on("hovermove",this.onHoverMove),this.on("hoverout",this.onHoverOut),this.on("gridclick",this.onGridClick)):void 0},i.prototype.defaults={lineWidth:3,pointSize:4,lineColors:["#0b62a4","#7A92A3","#4da74d","#afd8f8","#edc240","#cb4b4b","#9440ed"],pointStrokeWidths:[1],pointStrokeColors:["#ffffff"],pointFillColors:[],smooth:!0,xLabels:"auto",xLabelFormat:null,xLabelMargin:24,hideHover:!1},i.prototype.calc=function(){return this.calcPoints(),this.generatePaths()},i.prototype.calcPoints=function(){var t,e,i,o,n,s;for(s=[],i=0,o=(n=this.data).length;o>i;i++)t=n[i],t._x=this.transX(t.x),t._y=function(){var i,o,n,s;for(s=[],i=0,o=(n=t.y).length;o>i;i++)e=n[i],null!=e?s.push(this.transY(e)):s.push(e);return s}.call(this),s.push(t._ymax=Math.min.apply(Math,[this.bottom].concat(function(){var i,o,n,s;for(s=[],i=0,o=(n=t._y).length;o>i;i++)null!=(e=n[i])&&s.push(e);return s}())));return s},i.prototype.hitTest=function(t){var e,i,o,n,s;if(0===this.data.length)return null;for(e=o=0,n=(s=this.data.slice(1)).length;n>o&&(i=s[e],!(t<(i._x+this.data[e]._x)/2));e=++o);return e},i.prototype.onGridClick=function(t,e){var i;return i=this.hitTest(t),this.fire("click",i,this.data[i].src,t,e)},i.prototype.onHoverMove=function(t){var e;return e=this.hitTest(t),this.displayHoverForRow(e)},i.prototype.onHoverOut=function(){return!1!==this.options.hideHover?this.displayHoverForRow(null):void 0},i.prototype.displayHoverForRow=function(t){var e;return null!=t?((e=this.hover).update.apply(e,this.hoverContentForRow(t)),this.hilight(t)):(this.hover.hide(),this.hilight())},i.prototype.hoverContentForRow=function(t){var e,i,o,n,s,r,a;for(e="<div class='morris-hover-row-label'>"+(o=this.data[t]).label+"</div>",i=s=0,r=(a=o.y).length;r>s;i=++s)n=a[i],e+="<div class='morris-hover-point' style='color: "+this.colorFor(o,i,"label")+"'>\n "+this.options.labels[i]+":\n "+this.yLabelFormat(n)+"\n</div>";return"function"==typeof this.options.hoverCallback&&(e=this.options.hoverCallback(t,this.options,e,o.src)),[e,o._x,o._ymax]},i.prototype.generatePaths=function(){var t,i,o,n;return this.paths=function(){var s,r,a,l;for(l=[],i=s=0,r=this.options.ykeys.length;r>=0?r>s:s>r;i=r>=0?++s:--s)n="boolean"==typeof this.options.smooth?this.options.smooth:(a=this.options.ykeys[i],h.call(this.options.smooth,a)>=0),t=function(){var t,e,n,s;for(s=[],t=0,e=(n=this.data).length;e>t;t++)void 0!==(o=n[t])._y[i]&&s.push({x:o._x,y:o._y[i]});return s}.call(this),t.length>1?l.push(e.Line.createPath(t,n,this.bottom)):l.push(null);return l}.call(this)},i.prototype.draw=function(){var t;return(!0===(t=this.options.axes)||"both"===t||"x"===t)&&this.drawXAxis(),this.drawSeries(),!1===this.options.hideHover?this.displayHoverForRow(this.data.length-1):void 0},i.prototype.drawXAxis=function(){var t,i,o,n,s,r,a,h,l,p,d=this;for(a=this.bottom+this.options.padding/2,s=null,n=null,t=function(t,e){var i,o,r,h,l;return i=d.drawXAxisLabel(d.transX(e),a,t),l=i.getBBox(),i.transform("r"+-d.options.xLabelAngle),o=i.getBBox(),i.transform("t0,"+o.height/2+"..."),0!==d.options.xLabelAngle&&(h=-.5*l.width*Math.cos(d.options.xLabelAngle*Math.PI/180),i.transform("t"+h+",0...")),o=i.getBBox(),(null==s||s>=o.x+o.width||null!=n&&n>=o.x)&&o.x>=0&&o.x+o.width<d.el.width()?(0!==d.options.xLabelAngle&&(r=1.25*d.options.gridTextSize/Math.sin(d.options.xLabelAngle*Math.PI/180),n=o.x-r),s=o.x-d.options.xLabelMargin):i.remove()},(o=this.options.parseTime?1===this.data.length&&"auto"===this.options.xLabels?[[this.data[0].label,this.data[0].x]]:e.labelSeries(this.xmin,this.xmax,this.width,this.options.xLabels,this.options.xLabelFormat):function(){var t,e,i,o;for(o=[],t=0,e=(i=this.data).length;e>t;t++)r=i[t],o.push([r.label,r.x]);return o}.call(this)).reverse(),p=[],h=0,l=o.length;l>h;h++)i=o[h],p.push(t(i[0],i[1]));return p},i.prototype.drawSeries=function(){var t,e,i,o,n,s;for(this.seriesPoints=[],t=e=o=this.options.ykeys.length-1;0>=o?0>=e:e>=0;t=0>=o?++e:--e)this._drawLineFor(t);for(s=[],t=i=n=this.options.ykeys.length-1;0>=n?0>=i:i>=0;t=0>=n?++i:--i)s.push(this._drawPointFor(t));return s},i.prototype._drawPointFor=function(t){var e,i,o,n,s,r;for(this.seriesPoints[t]=[],r=[],o=0,n=(s=this.data).length;n>o;o++)i=s[o],e=null,null!=i._y[t]&&(e=this.drawLinePoint(i._x,i._y[t],this.colorFor(i,t,"point"),t)),r.push(this.seriesPoints[t].push(e));return r},i.prototype._drawLineFor=function(t){var e;return e=this.paths[t],null!==e?this.drawLinePath(e,this.colorFor(null,t,"line"),t):void 0},i.createPath=function(t,i,o){var n,s,r,a,h,l,p,d,u,c,f,g,y,m;for(p="",i&&(r=e.Line.gradients(t)),d={y:null},a=y=0,m=t.length;m>y;a=++y)null!=(n=t[a]).y&&(null!=d.y?i?(s=r[a],l=r[a-1],h=(n.x-d.x)/4,u=d.x+h,f=Math.min(o,d.y+h*l),c=n.x-h,g=Math.min(o,n.y-h*s),p+="C"+u+","+f+","+c+","+g+","+n.x+","+n.y):p+="L"+n.x+","+n.y:i&&null==r[a]||(p+="M"+n.x+","+n.y)),d=n;return p},i.gradients=function(t){var e,i,o,n,s,r,a,h;for(i=function(t,e){return(t.y-e.y)/(t.x-e.x)},h=[],o=r=0,a=t.length;a>r;o=++r)e=t[o],null!=e.y?(n=t[o+1]||{y:null},s=t[o-1]||{y:null},null!=s.y&&null!=n.y?h.push(i(s,n)):null!=s.y?h.push(i(s,e)):null!=n.y?h.push(i(e,n)):h.push(null)):h.push(null);return h},i.prototype.hilight=function(t){var e,i,o,n,s;if(null!==this.prevHilight&&this.prevHilight!==t)for(e=i=0,n=this.seriesPoints.length-1;n>=0?n>=i:i>=n;e=n>=0?++i:--i)this.seriesPoints[e][this.prevHilight]&&this.seriesPoints[e][this.prevHilight].animate(this.pointShrinkSeries(e));if(null!==t&&this.prevHilight!==t)for(e=o=0,s=this.seriesPoints.length-1;s>=0?s>=o:o>=s;e=s>=0?++o:--o)this.seriesPoints[e][t]&&this.seriesPoints[e][t].animate(this.pointGrowSeries(e));return this.prevHilight=t},i.prototype.colorFor=function(t,e,i){return"function"==typeof this.options.lineColors?this.options.lineColors.call(this,t,e,i):"point"===i?this.options.pointFillColors[e%this.options.pointFillColors.length]||this.options.lineColors[e%this.options.lineColors.length]:this.options.lineColors[e%this.options.lineColors.length]},i.prototype.drawXAxisLabel=function(t,e,i){return this.raphael.text(t,e,i).attr("font-size",this.options.gridTextSize).attr("font-family",this.options.gridTextFamily).attr("font-weight",this.options.gridTextWeight).attr("fill",this.options.gridTextColor)},i.prototype.drawLinePath=function(t,e,i){return this.raphael.path(t).attr("stroke",e).attr("stroke-width",this.lineWidthForSeries(i))},i.prototype.drawLinePoint=function(t,e,i,o){return this.raphael.circle(t,e,this.pointSizeForSeries(o)).attr("fill",i).attr("stroke-width",this.pointStrokeWidthForSeries(o)).attr("stroke",this.pointStrokeColorForSeries(o))},i.prototype.pointStrokeWidthForSeries=function(t){return this.options.pointStrokeWidths[t%this.options.pointStrokeWidths.length]},i.prototype.pointStrokeColorForSeries=function(t){return this.options.pointStrokeColors[t%this.options.pointStrokeColors.length]},i.prototype.lineWidthForSeries=function(t){return this.options.lineWidth instanceof Array?this.options.lineWidth[t%this.options.lineWidth.length]:this.options.lineWidth},i.prototype.pointSizeForSeries=function(t){return this.options.pointSize instanceof Array?this.options.pointSize[t%this.options.pointSize.length]:this.options.pointSize},i.prototype.pointGrowSeries=function(t){return Raphael.animation({r:this.pointSizeForSeries(t)+3},25,"linear")},i.prototype.pointShrinkSeries=function(t){return Raphael.animation({r:this.pointSizeForSeries(t)},25,"linear")},i}(e.Grid),e.labelSeries=function(i,o,n,s,r){var a,h,l,p,d,u,c,f,g,y,m;if(l=200*(o-i)/n,h=new Date(i),void 0===(c=e.LABEL_SPECS[s]))for(m=e.AUTO_LABEL_ORDER,g=0,y=m.length;y>g;g++)if(p=m[g],u=e.LABEL_SPECS[p],l>=u.span){c=u;break}for(void 0===c&&(c=e.LABEL_SPECS.second),r&&(c=t.extend({},c,{fmt:r})),a=c.start(h),d=[];(f=a.getTime())<=o;)f>=i&&d.push([c.fmt(a),f]),c.incr(a);return d},i=function(t){return{span:60*t*1e3,start:function(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours())},fmt:function(t){return e.pad2(t.getHours())+":"+e.pad2(t.getMinutes())},incr:function(e){return e.setUTCMinutes(e.getUTCMinutes()+t)}}},o=function(t){return{span:1e3*t,start:function(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes())},fmt:function(t){return e.pad2(t.getHours())+":"+e.pad2(t.getMinutes())+":"+e.pad2(t.getSeconds())},incr:function(e){return e.setUTCSeconds(e.getUTCSeconds()+t)}}},e.LABEL_SPECS={decade:{span:1728e8,start:function(t){return new Date(t.getFullYear()-t.getFullYear()%10,0,1)},fmt:function(t){return""+t.getFullYear()},incr:function(t){return t.setFullYear(t.getFullYear()+10)}},year:{span:1728e7,start:function(t){return new Date(t.getFullYear(),0,1)},fmt:function(t){return""+t.getFullYear()},incr:function(t){return t.setFullYear(t.getFullYear()+1)}},month:{span:24192e5,start:function(t){return new Date(t.getFullYear(),t.getMonth(),1)},fmt:function(t){return t.getFullYear()+"-"+e.pad2(t.getMonth()+1)},incr:function(t){return t.setMonth(t.getMonth()+1)}},week:{span:6048e5,start:function(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())},fmt:function(t){return t.getFullYear()+"-"+e.pad2(t.getMonth()+1)+"-"+e.pad2(t.getDate())},incr:function(t){return t.setDate(t.getDate()+7)}},day:{span:864e5,start:function(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())},fmt:function(t){return t.getFullYear()+"-"+e.pad2(t.getMonth()+1)+"-"+e.pad2(t.getDate())},incr:function(t){return t.setDate(t.getDate()+1)}},hour:i(60),"30min":i(30),"15min":i(15),"10min":i(10),"5min":i(5),minute:i(1),"30sec":o(30),"15sec":o(15),"10sec":o(10),"5sec":o(5),second:o(1)},e.AUTO_LABEL_ORDER=["decade","year","month","week","day","hour","30min","15min","10min","5min","minute","30sec","15sec","10sec","5sec","second"],e.Area=function(i){function o(i){var s;return this instanceof e.Area?(s=t.extend({},n,i),this.cumulative=!s.behaveLikeLine,"auto"===s.fillOpacity&&(s.fillOpacity=s.behaveLikeLine?.8:1),void o.__super__.constructor.call(this,s)):new e.Area(i)}var n;return a(o,i),n={fillOpacity:"auto",behaveLikeLine:!1},o.prototype.calcPoints=function(){var t,e,i,o,n,s,r;for(r=[],o=0,n=(s=this.data).length;n>o;o++)t=s[o],t._x=this.transX(t.x),e=0,t._y=function(){var o,n,s,r;for(r=[],o=0,n=(s=t.y).length;n>o;o++)i=s[o],this.options.behaveLikeLine?r.push(this.transY(i)):(e+=i||0,r.push(this.transY(e)));return r}.call(this),r.push(t._ymax=Math.max.apply(Math,t._y));return r},o.prototype.drawSeries=function(){var t,e,i,o,n,s,r,a;for(this.seriesPoints=[],a=[],i=0,o=(e=this.options.behaveLikeLine?function(){s=[];for(var t=0,e=this.options.ykeys.length-1;e>=0?e>=t:t>=e;e>=0?t++:t--)s.push(t);return s}.apply(this):function(){r=[];for(var t=n=this.options.ykeys.length-1;0>=n?0>=t:t>=0;0>=n?t++:t--)r.push(t);return r}.apply(this)).length;o>i;i++)t=e[i],this._drawFillFor(t),this._drawLineFor(t),a.push(this._drawPointFor(t));return a},o.prototype._drawFillFor=function(t){var e;return e=this.paths[t],null!==e?(e+="L"+this.transX(this.xmax)+","+this.bottom+"L"+this.transX(this.xmin)+","+this.bottom+"Z",this.drawFilledPath(e,this.fillForSeries(t))):void 0},o.prototype.fillForSeries=function(t){var e;return e=Raphael.rgb2hsl(this.colorFor(this.data[t],t,"line")),Raphael.hsl(e.h,this.options.behaveLikeLine?.9*e.s:.75*e.s,Math.min(.98,this.options.behaveLikeLine?1.2*e.l:1.25*e.l))},o.prototype.drawFilledPath=function(t,e){return this.raphael.path(t).attr("fill",e).attr("fill-opacity",this.options.fillOpacity).attr("stroke","none")},o}(e.Line),e.Bar=function(i){function o(i){return this.onHoverOut=s(this.onHoverOut,this),this.onHoverMove=s(this.onHoverMove,this),this.onGridClick=s(this.onGridClick,this),this instanceof e.Bar?void o.__super__.constructor.call(this,t.extend({},i,{parseTime:!1})):new e.Bar(i)}return a(o,i),o.prototype.init=function(){return this.cumulative=this.options.stacked,"always"!==this.options.hideHover?(this.hover=new e.Hover({parent:this.el}),this.on("hovermove",this.onHoverMove),this.on("hoverout",this.onHoverOut),this.on("gridclick",this.onGridClick)):void 0},o.prototype.defaults={barSizeRatio:.75,barGap:3,barColors:["#0b62a4","#7a92a3","#4da74d","#afd8f8","#edc240","#cb4b4b","#9440ed"],barOpacity:1,barRadius:[0,0,0,0],xLabelMargin:50},o.prototype.calc=function(){var t;return this.calcBars(),!1===this.options.hideHover?(t=this.hover).update.apply(t,this.hoverContentForRow(this.data.length-1)):void 0},o.prototype.calcBars=function(){var t,e,i,o,n,s,r;for(r=[],t=o=0,n=(s=this.data).length;n>o;t=++o)e=s[t],e._x=this.left+this.width*(t+.5)/this.data.length,r.push(e._y=function(){var t,o,n,s;for(s=[],t=0,o=(n=e.y).length;o>t;t++)i=n[t],null!=i?s.push(this.transY(i)):s.push(null);return s}.call(this));return r},o.prototype.draw=function(){var t;return(!0===(t=this.options.axes)||"both"===t||"x"===t)&&this.drawXAxis(),this.drawSeries()},o.prototype.drawXAxis=function(){var t,e,i,o,n,s,r,a,h,l,p,d,u;for(l=this.bottom+(this.options.xAxisLabelTopPadding||this.options.padding/2),r=null,s=null,u=[],t=p=0,d=this.data.length;d>=0?d>p:p>d;t=d>=0?++p:--p)a=this.data[this.data.length-1-t],e=this.drawXAxisLabel(a._x,l,a.label),h=e.getBBox(),e.transform("r"+-this.options.xLabelAngle),i=e.getBBox(),e.transform("t0,"+i.height/2+"..."),0!==this.options.xLabelAngle&&(n=-.5*h.width*Math.cos(this.options.xLabelAngle*Math.PI/180),e.transform("t"+n+",0...")),(null==r||r>=i.x+i.width||null!=s&&s>=i.x)&&i.x>=0&&i.x+i.width<this.el.width()?(0!==this.options.xLabelAngle&&(o=1.25*this.options.gridTextSize/Math.sin(this.options.xLabelAngle*Math.PI/180),s=i.x-o),u.push(r=i.x-this.options.xLabelMargin)):u.push(e.remove());return u},o.prototype.drawSeries=function(){var t,e,i,o,n,s,r,a,h,l,p,d,u,c,f;return i=this.width/this.options.data.length,a=this.options.stacked?1:this.options.ykeys.length,t=(i*this.options.barSizeRatio-this.options.barGap*(a-1))/a,this.options.barSize&&(t=Math.min(t,this.options.barSize)),d=i-t*a-this.options.barGap*(a-1),r=d/2,f=this.ymin<=0&&this.ymax>=0?this.transY(0):null,this.bars=function(){var a,d,g,y;for(g=this.data,y=[],o=a=0,d=g.length;d>a;o=++a)h=g[o],n=0,y.push(function(){var a,d,g,y;for(g=h._y,y=[],l=a=0,d=g.length;d>a;l=++a)c=g[l],null!==c?(f?(u=Math.min(c,f),e=Math.max(c,f)):(u=c,e=this.bottom),s=this.left+o*i+r,this.options.stacked||(s+=l*(t+this.options.barGap)),p=e-u,this.options.verticalGridCondition&&this.options.verticalGridCondition(h.x)&&this.drawBar(this.left+o*i,this.top,i,Math.abs(this.top-this.bottom),this.options.verticalGridColor,this.options.verticalGridOpacity,this.options.barRadius),this.options.stacked&&(u-=n),this.drawBar(s,u,t,p,this.colorFor(h,l,"bar"),this.options.barOpacity,this.options.barRadius),y.push(n+=p)):y.push(null);return y}.call(this));return y}.call(this)},o.prototype.colorFor=function(t,e,i){var o,n;return"function"==typeof this.options.barColors?(o={x:t.x,y:t.y[e],label:t.label},n={index:e,key:this.options.ykeys[e],label:this.options.labels[e]},this.options.barColors.call(this,o,n,i)):this.options.barColors[e%this.options.barColors.length]},o.prototype.hitTest=function(t){return 0===this.data.length?null:(t=Math.max(Math.min(t,this.right),this.left),Math.min(this.data.length-1,Math.floor((t-this.left)/(this.width/this.data.length))))},o.prototype.onGridClick=function(t,e){var i;return i=this.hitTest(t),this.fire("click",i,this.data[i].src,t,e)},o.prototype.onHoverMove=function(t){var e,i;return e=this.hitTest(t),(i=this.hover).update.apply(i,this.hoverContentForRow(e))},o.prototype.onHoverOut=function(){return!1!==this.options.hideHover?this.hover.hide():void 0},o.prototype.hoverContentForRow=function(t){var e,i,o,n,s,r,a,h;for(e="<div class='morris-hover-row-label'>"+(o=this.data[t]).label+"</div>",i=r=0,a=(h=o.y).length;a>r;i=++r)s=h[i],e+="<div class='morris-hover-point' style='color: "+this.colorFor(o,i,"label")+"'>\n "+this.options.labels[i]+":\n "+this.yLabelFormat(s)+"\n</div>";return"function"==typeof this.options.hoverCallback&&(e=this.options.hoverCallback(t,this.options,e,o.src)),n=this.left+(t+.5)*this.width/this.data.length,[e,n]},o.prototype.drawXAxisLabel=function(t,e,i){return this.raphael.text(t,e,i).attr("font-size",this.options.gridTextSize).attr("font-family",this.options.gridTextFamily).attr("font-weight",this.options.gridTextWeight).attr("fill",this.options.gridTextColor)},o.prototype.drawBar=function(t,e,i,o,n,s,r){var a;return a=Math.max.apply(Math,r),(0===a||a>o?this.raphael.rect(t,e,i,o):this.raphael.path(this.roundedRect(t,e,i,o,r))).attr("fill",n).attr("fill-opacity",s).attr("stroke","none")},o.prototype.roundedRect=function(t,e,i,o,n){return null==n&&(n=[0,0,0,0]),["M",t,n[0]+e,"Q",t,e,t+n[0],e,"L",t+i-n[1],e,"Q",t+i,e,t+i,e+n[1],"L",t+i,e+o-n[2],"Q",t+i,e+o,t+i-n[2],e+o,"L",t+n[3],e+o,"Q",t,e+o,t,e+o-n[3],"Z"]},o}(e.Grid),e.Donut=function(i){function o(i){this.resizeHandler=s(this.resizeHandler,this),this.select=s(this.select,this),this.click=s(this.click,this);var o=this;if(!(this instanceof e.Donut))return new e.Donut(i);if(this.options=t.extend({},this.defaults,i),this.el=t("string"==typeof i.element?document.getElementById(i.element):i.element),null===this.el||0===this.el.length)throw new Error("Graph placeholder not found.");void 0!==i.data&&0!==i.data.length&&(this.raphael=new Raphael(this.el[0]),this.options.resize&&t(window).bind("resize",function(){return null!=o.timeoutId&&window.clearTimeout(o.timeoutId),o.timeoutId=window.setTimeout(o.resizeHandler,100)}),this.setData(i.data))}return a(o,i),o.prototype.defaults={colors:["#0B62A4","#3980B5","#679DC6","#95BBD7","#B0CCE1","#095791","#095085","#083E67","#052C48","#042135"],backgroundColor:"#FFFFFF",labelColor:"#000000",formatter:e.commas,resize:!1},o.prototype.redraw=function(){var t,i,o,n,s,r,a,h,l,p,d,u,c,f,g,y,m,x,v,b,w,M,k;for(this.raphael.clear(),i=this.el.width()/2,o=this.el.height()/2,c=(Math.min(i,o)-10)/3,d=0,f=0,m=(b=this.values).length;m>f;f++)u=b[f],d+=u;for(h=5/(2*c),t=1.9999*Math.PI-h*this.data.length,r=0,s=0,this.segments=[],n=g=0,x=(w=this.values).length;x>g;n=++g)u=w[n],l=r+h+t*(u/d),(p=new e.DonutSegment(i,o,2*c,c,r,l,this.data[n].color||this.options.colors[s%this.options.colors.length],this.options.backgroundColor,s,this.raphael)).render(),this.segments.push(p),p.on("hover",this.select),p.on("click",this.click),r=l,s+=1;for(this.text1=this.drawEmptyDonutLabel(i,o-10,this.options.labelColor,15,800),this.text2=this.drawEmptyDonutLabel(i,o+10,this.options.labelColor,14),a=Math.max.apply(Math,this.values),s=0,k=[],y=0,v=(M=this.values).length;v>y;y++){if((u=M[y])===a){this.select(s);break}k.push(s+=1)}return k},o.prototype.setData=function(t){var e;return this.data=t,this.values=function(){var t,i,o,n;for(n=[],t=0,i=(o=this.data).length;i>t;t++)e=o[t],n.push(parseFloat(e.value));return n}.call(this),this.redraw()},o.prototype.click=function(t){return this.fire("click",t,this.data[t])},o.prototype.select=function(t){var e,i,o,n;for(i=0,o=(n=this.segments).length;o>i;i++)n[i].deselect();return this.segments[t].select(),e=this.data[t],this.setLabels(e.label,this.options.formatter(e.value,e))},o.prototype.setLabels=function(t,e){var i,o,n,s,r,a,h,l;return i=2*(Math.min(this.el.width()/2,this.el.height()/2)-10)/3,s=1.8*i,n=i/2,o=i/3,this.text1.attr({text:t,transform:""}),r=this.text1.getBBox(),a=Math.min(s/r.width,n/r.height),this.text1.attr({transform:"S"+a+","+a+","+(r.x+r.width/2)+","+(r.y+r.height)}),this.text2.attr({text:e,transform:""}),h=this.text2.getBBox(),l=Math.min(s/h.width,o/h.height),this.text2.attr({transform:"S"+l+","+l+","+(h.x+h.width/2)+","+h.y})},o.prototype.drawEmptyDonutLabel=function(t,e,i,o,n){var s;return s=this.raphael.text(t,e,"").attr("font-size",o).attr("fill",i),null!=n&&s.attr("font-weight",n),s},o.prototype.resizeHandler=function(){return this.timeoutId=null,this.raphael.setSize(this.el.width(),this.el.height()),this.redraw()},o}(e.EventEmitter),e.DonutSegment=function(t){function e(t,e,i,o,n,r,a,h,l,p){this.cx=t,this.cy=e,this.inner=i,this.outer=o,this.color=a,this.backgroundColor=h,this.index=l,this.raphael=p,this.deselect=s(this.deselect,this),this.select=s(this.select,this),this.sin_p0=Math.sin(n),this.cos_p0=Math.cos(n),this.sin_p1=Math.sin(r),this.cos_p1=Math.cos(r),this.is_long=r-n>Math.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 a(e,t),e.prototype.calcArcPoints=function(t){return[this.cx+t*this.sin_p0,this.cy+t*this.cos_p0,this.cx+t*this.sin_p1,this.cy+t*this.cos_p1]},e.prototype.calcSegment=function(t,e){var i,o,n,s,r,a,h,l,p,d;return p=this.calcArcPoints(t),i=p[0],n=p[1],o=p[2],s=p[3],d=this.calcArcPoints(e),r=d[0],h=d[1],a=d[2],l=d[3],"M"+i+","+n+"A"+t+","+t+",0,"+this.is_long+",0,"+o+","+s+"L"+a+","+l+"A"+e+","+e+",0,"+this.is_long+",1,"+r+","+h+"Z"},e.prototype.calcArc=function(t){var e,i,o,n,s;return s=this.calcArcPoints(t),e=s[0],o=s[1],i=s[2],n=s[3],"M"+e+","+o+"A"+t+","+t+",0,"+this.is_long+",0,"+i+","+n},e.prototype.render=function(){var t=this;return this.arc=this.drawDonutArc(this.hilight,this.color),this.seg=this.drawDonutSegment(this.path,this.color,this.backgroundColor,function(){return t.fire("hover",t.index)},function(){return t.fire("click",t.index)})},e.prototype.drawDonutArc=function(t,e){return this.raphael.path(t).attr({stroke:e,"stroke-width":2,opacity:0})},e.prototype.drawDonutSegment=function(t,e,i,o,n){return this.raphael.path(t).attr({fill:e,stroke:i,"stroke-width":3}).hover(o).click(n)},e.prototype.select=function(){return this.selected?void 0:(this.seg.animate({path:this.selectedPath},150,"<>"),this.arc.animate({opacity:1},150,"<>"),this.selected=!0)},e.prototype.deselect=function(){return this.selected?(this.seg.animate({path:this.path},150,"<>"),this.arc.animate({opacity:0},150,"<>"),this.selected=!1):void 0},e}(e.EventEmitter)}.call(void 0),$(document).ready(function(){if($("#sales-graph").length&&Morris.Area({element:"sales-graph",data:[{period:"2010 Q1",iphone:2666,ipad:null,itouch:2647},{period:"2010 Q2",iphone:2778,ipad:2294,itouch:2441},{period:"2010 Q3",iphone:4912,ipad:1969,itouch:2501},{period:"2010 Q4",iphone:3767,ipad:3597,itouch:5689},{period:"2011 Q1",iphone:6810,ipad:1914,itouch:2293},{period:"2011 Q2",iphone:5670,ipad:4293,itouch:1881},{period:"2011 Q3",iphone:4820,ipad:3795,itouch:1588},{period:"2011 Q4",iphone:15073,ipad:5967,itouch:5175},{period:"2012 Q1",iphone:10687,ipad:4460,itouch:2028},{period:"2012 Q2",iphone:8432,ipad:5713,itouch:1791}],xkey:"period",ykeys:["iphone","ipad","itouch"],labels:["iPhone","iPad","iPod Touch"],pointSize:2,hideHover:"auto"}),$("#area-graph").length&&Morris.Area({element:"area-graph",data:[{x:"2011 Q1",y:3,z:3},{x:"2011 Q2",y:2,z:0},{x:"2011 Q3",y:0,z:2},{x:"2011 Q4",y:4,z:4}],xkey:"x",ykeys:["y","z"],labels:["Y","Z"]}),$("#bar-graph").length&&Morris.Bar({element:"bar-graph",data:[{x:"2011 Q1",y:0},{x:"2011 Q2",y:1},{x:"2011 Q3",y:2},{x:"2011 Q4",y:3},{x:"2012 Q1",y:4},{x:"2012 Q2",y:5},{x:"2012 Q3",y:6},{x:"2012 Q4",y:7},{x:"2013 Q1",y:8}],xkey:"x",ykeys:["y"],labels:["Y"],barColors:function(t,e,i){return"bar"===i?"rgb("+Math.ceil(255*t.y/this.ymax)+",0,0)":"#000"}}),$("#normal-bar-graph").length&&Morris.Bar({element:"normal-bar-graph",data:[{x:"2011 Q1",y:3,z:2,a:3},{x:"2011 Q2",y:2,z:null,a:1},{x:"2011 Q3",y:0,z:2,a:4},{x:"2011 Q4",y:2,z:4,a:3}],xkey:"x",ykeys:["y","z","a"],labels:["Y","Z","A"]}),$("#noline-bar-graph").length&&Morris.Bar({element:"noline-bar-graph",axes:!1,data:[{x:"2011 Q1",y:3,z:2,a:3},{x:"2011 Q2",y:2,z:null,a:1},{x:"2011 Q3",y:0,z:2,a:4},{x:"2011 Q4",y:2,z:4,a:3}],xkey:"x",ykeys:["y","z","a"],labels:["Y","Z","A"]}),$("#year-graph").length){n=[{period:"2012-10-01",licensed:3407,sorned:660},{period:"2012-09-30",licensed:3351,sorned:629},{period:"2012-09-29",licensed:3269,sorned:618},{period:"2012-09-20",licensed:3246,sorned:661},{period:"2012-09-19",licensed:3257,sorned:667},{period:"2012-09-18",licensed:3248,sorned:627},{period:"2012-09-17",licensed:3171,sorned:660},{period:"2012-09-16",licensed:3171,sorned:676},{period:"2012-09-15",licensed:3201,sorned:656},{period:"2012-09-10",licensed:3215,sorned:622}];Morris.Line({element:"year-graph",data:n,xkey:"period",ykeys:["licensed","sorned"],labels:["Licensed","SORN"]})}if($("#decimal-graph").length){for(var t=[],e=0;e<=360;e+=10)t.push({x:e,y:Math.sin(Math.PI*e/180).toFixed(4)});window.m=Morris.Line({element:"decimal-graph",data:t,xkey:"x",ykeys:["y"],labels:["sin(x)"],parseTime:!1,hoverCallback:function(t,e){var i=e.data[t];return"sin("+i.x+") = "+i.y},xLabelMargin:10})}if($("#donut-graph").length&&Morris.Donut({element:"donut-graph",data:[{value:70,label:"foo"},{value:15,label:"bar"},{value:10,label:"baz"},{value:5,label:"A really really long label"}],formatter:function(t){return t+"%"}}),$("#time-graph").length){var i=[{period:"2011 W27",licensed:3407,sorned:660},{period:"2011 W26",licensed:3351,sorned:629},{period:"2011 W25",licensed:3269,sorned:618},{period:"2011 W24",licensed:3246,sorned:661},{period:"2011 W23",licensed:3257,sorned:667},{period:"2011 W22",licensed:3248,sorned:627},{period:"2011 W21",licensed:3171,sorned:660},{period:"2011 W20",licensed:3171,sorned:676},{period:"2011 W19",licensed:3201,sorned:656},{period:"2011 W18",licensed:3215,sorned:622},{period:"2011 W17",licensed:3148,sorned:632},{period:"2011 W16",licensed:3155,sorned:681},{period:"2011 W15",licensed:3190,sorned:667},{period:"2011 W14",licensed:3226,sorned:620},{period:"2011 W13",licensed:3245,sorned:null},{period:"2011 W12",licensed:3289,sorned:null},{period:"2011 W11",licensed:3263,sorned:null},{period:"2011 W10",licensed:3189,sorned:null},{period:"2011 W09",licensed:3079,sorned:null},{period:"2011 W08",licensed:3085,sorned:null},{period:"2011 W07",licensed:3055,sorned:null},{period:"2011 W06",licensed:3063,sorned:null},{period:"2011 W05",licensed:2943,sorned:null},{period:"2011 W04",licensed:2806,sorned:null},{period:"2011 W03",licensed:2674,sorned:null},{period:"2011 W02",licensed:1702,sorned:null},{period:"2011 W01",licensed:1732,sorned:null}];Morris.Line({element:"time-graph",data:i,xkey:"period",ykeys:["licensed","sorned"],labels:["Licensed","SORN"],events:["2011-04","2011-08"]})}if($("#graph-B").length){var o=[{period:"2011-08-12",a:100},{period:"2011-03-03",a:75},{period:"2010-08-08",a:50},{period:"2010-05-10",a:25},{period:"2010-03-14",a:0},{period:"2010-01-10",a:-25},{period:"2009-12-10",a:-50},{period:"2009-10-07",a:-75},{period:"2009-09-25",a:-100}];Morris.Line({element:"graph-B",data:o,xkey:"period",ykeys:["a"],labels:["Series A"],units:"%"})}if($("#nogrid-graph").length){n=[{period:"2012-10-01",licensed:3407,sorned:660},{period:"2012-09-30",licensed:3351,sorned:629},{period:"2012-09-29",licensed:3269,sorned:618},{period:"2012-09-20",licensed:3246,sorned:661},{period:"2012-09-19",licensed:3257,sorned:667},{period:"2012-09-18",licensed:3248,sorned:627},{period:"2012-09-17",licensed:3171,sorned:660},{period:"2012-09-16",licensed:3171,sorned:676},{period:"2012-09-15",licensed:3201,sorned:656},{period:"2012-09-10",licensed:3215,sorned:622}];Morris.Line({element:"nogrid-graph",grid:!1,data:n,xkey:"period",ykeys:["licensed","sorned"],labels:["Licensed","SORN"]})}if($("#non-continu-graph").length){n=[{period:"2012-10-01",licensed:3407},{period:"2012-09-30",sorned:0},{period:"2012-09-29",sorned:618},{period:"2012-09-20",licensed:3246,sorned:661},{period:"2012-09-19",licensed:3257,sorned:null},{period:"2012-09-18",licensed:3248,other:1e3},{period:"2012-09-17",sorned:0},{period:"2012-09-16",sorned:0},{period:"2012-09-15",licensed:3201,sorned:656},{period:"2012-09-10",licensed:3215}];Morris.Line({element:"non-continu-graph",data:n,xkey:"period",ykeys:["licensed","sorned","other"],labels:["Licensed","SORN","Other"],xLabelFormat:function(t){return t.getMonth()+1+"/"+t.getDate()+"/"+t.getFullYear()},xLabels:"day"})}if($("#non-date-graph").length){var n=[{elapsed:"I",value:34},{elapsed:"II",value:24},{elapsed:"III",value:3},{elapsed:"IV",value:12},{elapsed:"V",value:13},{elapsed:"VI",value:22},{elapsed:"VII",value:5},{elapsed:"VIII",value:26},{elapsed:"IX",value:12},{elapsed:"X",value:19}];Morris.Line({element:"non-date-graph",data:n,xkey:"elapsed",ykeys:["value"],labels:["value"],parseTime:!1})}if($("#stacked-bar-graph").length&&Morris.Bar({element:"stacked-bar-graph",axes:!1,grid:!1,data:[{x:"2011 Q1",y:3,z:2,a:3},{x:"2011 Q2",y:2,z:null,a:1},{x:"2011 Q3",y:0,z:2,a:4},{x:"2011 Q4",y:2,z:4,a:3}],xkey:"x",ykeys:["y","z","a"],labels:["Y","Z","A"],stacked:!0}),$("#interval-graph").length){var s=0;function r(t){for(var e=[],i=0;i<=360;i+=10){var o=(t+i)%360;e.push({x:i,y:Math.sin(Math.PI*o/180).toFixed(4),z:Math.cos(Math.PI*o/180).toFixed(4)})}return e}var a=Morris.Line({element:"interval-graph",data:r(0),xkey:"x",ykeys:["y","z"],labels:["sin()","cos()"],parseTime:!1,ymin:-1,ymax:1,hideHover:!0});function h(){s++,a.setData(r(5*s)),$("#reloadStatus").text(s+" reloads")}setInterval(h,100)}}),Morris.Donut.prototype.setFormatter=function(t){this.options.formatter=t},Morris.Donut.prototype.setColors=function(t){this.options.colors=t},Morris}(); |
{ | ||
"name": "@ninjamsp/ninja-morris", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"main": "bundle.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
43217
166