forked from square/cubism
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcubism.v1.min.js
1 lines (1 loc) · 21.7 KB
/
cubism.v1.min.js
1
(function(a){function d(a){return a}function e(){}function j(a){return Math.floor(a/1e3)}function k(a){var b=a.indexOf("|"),c=a.substring(0,b),d=c.lastIndexOf(","),e=c.lastIndexOf(",",d-1),f=c.lastIndexOf(",",e-1),g=c.substring(f+1,e)*1e3,h=c.substring(d+1)*1e3;return a.substring(b+1).split(",").slice(1).map(function(a){return+a})}function l(a){if(!(a instanceof e))throw new Error("invalid context");this.context=a}function o(a,b){return function(c,d,e,f){a(new Date(+c+b),new Date(+d+b),e,f)}}function p(a,b){l.call(this,a),b=+b;var c=b+"";this.valueOf=function(){return b},this.toString=function(){return c}}function r(a,b){function c(b,c){if(c instanceof l){if(b.context!==c.context)throw new Error("mismatch context")}else c=new p(b.context,c);l.call(this,b.context),this.left=b,this.right=c,this.toString=function(){return b+" "+a+" "+c}}var d=c.prototype=Object.create(l.prototype);return d.valueAt=function(a){return b(this.left.valueAt(a),this.right.valueAt(a))},d.shift=function(a){return new c(this.left.shift(a),this.right.shift(a))},d.on=function(a,b){return arguments.length<2?this.left.on(a):(this.left.on(a,b),this.right.on(a,b),this)},function(a){return new c(this,a)}}function u(a){return a&16777214}function v(a){return(a+1&16777214)-1}var b=a.cubism={version:"1.6.0"},c=0;b.option=function(a,c){var d=b.options(a);return d.length?d[0]:c},b.options=function(a,b){var c=location.search.substring(1).split("&"),d=[],e=-1,f=c.length,g;while(++e<f)(g=c[e].split("="))[0]==a&&d.push(decodeURIComponent(g[1]));return d.length||arguments.length<2?d:b},b.context=function(a){function x(){var a=Date.now();return i=k=new Date(Math.floor((a-l-m+g)/d)*d),h=j=new Date(i-(f/v|0)*d),o.domain([h,i]),b}var b=new e,d=a&&a.step?a.step:1e4,f=a&&a.size?a.size:1440,g=0,h,i,j,k,l=a&&a.serverDelay?a.serverDelay:5e3,m=a&&a.clientDelay?a.clientDelay:5e3,n=d3.dispatch("prepare","beforechange","change","focus"),o=b.scale=d3.time.scale().range([0,f]),p,q,r=null,s,t=a&&typeof a.drawAsync!="undefined"?a.drawAsync:!0,u=0,v=a&&a.pixelWidth?a.pixelWidth:1,w=!1;return b.start=function(){p&&clearTimeout(p),q&&clearTimeout(q);var a=+k+l-Date.now()-g;return a<=m&&(a=+k+d-Date.now()+l),p=setTimeout(function c(){k=new Date(Math.floor((Date.now()-l+g)/d)*d),j=new Date(k-(f/b.pixelWidth()|0)*d),n.prepare.call(b,j,k),q=setTimeout(function a(){if(!t){if(w)return;if(u){q=setTimeout(a,m);return}}o.domain([h=j,i=k]),n.beforechange.call(b,j,k),n.change.call(b,j,k),n.focus.call(b,s)},m),p=setTimeout(c,d)},a),b},b.stop=function(){return p=clearTimeout(p),q=clearTimeout(q),b},p=setTimeout(b.start,10),b.step=function(a){return arguments.length?(d=+a,x()):d},b.size=function(a){return arguments.length?(o.range([0,f=+a]),x()):f},b.shift=function(a){return arguments.length?(g=+a,x()):g},b.focusAnchor=function(a){return arguments.length?(r=a,b):r},b.serverDelay=function(a){return arguments.length?(l=+a,x()):l},b.clientDelay=function(a){return arguments.length?(m=+a,x()):m},b.drawAsync=function(a){return arguments.length?(t=a,b):t},b.requestCounter=function(a){return arguments.length?(u=+a,u=Math.max(0,u),b):u},b.isFetchFailing=function(a){return arguments.length?(w=a,b):w},b.pixelWidth=function(a){return arguments.length?(v=+a,b):v},b.focus=function(a){return a=a===null?r:a,n.focus.call(b,s=a),b},b.on=function(a,c){return arguments.length<2?n.on(a):(n.on(a,c),c!=null&&(/^prepare(\.|$)/.test(a)&&c.call(b,j,k),/^beforechange(\.|$)/.test(a)&&c.call(b,h,i),/^change(\.|$)/.test(a)&&c.call(b,h,i),/^focus(\.|$)/.test(a)&&c.call(b,s)),b)},d3.select(window).on("keydown.context-"+ ++c,function(){if(d3.event.target.nodeName.toLowerCase()=="input")return;switch(!d3.event.metaKey&&d3.event.keyCode){case 37:s==null&&(s=f-1),s>0&&b.focus(s-=v);break;case 39:s==null&&(s=f-2),s<f-1&&b.focus(s+=v);break;default:return}d3.event.preventDefault()}),x()};var f=b.context.prototype=e.prototype;f.constant=function(a){return new p(this,+a)},f.cube=function(a){arguments.length||(a="");var b={},c=this;return b.metric=function(b){return c.metric(function(c,d,e,f){d3.json(a+"/1.0/metric"+"?expression="+encodeURIComponent(b)+"&start="+g(c)+"&stop="+g(d)+"&step="+e,function(a){if(!a)return f(new Error("unable to load data"));f(null,a.map(function(a){return a.value}))})},b+="")},b.toString=function(){return a},b};var g=d3.time.format.iso;f.librato=function(a,c){function f(a){var b=avail_rsts[0],c=avail_rsts[avail_rsts.length];if(a>=c)return c;if(a<=b)return b;var d,e,f;for(f=a;f<=c;f++){d=avail_rsts.indexOf(f);if(d>-1){e=avail_rsts[d];break}}var g;for(f=a;f>=b;f--){d=avail_rsts.indexOf(f);if(d>-1){g=avail_rsts[d];break}}return e-a<a-g?e:g}function g(a,b,c){var d=b-a,e=2419200,g=604800,h=172800,i;return d>e?3600:(i=f(c),d>g&&i<900?900:d>h&&i<60?60:i)}var d={},e=this;auth_string="Basic "+btoa(a+":"+c),avail_rsts=[1,60,900,3600];var j=function(a){function d(b,d,e){var f="compose="+a+"&start_time="+b+"&end_time="+d+"&resolution="+g(b,d,e);return c+"?"+f}function e(a,b,c,d){var e=[];for(i=a;i<=b;i+=c){var f=[];while(d.length&&d[0].measure_time<=i)f.push(d.shift().value);var g;f.length?g=f.reduce(function(a,b){return a+b})/f.length:g=e.length?e[e.length-1]:0,e.push(g)}return e}var c="https://metrics-api.librato.com/v1/metrics";return request={},request.fire=function(a,c,f,g){function i(j){d3.json(j).header("X-Requested-With","XMLHttpRequest").header("Authorization",auth_string).header("Librato-User-Agent","cubism/"+b.version).get(function(b,j){if(!b){if(j.measurements.length===0)return;j.measurements[0].series.forEach(function(a){h.push(a)});var k="query"in j&&"next_time"in j.query;if(k)i(d(j.query.next_time,c,f));else{var l=e(a,c,f,h);g(l)}}})}var h=[];i(d(a,c,f))},request};return d.metric=function(a){return e.metric(function(b,c,d,e){j(a).fire(h(b),h(c),h(d),function(a){e(null,a)})},a+="")},d.toString=function(){return"librato"},d};var h=function(a){return Math.floor(a/1e3)};f.graphite=function(a){arguments.length||(a="");var b={},c=this;return b.metric=function(b){var d="sum",e=c.metric(function(c,e,f,g){var h=b;f!==1e4&&(h="summarize("+h+",'"+(f%36e5?f%6e4?f/1e3+"sec":f/6e4+"min":f/36e5+"hour")+"','"+d+"')"),d3.text(a+"/render?format=raw"+"&target="+encodeURIComponent("alias("+h+",'')")+"&from="+j(c-2*f)+"&until="+j(e-1e3),function(a){if(!a)return g(new Error("unable to load data"));g(null,k(a))})},b+="");return e.summarize=function(a){return d=a,e},e},b.find=function(b,c){d3.json(a+"/metrics/find?format=completer"+"&query="+encodeURIComponent(b),function(a){if(!a)return c(new Error("unable to find metrics"));c(null,a.metrics.map(function(a){return a.path}))})},b.toString=function(){return a},b},f.gangliaWeb=function(a){var b="",c="/ganglia2/";arguments.length&&(a.host&&(b=a.host),a.uriPathPrefix&&(c=a.uriPathPrefix,c[0]!="/"&&(c="/"+c),c[c.length-1]!="/"&&(c+="/")));var d={},e=this;return d.metric=function(a){var d=a.clusterName,f=a.metricName,g=a.hostName,h=a.isReport||!1,i=a.titleGenerator||function(a){return"clusterName:"+d+" metricName:"+f+(g?" hostName:"+g:"")},j=a.onChangeCallback,k=h?"g":"m",l=e.metric(function(a,e,h,i){function j(){return"c="+d+"&"+k+"="+f+(g?"&h="+g:"")+"&cs="+a/1e3+"&ce="+e/1e3+"&step="+h/1e3+"&graphlot=1"}d3.json(b+c+"graph.php?"+j(),function(a){if(!a)return i(new Error("Unable to fetch GangliaWeb data"));i(null,a[0].data)})},i(a));return l.toString=function(){return i(a)},j&&l.on("change",j),l},d.toString=function(){return b+c},d},f.linechart=function(){function g(g){g.on("mousemove.linechart",function(){a.focus(Math.round(d3.mouse(this)[0]))}).on("mouseout.linechart",function(){a.focus(null)}),g.append("svg").attr("width",b).attr("height",e),g.each(function(g,h){function o(){if(j.length==0)return;var c=[],d=0,g=0,h=Infinity;for(var i in j){var k=[],o=0;while(o<a.size()){var p=[];for(var q=0;q<step&&o<a.size();++q,++o)p.push(j[i].valueAt(o));var r=f(p);isFinite(r)?k.push(r):k.push(0)}c.push(k),d=k.length;var s,t,u;s=d3.max(k),t=d3.min(k);if(s==t)u=Math.min(10,s*.2),max=s+u,min=s-u;else{u=Math.pow(10,Math.floor(Math.log(s<1?1:s)/Math.LN10));while(u>(s-t)/2)u/=10;min=Math.floor(t/u)*u,max=(1+Math.floor(s/u))*u}auto_min&&(h=Math.min(h,min)),auto_max&&(g=Math.max(g,max))}if(!isFinite(g))return;isFinite(h)||(h=0);var v=d3.scale.linear().domain([0,d]).range([0,b]),w=scale.domain([g,h]).range([0,e]);l.x(function(a,b){return v(b)}).y(function(a){return w(a)}),m.selectAll("path").remove(),m.selectAll("g").remove(),m.append("g").attr("class","left axis").attr("transform","translate("+axis_width+", 0)").call(d3.svg.axis().scale(w).tickValues(tick_position.map(function(a){return a*g+(1-a)*h})).orient("left").tickFormat(tickFormat));var x=Math.floor(axis_width*d/b);for(var y in c)m.append("path").attr("d",l(c[y].slice(x))).attr("transform","translate("+axis_width+", 0)").attr("width",b-axis_width).attr("stroke",colors[y]).attr("stroke-width",stroke_width).attr("fill","none");m.append("g").attr("class","toolpit"),m.select(".toolpit").append("rect").attr("class","toolpit-rect").attr("x",5).attr("rx",5).attr("ry",5).attr("stroke","grey").attr("stroke-width",2).attr("fill","rgb(255,255,255)").attr("fill-opacity",.8),m.select(".toolpit").append("text").attr("class","toolpit-text").attr("font-family","courier").attr("font-size",12),n+=1}function p(c){c==null&&(c=b-1);if(metrics.length==0)return;m.select(".toolpit-text").selectAll("tspan").remove();for(var d in j){var f=b/a.size();if(f>1)var g=Math.floor(c/f),h=g+1,i=c/f-g,k=(1-i)*j[d].valueAt(g)+i*j[d].valueAt(h);else var k=j[d].valueAt(c);m.select(".toolpit-text").append("tspan").attr("x",10).attr("y",15+15*d).attr("style","font-weight:bold").text(j[d].toString()+": "),m.select(".toolpit-text").append("tspan").attr("y",15+15*d).attr("style","stroke:"+colors[d]).text(isNaN(k)?"n/a":format(k))}var l=10,n=10;m.select(".toolpit-text").each(function(){l=Math.max(l,this.getBBox().width+10),n=Math.max(n,this.getBBox().height+10)});var o=c<b-l-10?c:c-l-10,p=.9*e-n;m.select(".toolpit").attr("transform","translate("+o+", "+p+")"),m.select(".toolpit-rect").attr("width",l),m.select(".toolpit-rect").attr("height",n)}var i=this,j=typeof metrics=="function"?metrics.call(i,g,h):metrics,k=++c,l=d3.svg.line().interpolate("basis"),m=d3.select(i).select("svg"),n=0;a.on("change.linechart-"+k,o),a.on("focus.linechart-"+k,p);for(var q in j)j[q].on("change.linechart-"+k,function(a,b){o(),p(),n==j.length&&j[q].on("change.linechart-"+k,d)})})}var a=this,b=a.size(),e=30,f=function(a){return a.length>0?a[0]:0};return scale=d3.scale.linear().interpolate(d3.interpolateRound),metrics=d,title=d,format=d3.format("f"),tickFormat=function(a){if(a>0)return a},colors=["#08519c","#74c476","#6baed6","#006d2c","#3182bd","#bae4b3","#bdd7e7","#31a354"],step=1,stroke_width=1,axis_width=0,tick_position=[.4,.8],auto_min=!1,auto_max=!0,g.remove=function(b){function c(b){b.metrics[0].on("change.linechart-"+b.id,null),a.on("change.linechart-"+b.id,null),a.on("focus.linechart-"+b.id,null)}b.on("mousemove.linechart",null).on("mouseout.linechart",null),b.selectAll("svg").each(c).remove(),b.selectAll(".toolpit").remove()},g.height=function(a){return arguments.length?(e=+a,g):e},g.width=function(a){return arguments.length?(b=+a,g):b},g.summarize=function(a){return arguments.length?(f=a,g):f},g.metrics=function(a){return arguments.length?(metrics=a,g):metrics},g.scale=function(a){return arguments.length?(scale=a,g):scale},g.title=function(a){return arguments.length?(title=a,g):title},g.format=function(a){return arguments.length?(format=a,g):format},g.tickFormat=function(a){return arguments.length?(tickFormat=a,g):tickFormat},g.colors=function(a){return arguments.length?(colors=a,g):colors},g.step=function(a){return arguments.length?(+a>0&&(step=+a),g):step},g.stroke_width=function(a){return arguments.length?(stroke_width=a,g):stroke_width},g.axis_width=function(a){return arguments.length?(axis_width=+a,g):axis_width},g.tick_position=function(a){return arguments.length?(tick_position=a,g):tick_position},g.auto_min=function(a){return arguments.length?(auto_min=a,g):auto_min},g};var m=l.prototype;b.metric=l,m.valueAt=function(){return NaN},m.alias=function(a){return this.toString=function(){return a},this},m.extent=function(){var a=0,b=this.context.size(),c,d=Infinity,e=-Infinity;while(++a<b)c=this.valueAt(a),c<d&&(d=c),c>e&&(e=c);return[d,e]},m.on=function(a,b){return arguments.length<2?null:this},m.shift=function(){return this},m.on=function(){return arguments.length<2?null:this},f.metric=function(a,b){function r(b,c){var f=g,h=Math.min(j,Math.round((b-g)/i));if(!h||q)return;q=!0,h=Math.min(j,h+n);var l=new Date(c-h*i);d.requestCounter(1),a(l,c,i,function(a,b){d.requestCounter(-1),q=!1;if(a)return d.isFetchFailing(!0),g=isFinite(f)?g:f,console.warn(a);d.isFetchFailing(!1);var h=isFinite(g)?Math.round((l-g)/i):0;for(var j=0,n=b.length;j<n;++j)k[j+h]=b[j];m.change.call(e,g,c)})}function s(a,b){isFinite(g)||(g=a),k.splice(0,Math.max(0,Math.min(j,Math.round((a-g)/i)))),g=a,h=b}var d=this,e=new l(d),f=".metric-"+ ++c,g=-Infinity,h,i=d.step(),j=parseInt(d.size()/d.pixelWidth()),k=[],m=d3.dispatch("change"),p=0,q;return e.valueAt=function(a){return k[a]},e.shift=function(b){return d.metric(o(a,+b))},e.on=function(a,b){return arguments.length?(b==null?m.on(a)!=null&&--p==0&&d.on("prepare"+f,null).on("beforechange"+f,null):m.on(a)==null&&++p==1&&d.on("prepare"+f,r).on("beforechange"+f,s),m.on(a,b),b!=null&&/^change(\.|$)/.test(a)&&b.call(d,g,h),e):m.on(a)},arguments.length>1&&(e.toString=function(){return b}),e};var n=6,q=p.prototype=Object.create(l.prototype);q.valueAt=function(){return+this},q.extent=function(){return[+this,+this]},m.add=r("+",function(a,b){return a+b}),m.subtract=r("-",function(a,b){return a-b}),m.multiply=r("*",function(a,b){return a*b}),m.divide=r("/",function(a,b){return a/b}),f.horizon=function(){function s(b){p=b,b.on("mousemove.horizon",function(){a.focus(Math.round(d3.mouse(this)[0]))}).on("mouseout.horizon",function(){a.focus(null)}),b.append("canvas").attr("width",f).attr("height",g),b.append("span").attr("class","title").text(k),b.append("span").attr("class","value"),b.each(function(b,k){function D(c,d){y.save();var i=t.extent(),j=a.pixelWidth();C=i.every(isFinite);var k=null;v!=null&&(k=typeof v=="function"?v.call(p,b,H):v),k!=null&&(i=k);var l=0,m=Math.max(-i[0],i[1]);if(this===a){if(m==A){var o=parseInt((c-w)/x*j);l=f-Math.max(o,n*j);if(o<f){var q=e.getContext("2d");q.clearRect(0,0,f,g),q.drawImage(y.canvas,o,0,f-o,g,0,0,f-o,g),y.clearRect(0,0,f,g),y.drawImage(q.canvas,0,0)}}w=c}h.domain([0,A=m]),y.clearRect(l,0,f-l,g);var s=!1,z,D,E=r[j+""]||r[1];E&&(E=y.createPattern(E,"repeat"));for(var F=0;F<B;++F){y.fillStyle=u[B+F];var G=(F-B+1)*g;h.range([B*g+G,G]),G=h(0);for(var H=parseInt(l/j),I=f/j|0,J,K=t.valueAt(H-1),L;H<I;++H,K=L){L=J=t.valueAt(H);if(isNaN(J)){E&&(y.fillStyle=E,y.fillRect(H*j,0,j,g));continue}if(j>1){K=(isNaN(K)?L:K)||0,z=((L||0)-K)/j;for(var M=1;M<=j;++M)D=K+z*M,D<0?(s||(y.translate(0,g),y.scale(1,-1),s=!0),y.fillStyle=u[B-1-F],D=h(-D)):(s&&(y.translate(0,g),y.scale(1,-1),s=!1),y.fillStyle=u[B+F],D=h(D)),y.fillRect(H*j+M-1,D,1,G-D)}else J<0?(s||(y.translate(0,g),y.scale(1,-1),s=!0),y.fillStyle=u[B-1-F],J=h(-J)):(s&&(y.translate(0,-1*g),y.scale(1,1),s=!1),y.fillStyle=u[B+F],J=h(J)),y.fillRect(H*j,J,j,G-J)}}y.restore()}function E(b){b==null&&(b=f-1);var c=t.valueAt(b/a.pixelWidth()|0);z.datum(c).text(isNaN(c)?m:l)}var p=this,s=++c,t=typeof i=="function"?i.call(p,b,k):i,u=typeof q=="function"?q.call(p,b,k):q,v=j,w=-Infinity,x=a.step(),y=d3.select(p).select("canvas"),z=d3.select(p).select(".value"),A,B=u.length>>1,C;y.datum({id:s,metric:t}),y=y.node().getContext("2d"),a.on("change.horizon-"+s,D),a.on("focus.horizon-"+s,E),t.on("change.horizon-"+s,function(a,b){D(a,b),E(),C&&t.on("change.horizon-"+s,d)}),o=D})}var a=this,b="offset",e=document.createElement("canvas"),f=e.width=a.size(),g=e.height=30,h=d3.scale.linear().interpolate(d3.interpolateRound),i=d,j=null,k=d,l=d3.format(".2s"),m=null,o=null,p=null,q=["#08519c","#3182bd","#6baed6","#bdd7e7","#bae4b3","#74c476","#31a354","#006d2c"],r={};return s.remove=function(b){function c(b){b.metric.on("change.horizon-"+b.id,null),a.on("change.horizon-"+b.id,null),a.on("focus.horizon-"+b.id,null)}b.on("mousemove.horizon",null).on("mouseout.horizon",null),b.selectAll("canvas").each(c).remove(),b.selectAll(".title,.value").remove()},s.redraw=function(){o&&o.call(null)},s.mode=function(a){return arguments.length?(b=a+"",s):b},s.height=function(a){return arguments.length?(e.height=g=+a,s):g},s.metric=function(a){return arguments.length?(i=a,s):i},s.scale=function(a){return arguments.length?(h=a,s):h},s.extent=function(a){return arguments.length?(j=a,s):j},s.title=function(a){return arguments.length?(k=a,s):k},s.format=function(a){return arguments.length?(l=a,s):l},s.formatNaN=function(a){return arguments.length?(m=a,s):m},s.colors=function(a){return arguments.length?(q=a,s):q},s.resize=function(a){return arguments.length?(f=e.width=a,p.select("canvas").attr("width",f),s.redraw(),f):f},s.patterns=function(a){return arguments.length?(r=a,s):r},s},f.comparison=function(){function o(o){o.on("mousemove.comparison",function(){a.focus(Math.round(d3.mouse(this)[0]))}).on("mouseout.comparison",function(){a.focus(null)}),o.append("canvas").attr("width",b).attr("height",e),o.append("span").attr("class","title").text(j),o.append("span").attr("class","value primary"),o.append("span").attr("class","value change"),o.each(function(j,o){function B(c,d){x.save(),x.clearRect(0,0,b,e);var g=r.extent(),h=s.extent(),i=t==null?g:t;f.domain(i).range([e,0]),A=g.concat(h).every(isFinite);var j=c/a.step()&1?v:u;x.fillStyle=m[2];for(var k=0,l=b;k<l;++k){var o=f(r.valueAt(k)),p=f(s.valueAt(k));o<p&&x.fillRect(j(k),o,1,p-o)}x.fillStyle=m[0];for(k=0;k<l;++k){var o=f(r.valueAt(k)),p=f(s.valueAt(k));o>p&&x.fillRect(j(k),p,1,o-p)}x.fillStyle=m[3];for(k=0;k<l;++k){var o=f(r.valueAt(k)),p=f(s.valueAt(k));o<=p&&x.fillRect(j(k),o,1,n)}x.fillStyle=m[1];for(k=0;k<l;++k){var o=f(r.valueAt(k)),p=f(s.valueAt(k));o>p&&x.fillRect(j(k),o-n,1,n)}x.restore()}function C(a){a==null&&(a=b-1);var c=r.valueAt(a),d=s.valueAt(a),e=(c-d)/d;y.datum(c).text(isNaN(c)?null:k),z.datum(e).text(isNaN(e)?null:l).attr("class","value change "+(e>0?"positive":e<0?"negative":""))}function D(a,b){B(a,b),C(),A&&(r.on("change.comparison-"+q,d),s.on("change.comparison-"+q,d))}var p=this,q=++c,r=typeof g=="function"?g.call(p,j,o):g,s=typeof h=="function"?h.call(p,j,o):h,t=typeof i=="function"?i.call(p,j,o):i,w=d3.select(p),x=w.select("canvas"),y=w.select(".value.primary"),z=w.select(".value.change"),A;x.datum({id:q,primary:r,secondary:s}),x=x.node().getContext("2d"),r.on("change.comparison-"+q,D),s.on("change.comparison-"+q,D),a.on("change.comparison-"+q,B),a.on("focus.comparison-"+q,C)})}var a=this,b=a.size(),e=120,f=d3.scale.linear().interpolate(d3.interpolateRound),g=function(a){return a[0]},h=function(a){return a[1]},i=null,j=d,k=s,l=t,m=["#9ecae1","#225b84","#a1d99b","#22723a"],n=1.5;return o.remove=function(b){function c(b){b.primary.on("change.comparison-"+b.id,null),b.secondary.on("change.comparison-"+b.id,null),a.on("change.comparison-"+b.id,null),a.on("focus.comparison-"+b.id,null)}b.on("mousemove.comparison",null).on("mouseout.comparison",null),b.selectAll("canvas").each(c).remove(),b.selectAll(".title,.value").remove()},o.height=function(a){return arguments.length?(e=+a,o):e},o.primary=function(a){return arguments.length?(g=a,o):g},o.secondary=function(a){return arguments.length?(h=a,o):h},o.scale=function(a){return arguments.length?(f=a,o):f},o.extent=function(a){return arguments.length?(i=a,o):i},o.title=function(a){return arguments.length?(j=a,o):j},o.formatPrimary=function(a){return arguments.length?(k=a,o):k},o.formatChange=function(a){return arguments.length?(l=a,o):l},o.colors=function(a){return arguments.length?(m=a,o):m},o.strokeWidth=function(a){return arguments.length?(n=a,o):n},o};var s=d3.format(".2s"),t=d3.format("+.0%");f.axis=function(){function h(f){var i=++c,j,k=f.append("svg").datum({id:i}).attr("width",b).attr("height",Math.max(28,-h.tickSize())).append("g").attr("transform","translate(0,"+(e.orient()==="top"?27:4)+")").call(e);a.on("change.axis-"+i,function(){k.call(e),j||(j=d3.select(k.node().appendChild(k.selectAll("text").node().cloneNode(!0))).style("display","none").text(null))}),a.on("focus.axis-"+i,function(c){var e=a.pixelWidth();if(j)if(c==null)j.style("display","none"),k.selectAll("text").style("fill-opacity",null);else{c=(c/e|0)*e,j.style("display",null).text(g(d.invert(c)));var f=j.node().getComputedTextLength()+6,h=(f-6)/2;c+h>b?c=b-h:c-h<0&&(c=h),j.attr("x",c),k.selectAll("text").style("opacity",function(a){return Math.abs(d(a)-c)<f?0:1})}})}var a=this,b=a.size(),d=a.scale,e=d3.svg.axis().scale(d),f=a.step()<6e4?w:a.step()<864e5?x:y,g=f;return h.remove=function(b){function c(b){a.on("change.axis-"+b.id,null),a.on("focus.axis-"+b.id,null)}b.selectAll("svg").each(c).remove()},h.width=function(c){if(!arguments.length)return b;b=+c,d=a.scale.range([0,b]),e=e.scale(d)},h.focusFormat=function(a){return arguments.length?(g=a==null?f:a,h):g==f?null:a},d3.rebind(h,e,"orient","ticks","tickSubdivide","tickSize","tickPadding","tickFormat")};var w=d3.time.format("%I:%M:%S %p"),x=d3.time.format("%I:%M %p"),y=d3.time.format("%B %d");f.rule=function(){function e(b){var c=a.pixelWidth();b.style("position","absolute").style("top",0).style("bottom",0).style("width",c+"px").style("pointer-events","none")}function f(b){var c=a.pixelWidth();return(b/c|0)*c+"px"}function g(d){var g=++c,h=d.append("div").datum({id:g}).attr("class","line").call(e);d.each(function(g,h){function l(b,c){var g=[];for(var h=0,i=a.size();h<i;++h)k.valueAt(h)&&g.push(h);var j=d.selectAll(".metric").data(g);j.exit().remove(),j.enter().append("div").attr("class","metric line").call(e),j.style("left",f)}var i=this,j=++c,k=typeof b=="function"?b.call(i,g,h):b;if(!k)return;a.on("change.rule-"+j,l),k.on("change.rule-"+j,l)}),a.on("focus.rule-"+g,function(a){h.style("display",a==null?"none":null).style("left",a==null?null:a+"px")})}var a=this,b=d;return g.remove=function(b){function c(b){a.on("focus.rule-"+b.id,null)}b.selectAll(".line").each(c).remove()},g.metric=function(a){return arguments.length?(b=a,g):b},g}})(this);