You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nvd3/nv.d3.min.js

3 lines
92 KiB
JavaScript

(function(){function c(a,b,c){return function(d,e,f){var g=a(d),h=[];g<d&&b(g);if(f>1)while(g<e){var i=new Date(+g);c(i)%f||h.push(i),b(g)}else while(g<e)h.push(new Date(+g)),b(g);return h}}function b(a,b){var c=[31,28,31,30,31,30,31,31,30,31,30,31];if(a!=2)return c[a-1];if(b%4!=0)return c[1];if(b%100==0&&b%400!=0)return c[1];return c[1]+1}var a={version:"0.0.1a",dev:!0};window.nv=a,a.tooltip={},a.utils={},a.models={},a.charts={},a.graphs=[],a.log={},a.dispatch=d3.dispatch("render_start","render_end"),a.dispatch.on("render_start",function(b){a.log.startTime=+(new Date)}),a.dispatch.on("render_end",function(b){a.log.endTime=+(new Date),a.log.totalTime=a.log.endTime-a.log.startTime,a.dev&&console.log&&console.log("total",a.log.totalTime)}),a.render=function b(c){c=c||1,b.active=!0,a.dispatch.render_start(),setTimeout(function(){var d;for(var e=0;e<c&&(graph=b.queue[e]);e++)d=graph.generate(),typeof graph.callback=="function"&&graph.callback(d),a.graphs.push(d);b.queue.splice(0,e),b.queue.length?setTimeout(arguments.callee,0):(a.render.active=!1,a.dispatch.render_end())},0)},a.render.queue=[],a.addGraph=function(b){typeof arguments[0]=="function"&&(b={generate:arguments[0],callback:arguments[1]}),a.render.queue.push(b),a.render.active||a.render()},a.identity=function(a){return a},a.strip=function(a){return a.replace(/(\s|&)/g,"")},d3.time.monthEnd=function(a){return new Date(a.getFullYear(),a.getMonth(),0)},d3.time.monthEnds=c(d3.time.monthEnd,function(a){a.setUTCDate(a.getUTCDate()+1),a.setDate(b(a.getMonth()+1,a.getFullYear()))},function(a){return a.getMonth()}),function(){var b=window.nv.tooltip={};b.show=function(b,c,d,e){var f=document.createElement("div");f.className="nvtooltip",d=d||"s",e=e||20;var g=document.getElementsByTagName("body")[0];f.innerHTML=c,f.style.left=1,f.style.top=1,f.style.opacity=0,g.appendChild(f);var h=parseInt(f.offsetHeight),i=parseInt(f.offsetWidth),j=a.utils.windowSize().width,k=a.utils.windowSize().height,l=g.scrollTop,m=g.scrollLeft,n,o;switch(d){case"e":n=b[0]-i-e,o=b[1]-h/2,n<m&&(n=b[0]+e),o<l&&(o=l+5),o+h>l+k&&(o=l-h-5);break;case"w":n=b[0]+e,o=b[1]-h/2,n+i>j&&(n=b[0]-i-e),o<l&&(o=l+5),o+h>l+k&&(o=l-h-5);break;case"n":n=b[0]-i/2,o=b[1]+e,n<m&&(n=m+5),n+i>j&&(n=j-i-5),o+h>l+k&&(o=b[1]-h-e);break;case"s":n=b[0]-i/2,o=b[1]-h-e,n<m&&(n=m+5),n+i>j&&(n=j-i-5),l>o&&(o=b[1]+20)}f.style.left=n+"px",f.style.top=o+"px",f.style.opacity=1;return f},b.cleanup=function(){var a=document.getElementsByClassName("nvtooltip"),b=[];while(a.length)b.push(a[0]),a[0].style.transitionDelay="0 !important",a[0].style.opacity=0,a[0].className="nvtooltip-pending-removal";setTimeout(function(){while(b.length){var a=b.pop();a.parentNode.removeChild(a)}},500)}}(),a.utils.windowSize=function(){var a={width:640,height:480};document.body&&document.body.offsetWidth&&(a.width=document.body.offsetWidth,a.height=document.body.offsetHeight),document.compatMode=="CSS1Compat"&&document.documentElement&&document.documentElement.offsetWidth&&(a.width=document.documentElement.offsetWidth,a.height=document.documentElement.offsetHeight),window.innerWidth&&window.innerHeight&&(a.width=window.innerWidth,a.height=window.innerHeight);return a},a.utils.windowResize=function(a){var b=window.onresize;window.onresize=function(c){typeof b=="function"&&b(c),a(c)}},a.models.axis=function(){function g(h){h.each(function(g){var h=d3.select(this),i=h.selectAll("g.wrap.axis").data([g]),j=i.enter().append("g").attr("class","wrap axis"),k=j.append("g"),l=i.select("g");(e.orient()=="top"||e.orient()=="bottom")&&e.ticks(Math.abs(a.range()[1]-a.range()[0])/100),d3.transition(l).call(e),f=f||e.scale();var m=l.selectAll("text.axislabel").data([b||null]);m.exit().remove();switch(e.orient()){case"top":m.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",0),m.attr("x",a.range()[1]/2);if(c){var n=i.selectAll("g.axisMaxMin").data(a.domain());n.enter().append("g").attr("class","axisMaxMin").append("text"),n.exit().remove(),n.attr("transform",function(b,c){return"translate("+a(b)+",0)"}).select("text").attr("dy","0em").attr("y",-e.tickPadding()).attr("text-anchor","middle").text(function(a,b){return e.tickFormat()(a)}),d3.transition(n).attr("transform",function(b,c){return"translate("+a.range()[c]+",0)"})}break;case"bottom":m.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",25),m.attr("x",a.range()[1]/2);if(c){var n=i.selectAll("g.axisMaxMin").data(a.domain());n.enter().append("g").attr("class","axisMaxMin").append("text"),n.exit().remove(),n.attr("transform",function(b,c){return"translate("+a(b)+",0)"}).select("text").attr("dy",".71em").attr("y",e.tickPadding()).attr("text-anchor","middle").text(function(a,b){return e.tickFormat()(a)}),d3.transition(n).attr("transform",function(b,c){return"translate("+a.range()[c]+",0)"})}break;case"right":m.enter().append("text").attr("class","axislabel").attr("transform","rotate(90)").attr("y",-40),m.attr("x",-a.range()[0]/2);if(c){var n=i.selectAll("g.axisMaxMin").data(a.domain());n.enter().append("g").attr("class","axisMaxMin").append("text").style("opacity",0),n.exit().remove(),n.attr("transform",function(b,c){return"translate(0,"+a(b)+")"}).select("text").attr("dy",".32em").attr("dx",e.tickPadding()).attr("text-anchor","start").text(function(a,b){return e.tickFormat()(a)}),d3.transition(n).attr("transform",function(b,c){return"translate(0,"+a.range()[c]+")"}).select("text").style("opacity",1)}break;case"left":m.enter().append("text").attr("class","axislabel").attr("transform","rotate(-90)").attr("y",-40),m.attr("x",-a.range()[0]/2);if(c){var n=i.selectAll("g.axisMaxMin").data(a.domain());n.enter().append("g").attr("class","axisMaxMin").append("text").style("opacity",0),n.exit().remove(),n.attr("transform",function(a,b){return"translate(0,"+f(a)+")"}).select("text").attr("dy",".32em").attr("dx",-e.tickPadding()).attr("text-anchor","end").text(function(a,b){return e.tickFormat()(a)}),d3.transition(n).attr("transform",function(b,c){return"translate(0,"+a.range()[c]+")"}).select("text").style("opacity",1)}}m.text(function(a){return a}),c&&(e.orient()==="left"||e.orient()==="right")&&l.selectAll("g").filter(function(b,c){return b&&(a(b)<8||a(b)>a.range()[0]-8)}).remove();if(c&&(e.orient()==="top"||e.orient()==="bottom")){var o=[];i.selectAll("g.axisMaxMin").each(function(b,c){c?o.push(a(b)-this.getBBox().width-4):o.push(a(b)+this.getBBox().width+4)}),l.selectAll("g").filter(function(b,c){return b&&(a(b)<o[0]||a(b)>o[1])}).remove()}d&&l.selectAll("line.tick").filter(function(a){return!parseFloat(Math.round(a*1e5)/1e6)}).classed("zero",!0),f=a.copy()});return g}var a=d3.scale.linear(),b=null,c=!0,d=!0,e=d3.svg.axis().scale(a).orient("bottom").tickFormat(function(a){return a}),f;d3.rebind(g,e,"orient","ticks","tickValues","tickSubdivide","tickSize","tickPadding","tickFormat"),d3.rebind(g,a,"domain","range","rangeBand","rangeBands"),g.axisLabel=function(a){if(!arguments.length)return b;b=a;return g},g.showMaxMin=function(a){if(!arguments.length)return c;c=a;return g},g.highlightZero=function(a){if(!arguments.length)return d;d=a;return g},g.scale=function(b){if(!arguments.length)return a;a=b,e.scale(a),d3.rebind(g,a,"domain","range","rangeBand","rangeBands");return g};return g},a.models.historicalBar=function(){function r(g){g.each(function(g){var h=b-a.left-a.right,o=c-a.top-a.bottom;m.domain(k||d3.extent(g[0].values,e)).range([0,h]),n.domain(l||d3.extent(g[0].values,f)).range([o,0]);var p=d3.select(this).on("click",function(a,b){q.chartClick({data:a,index:b,pos:d3.event,id:d})}),r=d3.select(this).selectAll("g.wrap.bar").data([g[0].values]),s=r.enter().append("g").attr("class","wrap nvd3 bar"),t=s.append("g");t.append("g").attr("class","bars"),r.attr("width",b).attr("height",c);var u=r.select("g").attr("transform","translate("+a.left+","+a.top+")");s.append("defs").append("clipPath").attr("id","chart-clip-path-"+d).append("rect"),r.select("#chart-clip-path-"+d+" rect").attr("width",h).attr("height",o),t.attr("clip-path",i?"url(#chart-clip-path-"+d+")":"");var v=t.append("g").attr("class","shiftWrap"),w=r.select(".bars").selectAll(".bar").data(function(a){return a});w.exit().remove();var z=w.enter().append("svg:rect").attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("fill",function(a,b){return j[0]}).attr("x",0).attr("y",function(a,b){return n(Math.max(0,f(a,b)))}).attr("height",function(a,b){return Math.abs(n(f(a,b))-n(0))}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),q.elementMouseover({point:a,series:g[0],pos:[m(e(a,b)),n(f(a,b))],pointIndex:b,seriesIndex:0,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),q.elementMouseout({point:a,series:g[0],pointIndex:b,seriesIndex:0,e:d3.event})}).on("click",function(a,b){q.elementClick({value:f(a,b),data:a,index:b,pos:[m(e(a,b)),n(f(a,b))],e:d3.event,id:d}),d3.event.stopPropagation()}).on("dblclick",function(a,b){q.elementDblClick({value:f(a,b),data:a,index:b,pos:[m(e(a,b)),n(f(a,b))],e:d3.event,id:d}),d3.event.stopPropagation()});w.attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("transform",function(a,b){return"translate("+(m(e(a,b))-m(.5))+",0)"}).attr("width",m(.9)),d3.transition(w).attr("y",function(a,b){return n(Math.max(0,f(a,b)))}).attr("height",function(a,b){return Math.abs(n(f(a,b))-n(0))})});return r}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=Math.floor(Math.random()*1e4),e=function(a){return a.x},f=function(a){return a.y},g=[],h=[],i=!0,j=d3.scale.category20().range(),k,l,m=d3.scale.linear(),n=d3.scale.linear(),o=d3.svg.axis().scale(m).orient("bottom"),p=d3.svg.axis().scale(n).orient("left"),q=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");r.dispatch=q,r.x=function(a){if(!arguments.length)return e;e=a;return r},r.y=function(a){if(!arguments.length)return f;f=a;return r},r.margin=function(b){if(!arguments.length)return a;a=b;return r},r.width=function(a){if(!arguments.length)return b;b=a;return r},r.height=function(a){if(!arguments.length)return c;c=a;return r},r.xScale=function(a){if(!arguments.length)return m;m=a;return r},r.yScale=function(a){if(!arguments.length)return n;n=a;return r},r.xDomain=function(a){if(!arguments.length)return k;k=a;return r},r.yDomain=function(a){if(!arguments.length)return l;l=a;return r},r.forceX=function(a){if(!arguments.length)return g;g=a;return r},r.forceY=function(a){if(!arguments.length)return h;h=a;return r},r.clipEdge=function(a){if(!arguments.length)return i;i=a;return r},r.color=function(a){if(!arguments.length)return j;j=a;return r},r.id=function(a){if(!arguments.length)return d;d=a;return r};return r},a.models.bullet=function(){function k(a){a.each(function(a,k){var l=d.call(this,a,k).slice().sort(d3.descending),m=e.call(this,a,k).slice().sort(d3.descending),n=f.call(this,a,k).slice().sort(d3.descending),o=d3.select(this),p=d3.scale.linear().domain([0,Math.max(l[0],m[0],n[0])]).range(b?[g,0]:[0,g]),q=this.__chart__||d3.scale.linear().domain([0,Infinity]).range(p.range());this.__chart__=p;var r=function(a){return Math.abs(q(a)-q(0))},s=function(a){return Math.abs(p(a)-p(0))},t=o.selectAll("rect.range").data(l);t.enter().append("rect").attr("class",function(a,b){return"range s"+b}).attr("width",r).attr("height",h).attr("x",b?q:0).on("mouseover",function(a,b){j.elementMouseover({value:a,label:b<=0?"Maximum":b>1?"Minimum":"Mean",pos:[p(a),h/2]})}).on("mouseout",function(a,b){j.elementMouseout({value:a,label:b<=0?"Minimum":b>=1?"Maximum":"Mean"})}).transition().duration(c).attr("width",s).attr("x",b?p:0),t.transition().duration(c).attr("x",b?p:0).attr("width",s).attr("height",h);var u=o.selectAll("rect.measure").data(n);u.enter().append("rect").attr("class",function(a,b){return"measure s"+b}).attr("width",r).attr("height",h/3).attr("x",b?q:0).attr("y",h/3).on("mouseover",function(a){j.elementMouseover({value:a,label:"Current",pos:[p(a),h/2]})}).on("mouseout",function(a){j.elementMouseout({value:a,label:"Current"})}).transition().duration(c).attr("width",s).attr("x",b?p:0),u.transition().duration(c).attr("width",s).attr("height",h/3).attr("x",b?p:0).attr("y",h/3);var v=o.selectAll("path.markerTriangle").data(m),w=h/6;v.enter().append("path").attr("class","markerTriangle").attr("transform",function(a){return"translate("+q(a)+","+h/2+")"}).attr("d","M0,"+w+"L"+w+","+ -w+" "+ -w+","+ -w+"Z").on("mouseover",function(a,b){j.elementMouseover({value:a,label:"Previous",pos:[p(a),h/2]})}).on("mouseout",function(a,b){j.elementMouseout({value:a,label:"Previous"})}),v.transition().duration(c).attr("transform",function(a){return"translate("+p(a)+","+h/2+")"}),v.exit().remove();var x=i||p.tickFormat(8),y=o.selectAll("g.tick").data(p.ticks(8),function(a){return this.textContent||x(a)}),z=y.enter().append("g").attr("class","tick").attr("transform",function(a){return"translate("+q(a)+",0)"}).style("opacity",1e-6);z.append("line").attr("y1",h).attr("y2",h*7/6),z.append("text").attr("text-anchor","middle").attr("dy","1em").attr("y",h*7/6).text(x),z.transition().duration(c).attr("transform",function(a){return"translate("+p(a)+",0)"}).style("opacity",1);var A=y.transition().duration(c).attr("transform",function(a){return"translate("+p(a)+",0)"}).style("opacity",1);A.select("line").attr("y1",h).attr("y2",h*7/6),A.select("text").attr("y",h*7/6),y.exit().transition().duration(c).attr("transform",function(a){return"translate("+p(a)+",0)"}).style("opacity",1e-6).remove()}),d3.timer.flush()}var a="left",b=!1,c=0,d=function(a){return a.ranges},e=function(a){return a.markers},f=function(a){return a.measures},g=380,h=30,i=null,j=d3.dispatch("elementMouseover","elementMouseout");k.dispatch=j,k.orient=function(c){if(!arguments.length)return a;a=c,b=a=="right"||a=="bottom";return k},k.ranges=function(a){if(!arguments.length)return d;d=a;return k},k.markers=function(a){if(!arguments.length)return e;e=a;return k},k.measures=function(a){if(!arguments.length)return f;f=a;return k},k.width=function(a){if(!arguments.length)return g;g=a;return k},k.height=function(a){if(!arguments.length)return h;h=a;return k},k.tickFormat=function(a){if(!arguments.length)return i;i=a;return k},k.duration=function(a){if(!arguments.length)return c;c=a;return k};return k},a.models.cumulativeLineChart=function(){function C(a,b){return b.map(function(b,c){var d=k.y()(b.values[a],a);return{key:b.key,values:b.values.map(function(a,b){return{x:k.x()(a,b),y:(k.y()(a,b)-d)/(1+d)}}),disabled:b.disabled,hover:b.hover}})}function B(h){h.each(function(y){var z=d3.select(this).classed("chart-"+o,!0),A=this,D=(d||parseInt(z.style("width"))||960)-b.left-b.right,E=(e||parseInt(z.style("height"))||400)-b.top-b.bottom,F=C(u.i,y);n.domain([0,y[0].values.length-1]).range([0,D]).clamp(!0);var G=z.selectAll("g.wrap.cumulativeLine").data([F]),H=G.enter().append("g").attr("class","wrap nvd3 cumulativeLine").append("g");H.append("g").attr("class","x axis"),H.append("g").attr("class","y axis"),H.append("g").attr("class","linesWrap"),H.append("g").attr("class","legendWrap"),H.append("g").attr("class","controlsWrap");var I=G.select("g");f&&(r.width(D),I.select(".legendWrap").datum(y).call(r),b.top!=r.height()&&(b.top=r.height(),E=(e||parseInt(z.style("height"))||400)-b.top-b.bottom),I.select(".legendWrap").attr("transform","translate(0,"+ -b.top+")")),i&&(s.width(140).color(["#444","#444","#444"]),I.select(".controlsWrap").datum(v).attr("transform","translate(0,"+ -b.top+")").call(s)),k.width(D).height(E).color(F.map(function(a,b){return a.color||c[b%c.length]}).filter(function(a,b){return!y[b].disabled})),I.attr("transform","translate("+b.left+","+b.top+")");var J=I.select(".linesWrap").datum(F.filter(function(a){return!a.disabled}));d3.transition(J).call(k);var K=J.selectAll(".indexLine").data([u]);K.enter().append("rect").attr("class","indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).call(x),K.attr("transform",function(a){return"translate("+n(a.i)+",0)"}).attr("height",E),p.scale(l).ticks(D/100).tickSize(-E,0),I.select(".x.axis").attr("transform","translate(0,"+m.range()[0]+")"),d3.transition(I.select(".x.axis")).call(p),q.scale(m).ticks(E/36).tickSize(-D,0),d3.transition(I.select(".y.axis")).call(q),s.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,j=!a.disabled,h.transition().call(B)}),r.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,y.filter(function(a){return!a.disabled}).length||y.map(function(a){a.disabled=!1,G.selectAll(".series").classed("disabled",!1);return a}),h.transition().call(B)}),k.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],t.tooltipShow(a)}),g&&t.on("tooltipShow",function(a){w(a,A.parentNode)}),k.dispatch.on("elementMouseout.tooltip",function(a){t.tooltipHide(a)}),g&&t.on("tooltipHide",a.tooltip.cleanup)}),B.update=function(){B(h)},B.container=this;return B}function A(a,b){B.update()}function z(a,b){a.x+=d3.event.dx,a.i=Math.round(n.invert(a.x)),d3.select(this).attr("transform","translate("+n(a.i)+",0)")}function y(a,b){}var b={top:30,right:20,bottom:50,left:60},c=d3.scale.category20().range(),d=null,e=null,f=!0,g=!0,h=function(a,b,c,d,e){return"<h3>"+a+"</h3>"+"<p>"+c+" at "+b+"</p>"},i=!1,j=!0,k=a.models.line(),l=k.xScale(),m=k.yScale(),n=d3.scale.linear(),o=k.id(),p=a.models.axis().scale(l).orient("bottom").tickPadding(5),q=a.models.axis().scale(m).orient("left"),r=a.models.legend().height(30),s=a.models.legend().height(30),t=d3.dispatch("tooltipShow","tooltipHide"),u={i:0,x:0},v=[{key:"Re-scale y-axis"}],w=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=p.tickFormat()(k.x()(b.point)),g=q.tickFormat()(k.y()(b.point)),i=h(b.series.key,f,g,b,B);a.tooltip.show([d,e],i)},x=d3.behavior.drag().on("dragstart",y).on("drag",z).on("dragend",A);B.dispatch=t,B.legend=r,B.xAxis=p,B.yAxis=q,d3.rebind(B,k,"x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),B.margin=function(a){if(!arguments.length)return b;b=a;return B},B.width=function(a){if(!arguments.length)return d;d=a;return B},B.height=function(a){if(!arguments.length)return e;e=a;return B},B.color=function(a){if(!arguments.length)return c;c=a,r.color(a);return B},B.showLegend=function(a){if(!arguments.length)return f;f=a;return B},B.tooltips=function(a){if(!arguments.length)return g;g=a;return B},B.tooltipContent=function(a){if(!arguments.length)return h;h=a;return B};return B},a.models.discreteBar=function(){function r(d){d.each(function(s){var t=b-a.left-a.right,u=c-a.top-a.bottom;s=s.map(function(a,b){a.values=a.values.map(function(a){a.series=b;return a});return a});var v=m&&n?[]:s.map(function(a){return a.values.map(function(a,b){return{x:g(a,b),y:h(a,b),y0:a.y0}})});e.domain(m||d3.merge(v).map(function(a){return a.x})).rangeBands([0,t],.1),f.domain(n||d3.extent(d3.merge(v).map(function(a){return a.y}).concat(i))),k?f.range([u-(f.domain()[0]<0?12:0),f.domain()[1]<0?0:12]):f.range([u,0]),o=o||e,p=p||d3.scale.linear().domain(f.domain()).range([f(0),f(0)]);var w=d3.select(this).selectAll("g.wrap.discretebar").data([s]),z=w.enter().append("g").attr("class","wrap nvd3 discretebar"),A=z.append("g");A.append("g").attr("class","groups");var B=w.select("g");w.attr("transform","translate("+a.left+","+a.top+")");var C=w.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});C.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(C.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),C.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}),d3.transition(C).style("stroke-opacity",1).style("fill-opacity",.75);var D=C.selectAll("g.bar").data(function(a){return a.values});D.exit().remove();var E=D.enter().append("g").attr("transform",function(a,b,c){return"translate("+e(g(a,b))+", "+f(0)+")"}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),q.elementMouseover({value:h(a,b),point:a,series:s[a.series],pos:[e(g(a,b))+e.rangeBand()*(a.series+.5)/s.length,f(h(a,b))],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),q.elementMouseout({value:h(a,b),point:a,series:s[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){q.elementClick({value:h(a,b),point:a,series:s[a.series],pos:[e(g(a,b))+e.rangeBand()*(a.series+.5)/s.length,f(h(a,b))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(a,b){q.elementDblClick({value:h(a,b),point:a,series:s[a.series],pos:[e(g(a,b))+e.rangeBand()*(a.series+.5)/s.length,f(h(a,b))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()});E.append("rect").attr("height",0).attr("width",e.rangeBand()/s.length).style("fill",function(a,b){return a.color||j[b%j.length]}).style("stroke",function(a,b){return a.color||j[b%j.length]}),k?(E.append("text").attr("text-anchor","middle"),D.selectAll("text").attr("dx",e.rangeBand()/2).attr("dy",function(a,b){return h(a,b)<0?f(h(a,b))-f(0)+12:-4}).text(function(a,b){return l(h(a,b))})):D.selectAll("text").remove(),D.attr("class",function(a,b){return h(a,b)<0?"bar negative":"bar positive"}).attr("transform",function(a,b){return"translate("+e(g(a,b))+", "+(h(a,b)<0?p(0):p(h(a,b)))+")"}).selectAll("rect").attr("width",e.rangeBand()/s.length),d3.transition(D).attr("transform",function(a,b){return"translate("+e(g(a,b))+", "+(h(a,b)<0?f(0):f(h(a,b)))+")"}).selectAll("rect").attr("height",function(a,b){return Math.abs(f(h(a,b))-f(0))}),r.update=function(){d.transition().call(r)},o=e.copy(),p=f.copy()});return r}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=Math.floor(Math.random()*1e4),e=d3.scale.ordinal(),f=d3.scale.linear(),g=function(a){return a.x},h=function(a){return a.y},i=[0],j=d3.scale.category20().range(),k=!1,l=d3.format(",.2f"),m,n,o,p,q=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");r.dispatch=q,r.x=function(a){if(!arguments.length)return g;g=a;return r},r.y=function(a){if(!arguments.length)return h;h=a;return r},r.margin=function(b){if(!arguments.length)return a;a=b;return r},r.width=function(a){if(!arguments.length)return b;b=a;return r},r.height=function(a){if(!arguments.length)return c;c=a;return r},r.xScale=function(a){if(!arguments.length)return e;e=a;return r},r.yScale=function(a){if(!arguments.length)return f;f=a;return r},r.xDomain=function(a){if(!arguments.length)return m;m=a;return r},r.yDomain=function(a){if(!arguments.length)return n;n=a;return r},r.forceY=function(a){if(!arguments.length)return i;i=a;return r},r.color=function(a){if(!arguments.length)return j;j=a;return r},r.id=function(a){if(!arguments.length)return d;d=a;return r},r.showValues=function(a){if(!arguments.length)return k;k=a;return r},r.valuesFormat=function(a){if(!arguments.length)return l;l=a;return r};return r},a.models.discreteBarChart=function(){function q(e){e.each(function(h){var p=d3.select(this),r=this,s=(c||parseInt(p.style("width"))||960)-b.left-b.right,t=(d||parseInt(p.style("height"))||400)-b.top-b.bottom;i.width(s).height(t);var u=p.selectAll("g.wrap.discreteBarWithAxes").data([h]),v=u.enter().append("g").attr("class","wrap nvd3 discreteBarWithAxes").append("g"),w=v.append("defs");v.append("g").attr("class","x axis"),v.append("g").attr("class","y axis"),v.append("g").attr("class","barsWrap");var z=u.select("g");z.attr("transform","translate("+b.left+","+b.top+")");var A=z.select(".barsWrap").datum(h.filter(function(a){return!a.disabled}));d3.transition(A).call(i),w.append("clipPath").attr("id","x-label-clip-"+i.id()).append("rect"),z.select("#x-label-clip-"+i.id()+" rect").attr("width",j.rangeBand()*(f?2:1)).attr("height",16).attr("x",-j.rangeBand()/(f?1:2)),l.ticks(s/100).tickSize(-t,0),z.select(".x.axis").attr("transform","translate(0,"+(k.range()[0]+(i.showValues()?16:0))+")"),z.select(".x.axis").transition().duration(0).call(l);var B=z.select(".x.axis").selectAll("g");f&&B.selectAll("text").attr("transform",function(a,b,c){return"translate(0,"+(c%2==0?"0":"12")+")"}),B.selectAll("text").attr("clip-path",function(a,b,c){return"url(#x-label-clip-"+i.id()+")"}),m.ticks(t/36).tickSize(-s,0),d3.transition(z.select(".y.axis")).call(m),i.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],n.tooltipShow(a)}),g&&n.on("tooltipShow",function(a){o(a,r.parentNode)}),i.dispatch.on("elementMouseout.tooltip",function(a){n.tooltipHide(a)}),g&&n.on("tooltipHide",a.tooltip.cleanup),q.update=function(){e.transition().call(q)},q.container=this});return q}var b={top:30,right:20,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!1,g=!0,h=function(a,b,c,d,e){return"<h3>"+b+"</h3>"+"<p>"+c+"</p>"},i=a.models.discreteBar(),j=i.xScale(),k=i.yScale(),l=a.models.axis().scale(j).orient("bottom").highlightZero(!1).showMaxMin(!1),m=a.models.axis().scale(k).orient("left"),n=d3.dispatch("tooltipShow","tooltipHide");l.tickFormat(function(a){return a}),m.tickFormat(d3.format(",.1f"));var o=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=l.tickFormat()(i.x()(b.point)),g=m.tickFormat()(i.y()(b.point)),j=h(b.series.key,f,g,b,q);a.tooltip.show([d,e],j,b.value<0?"n":"s")},p=[{key:"Grouped"},{key:"Stacked",disabled:!0}];q.dispatch=n,q.discretebar=i,q.xAxis=l,q.yAxis=m,d3.rebind(q,i,"x","y","xDomain","yDomain","forceX","forceY","id","showValues","valueFormat"),q.margin=function(a){if(!arguments.length)return b;b=a;return q},q.width=function(a){if(!arguments.length)return c;c=a;return q},q.height=function(a){if(!arguments.length)return d;d=a;return q},q.color=function(a){if(!arguments.length)return e;e=a,i.color(a);return q},q.staggerLabels=function(a){if(!arguments.length)return f;f=a;return q},q.tooltips=function(a){if(!arguments.length)return g;g=a;return q},q.tooltipContent=function(a){if(!arguments.length)return h;h=a;return q};return q},a.models.distribution=function(){function j(g){g.each(function(g){var j=b-(d==="x"?a.left+a.right:a.top+a.bottom),k=d=="x"?"y":"x";i=i||h;var l=d3.select(this).selectAll("g.distribution").data([g]),m=l.enter().append("g").attr("class","nvd3 distribution"),n=m.append("g"),o=l.select("g");l.attr("transform","translate("+a.left+","+a.top+")");var p=o.selectAll("g.dist").data(function(a){return a},function(a){return a.key});p.enter().append("g"),p.attr("class",function(a,b){return"dist series-"+b}).style("stroke",function(a,b){return f[b%f.length]});var q=p.selectAll("line.dist"+d).data(function(a){return a.values});q.enter().append("line").attr(d+"1",function(a,b){return i(e(a,b))}).attr(d+"2",function(a,b){return i(e(a,b))}),d3.transition(p.exit().selectAll("line.dist"+d)).attr(d+"1",function(a,b){return h(e(a,b))}).attr(d+"2",function(a,b){return h(e(a,b))}).style("stroke-opacity",0).remove(),q.attr("class",function(a,b){return"dist"+d+" dist"+d+"-"+b}).attr(k+"1",0).attr(k+"2",c),d3.transition(q).attr(d+"1",function(a,b){return h(e(a,b))}).attr(d+"2",function(a,b){return h(e(a,b))}),i=h.copy()});return j}var a={top:0,right:0,bottom:0,left:0},b=400,c=8,d="x",e=function(a){return a[d]},f=d3.scale.category20().range(),g,h=d3.scale.linear(),i;j.margin=function(b){if(!arguments.length)return a;a=b;return j},j.width=function(a){if(!arguments.length)return b;b=a;return j},j.axis=function(a){if(!arguments.length)return d;d=a;return j},j.size=function(a){if(!arguments.length)return c;c=a;return j},j.getData=function(a){if(!arguments.length)return e;e=d3.functor(a);return j},j.scale=function(a){if(!arguments.length)return h;h=a;return j},j.color=function(a){if(!arguments.length)return f;f=a;return j};return j},a.models.legend=function(){function g(h){h.each(function(g){var h=b-a.left-a.right,i=d3.select(this).selectAll("g.legend").data([g]),j=i.enter().append("g").attr("class","nvd3 legend").append("g"),l=i.select("g").attr("transform","translate("+a.left+","+a.top+")"),m=l.selectAll(".series").data(function(a){return a}),n=m.enter().append("g").attr("class","series").on("mouseover",function(a,b){f.legendMouseover(a,b)}).on("mouseout",function(a,b){f.legendMouseout(a,b)}).on("click",function(a,b){f.legendClick(a,b)}).on("dblclick",function(a,b){f.legendDblclick(a,b)});n.append("circle").style("fill",function(a,b){return a.color||d[b%d.length]}).style("stroke",function(a,b){return a.color||d[b%d.length]}).style("stroke-width",2).attr("r",5),n.append("text").text(function(a){return a.key}).attr("text-anchor","start").attr("dy",".32em").attr("dx","8"),m.classed("disabled",function(a){return a.disabled}),m.exit().remove();if(e){var o=[];m.each(function(a,b){o.push(d3.select(this).select("text").node().getComputedTextLength()+28)});var p=0,q=0,r=[];while(q<h&&p<o.length)r[p]=o[p],q+=o[p++];while(q>h&&p>1){r=[],p--;for(k=0;k<o.length;k++)o[k]>(r[k%p]||0)&&(r[k%p]=o[k]);q=r.reduce(function(a,b,c,d){return a+b})}var s=[];for(var t=0,u=0;t<p;t++)s[t]=u,u+=r[t];m.attr("transform",function(a,b){return"translate("+s[b%p]+","+(5+Math.floor(b/p)*20)+")"}),l.attr("transform","translate("+(b-a.right-q)+","+a.top+")"),c=a.top+a.bottom+Math.ceil(o.length/p)*20}else{var v=5,w=5,x=0,y;m.attr("transform",function(c,d){var e=d3.select(this).select("text").node().getComputedTextLength()+28;y=w,b<a.left+a.right+y+e&&(w=y=5,v+=20),w+=e,w>x&&(x=w);return"translate("+y+","+v+")"}),l.attr("transform","translate("+(b-a.right-x)+","+a.top+")"),c=a.top+a.bottom+v+15}});return g}var a={top:5,right:0,bottom:5,left:0},b=400,c=20,d=d3.scale.category20().range(),e=!0,f=d3.dispatch("legendClick","legendDblclick","legendMouseover","legendMouseout");g.dispatch=f,g.margin=function(b){if(!arguments.length)return a;a=b;return g},g.width=function(a){if(!arguments.length)return b;b=a;return g},g.height=function(a){if(!arguments.length)return c;c=a;return g},g.color=function(a){if(!arguments.length)return d;d=a;return g},g.align=function(a){if(!arguments.length)return e;e=a;return g};return g},a.models.line=function(){function p(a){a.each(function(a){var o=c-b.left-b.right,p=d-b.top-b.bottom;k=k||j.xScale(),l=l||j.yScale(),m=m||k,n=n||l;var q=d3.select(this).selectAll("g.wrap.line").data([a]),r=q.enter().append("g").attr("class","wrap nvd3 line"),s=r.append("defs"),t=r.append("g"),u=q.select("g");t.append("g").attr("class","groups"),t.append("g").attr("class","scatterWrap");var v=q.select(".scatterWrap");j.width(o).height(p),d3.transition(v).call(j),q.attr("transform","translate("+b.left+","+b.top+")"),s.append("clipPath").attr("id","edge-clip-"+f).append("rect"),q.select("#edge-clip-"+f+" rect").attr("width",o).attr("height",p),u.attr("clip-path",i?"url(#edge-clip-"+f+")":""),v.attr("clip-path",i?"url(#edge-clip-"+f+")":"");var w=q.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});w.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(w.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),w.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return e[b%e.length]}).style("stroke",function(a,b){return e[b%e.length]}),d3.transition(w).style("stroke-opacity",1).style("fill-opacity",.5);var z=w.selectAll("path").data(function(a,b){return[a.values]});z.enter().append("path").attr("class","line").attr("d",d3.svg.line().x(function(a,b){return m(g(a,b))}).y(function(a,b){return n(h(a,b))})),d3.transition(w.exit().selectAll("path")).attr("d",d3.svg.line().x(function(a,b){return k(g(a,b))}).y(function(a,b){return l(h(a,b))})),d3.transition(z).attr("d",d3.svg.line().x(function(a,b){return k(g(a,b))}).y(function(a,b){return l(h(a,b))})),m=k.copy(),n=l.copy()});return p}var b={top:0,right:0,bottom:0,left:0},c=960,d=500,e=d3.scale.category20().range(),f=Math.floor(Math.random()*1e4),g=function(a){return a.x},h=function(a){return a.y},i=!1,j=a.models.scatter().id(f).size(16).sizeDomain([16,256]),k,l,m,n,o;p.dispatch=j.dispatch,d3.rebind(p,j,"interactive","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius"),p.margin=function(a){if(!arguments.length)return b;b=a;return p},p.width=function(a){if(!arguments.length)return c;c=a;return p},p.height=function(a){if(!arguments.length)return d;d=a;return p},p.x=function(a){if(!arguments.length)return g;g=a,j.x(a);return p},p.y=function(a){if(!arguments.length)return h;h=a,j.y(a);return p},p.clipEdge=function(a){if(!arguments.length)return i;i=a;return p},p.color=function(a){if(!arguments.length)return e;e=a,j.color(a);return p},p.id=function(a){if(!arguments
.length)return f;f=a;return p};return p},a.models.indentedTree=function(){function i(d){d.each(function(e){function B(a){var b=a.values||a._values;return b&&b.length}function A(a){return a._values&&a._values.length}function z(a){return a._values&&a._values.length?iconOpen:a.values&&a.values.length?iconClose:""}function y(a,b,c){d3.event.stopPropagation();if(d3.event.shiftKey&&!c){d3.event.shiftKey=!1,a.values&&a.values.forEach(function(a){(a.values||a._values)&&y(a,0,!0)});return!0}if(!B(a))return!0;a.values?(a._values=a.values,a.values=null):(a.values=a._values,a._values=null),i.update()}var j=b-a.left-a.right,k=c-a.top-a.bottom;i.update=function(){d.transition().call(i)};var l=0,m=1,n=d3.layout.tree().children(function(a){return a.values}).size([c,childIndent]);e[0].key||(e[0].key=g);var o=n.nodes(e[0]),p=d3.select(this).selectAll("div").data([[o]]),q=p.enter().append("div").attr("class","wrap nvd3 indentedtree"),r=q.append("table"),s=p.select("table").attr("width","100%").attr("class",tableClass);if(f){var t=r.append("thead"),u=t.append("tr");columns.forEach(function(a){u.append("th").attr("width",a.width?a.width:"10%").style("text-align",a.type=="numeric"?"right":"left").append("span").text(a.label)})}var v=s.selectAll("tbody").data(function(a){return a});v.enter().append("tbody"),m=d3.max(o,function(a){return a.depth}),n.size([c,m*childIndent]);var w=v.selectAll("tr").data(function(a){return a},function(a){return a.id||a.id==++l});w.exit().remove(),w.select("img.treeicon").attr("src",z).classed("folded",A);var x=w.enter().append("tr");columns.forEach(function(a,b){var c=x.append("td").style("padding-left",function(a){return(b?0:a.depth*childIndent+12+(z(a)?0:16))+"px"},"important").style("text-align",a.type=="numeric"?"right":"left");b==0&&c.append("img").classed("treeicon",!0).classed("folded",A).attr("src",z).style("width","14px").style("height","14px").style("padding","0 1px").style("display",function(a){return z(a)?"inline-block":"none"}).on("click",y),c.append("span").attr("class",d3.functor(a.classes)).text(function(b){return a.format?a.format(b):b[a.key]||"-"}),a.showCount&&c.append("span").attr("class","childrenCount").text(function(a){return a.values&&a.values.length||a._values&&a._values.length?"("+(a.values&&a.values.length||a._values&&a._values.length)+")":""}),a.click&&c.select("span").on("click",a.click)}),w.order().on("click",function(a){h.elementClick({row:this,data:a,pos:[a.x,a.y]})}).on("dblclick",function(a){h.elementDblclick({row:this,data:a,pos:[a.x,a.y]})}).on("mouseover",function(a){h.elementMouseover({row:this,data:a,pos:[a.x,a.y]})}).on("mouseout",function(a){h.elementMouseout({row:this,data:a,pos:[a.x,a.y]})})});return i}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=d3.scale.category20().range(),e=Math.floor(Math.random()*1e4),f=!0,g="No Results found.";childIndent=20,columns=[{key:"key",label:"Name",type:"text"}],tableClass=null,iconOpen="images/grey-plus.png",iconClose="images/grey-minus.png";var h=d3.dispatch("elementClick","elementDblclick","elementMouseover","elementMouseout");i.margin=function(b){if(!arguments.length)return a;a=b;return i},i.width=function(a){if(!arguments.length)return b;b=a;return i},i.height=function(a){if(!arguments.length)return c;c=a;return i},i.color=function(a){if(!arguments.length)return d;d=a,scatter.color(a);return i},i.id=function(a){if(!arguments.length)return e;e=a;return i},i.header=function(a){if(!arguments.length)return f;f=a;return i},i.noResultsText=function(a){if(!arguments.length)return g;g=a;return i},i.columns=function(a){if(!arguments.length)return columns;columns=a;return i},i.tableClass=function(a){if(!arguments.length)return tableClass;tableClass=a;return i};return i},a.models.lineChart=function(){function q(h){h.each(function(j){var r=d3.select(this),s=this,t=(d||parseInt(r.style("width"))||960)-b.left-b.right,u=(e||parseInt(r.style("height"))||400)-b.top-b.bottom,v=r.selectAll("g.wrap.lineChart").data([j]),w=v.enter().append("g").attr("class","wrap nvd3 lineChart").append("g");w.append("g").attr("class","x axis"),w.append("g").attr("class","y axis"),w.append("g").attr("class","linesWrap"),w.append("g").attr("class","legendWrap");var x=v.select("g");f&&(n.width(t),x.select(".legendWrap").datum(j).call(n),b.top!=n.height()&&(b.top=n.height(),u=(e||parseInt(r.style("height"))||400)-b.top-b.bottom),x.select(".legendWrap").attr("transform","translate(0,"+ -b.top+")")),i.width(t).height(u).color(j.map(function(a,b){return a.color||c[b%c.length]}).filter(function(a,b){return!j[b].disabled})),x.attr("transform","translate("+b.left+","+b.top+")");var z=x.select(".linesWrap").datum(j.filter(function(a){return!a.disabled}));d3.transition(z).call(i),l.ticks(t/100).tickSize(-u,0),x.select(".x.axis").attr("transform","translate(0,"+k.range()[0]+")"),d3.transition(x.select(".x.axis")).call(l),m.ticks(u/36).tickSize(-t,0),d3.transition(x.select(".y.axis")).call(m),n.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,j.filter(function(a){return!a.disabled}).length||j.map(function(a){a.disabled=!1,v.selectAll(".series").classed("disabled",!1);return a}),h.transition().call(q)}),i.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],o.tooltipShow(a)}),g&&o.on("tooltipShow",function(a){p(a,s.parentNode)}),i.dispatch.on("elementMouseout.tooltip",function(a){o.tooltipHide(a)}),g&&o.on("tooltipHide",a.tooltip.cleanup)}),q.update=function(){q(h)},q.container=this;return q}var b={top:30,right:20,bottom:50,left:60},c=d3.scale.category20().range(),d=null,e=null,f=!0,g=!0,h=function(a,b,c,d,e){return"<h3>"+a+"</h3>"+"<p>"+c+" at "+b+"</p>"},i=a.models.line(),j=i.xScale(),k=i.yScale(),l=a.models.axis().scale(j).orient("bottom").tickPadding(5),m=a.models.axis().scale(k).orient("left"),n=a.models.legend().height(30),o=d3.dispatch("tooltipShow","tooltipHide"),p=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=l.tickFormat()(i.x()(b.point)),g=m.tickFormat()(i.y()(b.point)),j=h(b.series.key,f,g,b,q);a.tooltip.show([d,e],j)};q.dispatch=o,q.legend=n,q.xAxis=l,q.yAxis=m,d3.rebind(q,i,"x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),q.margin=function(a){if(!arguments.length)return b;b=a;return q},q.width=function(a){if(!arguments.length)return d;d=a;return q},q.height=function(a){if(!arguments.length)return e;e=a;return q},q.color=function(a){if(!arguments.length)return c;c=a,n.color(a);return q},q.showLegend=function(a){if(!arguments.length)return f;f=a;return q},q.tooltips=function(a){if(!arguments.length)return g;g=a;return q},q.tooltipContent=function(a){if(!arguments.length)return h;h=a;return q};return q},a.models.linePlusBarChart=function(){function v(j){j.each(function(o){var w=d3.select(this),y=this,z=(c||parseInt(w.style("width"))||960)-b.left-b.right,A=(d||parseInt(w.style("height"))||400)-b.top-b.bottom,B=o.filter(function(a){return!a.disabled&&a.bar}),C=o.filter(function(a){return!a.disabled&&!a.bar}),D=o.filter(function(a){return!a.disabled&&a.bar}).map(function(a){return a.values.map(function(a,b){return{x:e(a,b),y:f(a,b)}})}),E=o.filter(function(a){return!a.disabled&&!a.bar}).map(function(a){return a.values.map(function(a,b){return{x:e(a,b),y:f(a,b)}})});m.domain(d3.extent(d3.merge(D.concat(E)),function(a){return a.x})).range([0,z]),k.width(z).height(A).color(o.map(function(a,b){return a.color||g[b%g.length]}).filter(function(a,b){return!o[b].disabled&&!o[b].bar})),l.width(z).height(A).color(o.map(function(a,b){return a.color||g[b%g.length]}).filter(function(a,b){return!o[b].disabled&&o[b].bar}));var F=d3.select(this).selectAll("g.wrap.linePlusBar").data([o]),G=F.enter().append("g").attr("class","wrap nvd3 linePlusBar").append("g");G.append("g").attr("class","x axis"),G.append("g").attr("class","y1 axis"),G.append("g").attr("class","y2 axis"),G.append("g").attr("class","barsWrap"),G.append("g").attr("class","linesWrap"),G.append("g").attr("class","legendWrap");var H=F.select("g");h&&(s.width(z),H.select(".legendWrap").datum(o.map(function(a){a.key=a.key+(a.bar?" (left axis)":" (right axis)");return a})).call(s),b.top!=s.height()&&(b.top=s.height(),A=(d||parseInt(w.style("height"))||400)-b.top-b.bottom),H.select(".legendWrap").attr("transform","translate(0,"+ -b.top+")"));var I=H.select(".barsWrap").datum(B.length?B:[{values:[]}]),J=H.select(".linesWrap").datum(C.length?C:[{values:[]}]);d3.transition(I).call(l),d3.transition(J).call(k),H.attr("transform","translate("+b.left+","+b.top+")"),p.ticks(z/100).tickSize(-A,0),H.select(".x.axis").attr("transform","translate(0,"+n.range()[0]+")"),d3.transition(H.select(".x.axis")).call(p),q.ticks(A/36).tickSize(-z,0),d3.transition(H.select(".y1.axis")).call(q),r.ticks(A/36).tickSize(B.length?0:-z,0),H.select(".y2.axis").attr("transform","translate("+m.range()[1]+",0)"),d3.transition(H.select(".y2.axis")).call(r),s.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,o.filter(function(a){return!a.disabled}).length||o.map(function(a){a.disabled=!1,F.selectAll(".series").classed("disabled",!1);return a}),j.transition().call(v)}),k.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],t.tooltipShow(a)}),i&&t.on("tooltipShow",function(a){u(a,y.parentNode)}),k.dispatch.on("elementMouseout.tooltip",function(a){t.tooltipHide(a)}),i&&t.on("tooltipHide",a.tooltip.cleanup),l.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],t.tooltipShow(a)}),i&&t.on("tooltipShow",function(a){u(a,y.parentNode)}),l.dispatch.on("elementMouseout.tooltip",function(a){t.tooltipHide(a)}),i&&t.on("tooltipHide",a.tooltip.cleanup),v.update=function(){j.transition().call(v)},v.container=this});return v}var b={top:30,right:60,bottom:50,left:60},c=null,d=null,e=function(a){return a.x},f=function(a){return a.y},g=d3.scale.category20().range(),h=!0,i=!0,j=function(a,b,c,d,e){return"<h3>"+a+"</h3>"+"<p>"+c+" at "+b+"</p>"},k=a.models.line(),l=a.models.historicalBar(),m=d3.scale.linear(),n=l.yScale(),o=k.yScale(),p=a.models.axis().scale(m).orient("bottom").tickPadding(5),q=a.models.axis().scale(n).orient("left"),r=a.models.axis().scale(o).orient("right"),s=a.models.legend().height(30),t=d3.dispatch("tooltipShow","tooltipHide"),u=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=p.tickFormat()(k.x()(b.point)),g=q.tickFormat()(k.y()(b.point)),h=j(b.series.key,f,g,b,v);a.tooltip.show([d,e],h,b.value<0?"n":"s")};v.dispatch=t,v.legend=s,v.lines=k,v.bars=l,v.xAxis=p,v.yAxis1=q,v.yAxis2=r,d3.rebind(v,k,"size","clipVoronoi"),v.x=function(a){if(!arguments.length)return e;e=a,k.x(a),l.x(a);return v},v.y=function(a){if(!arguments.length)return f;f=a,k.y(a),l.y(a);return v},v.margin=function(a){if(!arguments.length)return b;b=a;return v},v.width=function(a){if(!arguments.length)return c;c=a;return v},v.height=function(a){if(!arguments.length)return d;d=a;return v},v.color=function(a){if(!arguments.length)return g;g=a,s.color(a);return v},v.showLegend=function(a){if(!arguments.length)return h;h=a;return v},v.tooltips=function(a){if(!arguments.length)return i;i=a;return v},v.tooltipContent=function(a){if(!arguments.length)return j;j=a;return v};return v},a.models.lineWithFocusChart=function(){function y(j){j.each(function(z){function O(){var a=w.empty()?p.domain():d3.extent(d3.merge(z.filter(function(a){return!a.disabled}).map(function(a){return a.values})).filter(function(a){return k.x()(a)>=w.extent()[0]&&k.x()(a)<=w.extent()[1]}),k.y());typeof a[0]=="undefined"&&(a=p.domain()),m.domain(w.empty()?o.domain():w.extent()),n.domain(a),k.xDomain(m.domain()),k.yDomain(n.domain())}function N(){O(),K.call(k),J.select(".focus .x.axis").call(q),J.select(".focus .y.axis").call(r)}function M(a){var b=+(a=="e"),c=b?1:-1,d=E/3;return"M"+.5*c+","+d+"A6,6 0 0 "+b+" "+6.5*c+","+(d+6)+"V"+(2*d-6)+"A6,6 0 0 "+b+" "+.5*c+","+2*d+"Z"+"M"+2.5*c+","+(d+8)+"V"+(2*d-8)+"M"+4.5*c+","+(d+8)+"V"+(2*d-8)}var A=d3.select(this),B=this,C=(e||parseInt(A.style("width"))||960)-b.left-b.right,D=(f||parseInt(A.style("height"))||400)-b.top-b.bottom-g,E=g-c.top-c.bottom;w.on("brush",N);var F=A.selectAll("g.wrap.lineWithFocusChart").data([z]),G=F.enter().append("g").attr("class","wrap nvd3 lineWithFocusChart").append("g"),H=G.append("g").attr("class","focus");H.append("g").attr("class","x axis"),H.append("g").attr("class","y axis"),H.append("g").attr("class","linesWrap");var I=G.append("g").attr("class","context");I.append("g").attr("class","x axis"),I.append("g").attr("class","y axis"),I.append("g").attr("class","linesWrap"),I.append("g").attr("class","x brush"),G.append("g").attr("class","legendWrap");var J=F.select("g");h&&(u.width(C),J.select(".legendWrap").datum(z).call(u),b.top!=u.height()&&(b.top=u.height(),D=(f||parseInt(A.style("height"))||400)-b.top-b.bottom),J.select(".legendWrap").attr("transform","translate(0,"+ -b.top+")")),k.width(C).height(D).color(z.map(function(a,b){return a.color||d[b%d.length]}).filter(function(a,b){return!z[b].disabled})),l.width(C).height(E).color(z.map(function(a,b){return a.color||d[b%d.length]}).filter(function(a,b){return!z[b].disabled})),J.attr("transform","translate("+b.left+","+b.top+")");var K=J.select(".focus .linesWrap").datum(z.filter(function(a){return!a.disabled}));d3.transition(K).call(k),q.ticks(C/100).tickSize(-D,0),J.select(".focus .x.axis").attr("transform","translate(0,"+n.range()[0]+")"),d3.transition(J.select(".focus .x.axis")).call(q),r.ticks(D/36).tickSize(-C,0),d3.transition(J.select(".focus .y.axis")).call(r),J.select(".context").attr("transform","translate(0,"+(D+b.bottom+c.top)+")");var L=J.select(".context .linesWrap").datum(z.filter(function(a){return!a.disabled}));d3.transition(L).call(l),gBrush=J.select(".x.brush").call(w),gBrush.selectAll("rect").attr("height",E),gBrush.selectAll(".resize").append("path").attr("d",M),s.tickFormat(q.tickFormat()).ticks(C/100).tickSize(-E,0),J.select(".context .x.axis").attr("transform","translate(0,"+p.range()[0]+")"),d3.transition(J.select(".context .x.axis")).call(s),t.tickFormat(r.tickFormat()).ticks(E/36).tickSize(-C,0),d3.transition(J.select(".context .y.axis")).call(t),O(),u.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,z.filter(function(a){return!a.disabled}).length||z.map(function(a){a.disabled=!1,F.selectAll(".series").classed("disabled",!1);return a}),j.transition().call(y)}),k.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],v.tooltipShow(a)}),i&&v.on("tooltipShow",function(a){x(a,B.parentNode)}),k.dispatch.on("elementMouseout.tooltip",function(a){v.tooltipHide(a)}),i&&v.on("tooltipHide",a.tooltip.cleanup)}),y.update=function(){y(j)},y.container=this;return y}var b={top:30,right:20,bottom:50,left:60},c={top:0,right:20,bottom:20,left:60},d=d3.scale.category20().range(),e=null,f=null,g=100,h=!0,i=!0,j=function(a,b,c,d,e){return"<h3>"+a+"</h3>"+"<p>"+c+" at "+b+"</p>"},k=a.models.line().clipEdge(!0),l=a.models.line().interactive(!1),m=k.xScale(),n=k.yScale(),o=l.xScale(),p=l.yScale(),q=a.models.axis().scale(m).orient("bottom").tickPadding(5),r=a.models.axis().scale(n).orient("left"),s=a.models.axis().scale(m).orient("bottom").tickPadding(5),t=a.models.axis().scale(p).orient("left"),u=a.models.legend().height(30),v=d3.dispatch("tooltipShow","tooltipHide"),w=d3.svg.brush().x(o),x=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=q.tickFormat()(k.x()(b.point)),g=r.tickFormat()(k.y()(b.point)),h=j(b.series.key,f,g,b,y);a.tooltip.show([d,e],h)};y.dispatch=v,y.legend=u,y.xAxis=q,y.yAxis=r,d3.rebind(y,k,"x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),y.margin=function(a){if(!arguments.length)return b;b=a;return y},y.width=function(a){if(!arguments.length)return e;e=a;return y},y.height=function(a){if(!arguments.length)return f;f=a;return y},y.color=function(a){if(!arguments.length)return d;d=a,u.color(a);return y},y.showLegend=function(a){if(!arguments.length)return h;h=a;return y},y.tooltips=function(a){if(!arguments.length)return i;i=a;return y},y.tooltipContent=function(a){if(!arguments.length)return j;j=a;return y};return y},a.models.multiBar=function(){function s(t){t.each(function(u){var v=b-a.left-a.right,w=c-a.top-a.bottom;n=n||p,o=o||q,i&&(u=d3.layout.stack().offset("zero").values(function(a){return a.values}).y(f)(u)),u=u.map(function(a,b){a.values=a.values.map(function(a){a.series=b;return a});return a});var z=l&&m?[]:u.map(function(a){return a.values.map(function(a,b){return{x:e(a,b),y:f(a,b),y0:a.y0}})});p.domain(d3.merge(z).map(function(a){return a.x})).rangeBands([0,v],.1),q.domain(m||d3.extent(d3.merge(z).map(function(a){return a.y+(i?a.y0:0)}).concat(g))).range([w,0]);var A=d3.select(this).selectAll("g.wrap.multibar").data([u]),B=A.enter().append("g").attr("class","wrap nvd3 multibar"),C=B.append("defs"),D=B.append("g");D.append("g").attr("class","groups");var E=A.select("g");A.attr("transform","translate("+a.left+","+a.top+")"),C.append("clipPath").attr("id","edge-clip-"+d).append("rect"),A.select("#edge-clip-"+d+" rect").attr("width",v).attr("height",w),E.attr("clip-path",h?"url(#edge-clip-"+d+")":"");var F=A.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});F.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(F.exit()).selectAll("rect.bar").delay(function(a,b){return b*k/u[0].values.length}).attr("y",function(a){return i?o(a.y0):o(0)}).attr("height",0).remove(),F.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return j[b%j.length]}).style("stroke",function(a,b){return j[b%j.length]}),d3.transition(F).style("stroke-opacity",1).style("fill-opacity",.75);var G=F.selectAll("rect.bar").data(function(a){return a.values});G.exit().remove();var H=G.enter().append("rect").attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("x",function(a,b,c){return i?0:c*p.rangeBand()/u.length}).attr("y",function(a){return o(i?a.y0:0)}).attr("height",0).attr("width",p.rangeBand()/(i?1:u.length)).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),r.elementMouseover({value:f(a,b),point:a,series:u[a.series],pos:[p(e(a,b))+p.rangeBand()*(i?u.length/2:a.series+.5)/u.length,q(f(a,b)+(i?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),r.elementMouseout({value:f(a,b),point:a,series:u[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){r.elementClick({value:f(a,b),point:a,series:u[a.series],pos:[p(e(a,b))+p.rangeBand()*(i?u.length/2:a.series+.5)/u.length,q(f(a,b)+(i?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(a,b){r.elementDblClick({value:f(a,b),point:a,series:u[a.series],pos:[p(e(a,b))+p.rangeBand()*(i?u.length/2:a.series+.5)/u.length,q(f(a,b)+(i?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()});G.attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("transform",function(a,b){return"translate("+p(e(a,b))+",0)"}),i?d3.transition(G).delay(function(a,b){return b*k/u[0].values.length}).attr("y",function(a,b){return q(f(a,b)+(i?a.y0:0))}).attr("height",function(a,b){return Math.abs(q(a.y+(i?a.y0:0))-q(i?a.y0:0))}).each("end",function(){d3.transition(d3.select(this)).attr("x",function(a,b){return i?0:a.series*p.rangeBand()/u.length}).attr("width",p.rangeBand()/(i?1:u.length))}):d3.transition(G).delay(function(a,b){return b*k/u[0].values.length}).attr("x",function(a,b){return a.series*p.rangeBand()/u.length}).attr("width",p.rangeBand()/u.length).each("end",function(){d3.transition(d3.select(this)).attr("y",function(a,b){return f(a,b)<0?q(0):q(f(a,b))}).attr("height",function(a,b){return Math.abs(q(f(a,b))-q(0))})}),s.update=function(){t.transition().call(s)},n=p.copy(),o=q.copy()});return s}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=Math.floor(Math.random()*1e4),e=function(a){return a.x},f=function(a){return a.y},g=[0],h=!0,i=!1,j=d3.scale.category20().range(),k=1200,l,m,n,o,p=d3.scale.ordinal(),q=d3.scale.linear(),r=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");s.dispatch=r,s.x=function(a){if(!arguments.length)return e;e=a;return s},s.y=function(a){if(!arguments.length)return f;f=a;return s},s.margin=function(b){if(!arguments.length)return a;a=b;return s},s.width=function(a){if(!arguments.length)return b;b=a;return s},s.height=function(a){if(!arguments.length)return c;c=a;return s},s.xScale=function(a){if(!arguments.length)return p;p=a;return s},s.yScale=function(a){if(!arguments.length)return q;q=a;return s},s.xDomain=function(a){if(!arguments.length)return l;l=a;return s},s.yDomain=function(a){if(!arguments.length)return m;m=a;return s},s.forceY=function(a){if(!arguments.length)return g;g=a;return s},s.stacked=function(a){if(!arguments.length)return i;i=a;return s},s.clipEdge=function(a){if(!arguments.length)return h;h=a;return s},s.color=function(a){if(!arguments.length)return j;j=a;return s},s.id=function(a){if(!arguments.length)return d;d=a;return s},s.delay=function(a){if(!arguments.length)return k;k=a;return s};return s},a.models.multiBarChart=function(){function t(i){i.each(function(k){var u=d3.select(this),v=this,w=(c||parseInt(u.style("width"))||960)-b.left-b.right,x=(d||parseInt(u.style("height"))||400)-b.top-b.bottom,z=u.selectAll("g.wrap.multiBarWithLegend").data([k]),A=z.enter().append("g").attr("class","wrap nvd3 multiBarWithLegend").append("g");A.append("g").attr("class","x axis"),A.append("g").attr("class","y axis"),A.append("g").attr("class","barsWrap"),A.append("g").attr("class","legendWrap"),A.append("g").attr("class","controlsWrap");var B=z.select("g");g&&(o.width(w/2),B.select(".legendWrap").datum(k).call(o),b.top!=o.height()&&(b.top=o.height(),x=(d||parseInt(u.style("height"))||400)-b.top-b.bottom),B.select(".legendWrap").attr("transform","translate("+w/2+","+ -b.top+")")),j.width(w).height(x).color(k.map(function(a,b){return a.color||e[b%e.length]}).filter(function(a,b){return!k[b].disabled})),f&&(p.width(180).color(["#444","#444","#444"]),B.select(".controlsWrap").datum(s).attr("transform","translate(0,"+ -b.top+")").call(p)),B.attr("transform","translate("+b.left+","+b.top+")");var C=B.select(".barsWrap").datum(k.filter(function(a){return!a.disabled}));d3.transition(C).call(j),m.ticks(w/100).tickSize(-x,0),B.select(".x.axis").attr("transform","translate(0,"+l.range()[0]+")"),d3.transition(B.select(".x.axis")).call(m);var D=B.select(".x.axis").selectAll("g");D.selectAll("line, text").style("opacity",1),D.filter(function(a,b){return b%Math.ceil(k[0].values.length/(w/100))!==0}).selectAll("line, text").style("opacity",0),n.ticks(x/36).tickSize(-w,0),d3.transition(B.select(".y.axis")).call(n),o.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,k.filter(function(a){return!a.disabled}).length||k.map(function(a){a.disabled=!1,z.selectAll(".series").classed("disabled",!1);return a}),i.transition().call(t)}),p.dispatch.on("legendClick",function(a,b){if(!!a.disabled){s=s.map(function(a){a.disabled=!0;return a}),a.disabled=!1;switch(a.key){case"Grouped":j.stacked(!1);break;case"Stacked":j.stacked(!0)}i.transition().call(t)}}),j.dispatch.on("elementMouseover.tooltip2",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],q.tooltipShow(a)}),h&&q.on("tooltipShow",function(a){r(a,v.parentNode)}),j.dispatch.on("elementMouseout.tooltip",function(a){q.tooltipHide(a)}),h&&q.on("tooltipHide",a.tooltip.cleanup),t.update=function(){i.transition().call(t)},t.container=this});return t}var b={top:30,right:20,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!0,g=!0,h=!0,i=function(a,b,c,d,e){return"<h3>"+a+"</h3>"+"<p>"+c+" on "+b+"</p>"},j=a.models.multiBar().stacked(!1),k=j.xScale(),l=j.yScale(),m=a.models.axis().scale(k).orient("bottom").highlightZero(!1),n=a.models.axis().scale(l).orient("left"),o=a.models.legend().height(30),p=a.models.legend().height(30),q=d3.dispatch("tooltipShow","tooltipHide");m.tickFormat(function(a){return a}),n.tickFormat(d3.format(",.1f"));var r=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=m.tickFormat()(j.x()(b.point)),g=n.tickFormat()(j.y()(b.point)),h=i(b.series.key,f,g,b,t);a.tooltip.show([d,e],h,b.value<0?"n":"s")},s=[{key:"Grouped"},{key:"Stacked",disabled:!0}];t.dispatch=q,t.legend=o,t.xAxis=m,t.yAxis=n,d3.rebind(t,j,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id","stacked"),t.margin=function(a){if(!arguments.length)return b;b=a;return t},t.width=function(a){if(!arguments.length)return c;c=a;return t},t.height=function(a){if(!arguments.length)return d;d=a;return t},t.color=function(a){if(!arguments.length)return e;e=a,o.color(a);return t},t.showControls=function(a){if(!arguments.length)return f;f=a;return t},t.showLegend=function(a){if(!arguments.length)return g;g=a;return t};return t},a.models.multiBarHorizontal=function(){function v(d){d.each(function(p){var w=b-a.left-a.right,z=c-a.top-a.bottom;l&&(p=d3.layout.stack().offset("zero").values(function(a){return a.values}).y(h)(p)),p=p.map(function(a,b){a.values=a.values.map(function(a){a.series=b;return a});return a});var A=q&&r?[]:p.map(function(a){return a.values.map(function(a,b){return{x:g(a,b),y:h(a,b),y0:a.y0}})});e.domain(q||d3.merge(A).map(function(a){return a.x})).rangeBands([0,z],.1),f.domain(r||d3.extent(d3.merge(A).map(function(a){return a.y+(l?a.y0:0)}).concat(i))),m&&!l?f.range([f.domain()[0]<0?n:0,w-(f.domain()[1]>0?n:0)]):f.range([0,w]),s=s||e,t=t||d3.scale.linear().domain(f.domain()).range([f(0),f(0)]);var B=d3.select(this).selectAll("g.wrap.multibarHorizontal").data([p]),C=B.enter().append("g").attr("class","wrap nvd3 multibarHorizontal"),D=C.append("defs"),E=C.append("g");E.append("g").attr("class","groups");var F=B.select("g");B.attr("transform","translate("+a.left+","+a.top+")");var G=B.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});G.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(G.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),G.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return k[b%k.length]}).style("stroke",function(a,b){return k[b%k.length]}),d3.transition(G).style("stroke-opacity",1).style("fill-opacity",.75);var H=G.selectAll("g.bar").data(function(a){return a.values});H.exit().remove();var I=H.enter().append("g").attr("transform",function(a,b,c){return"translate("+t(l?a.y0:0)+","+(l?0:c*e.rangeBand()/p.length+e(g(a,b)))+")"}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),u.elementMouseover({value:h(a,b),point:a,series:p[a.series],pos:[f(h(a,b)+(l?a.y0:0)),e(g(a,b))+e.rangeBand()*(l?p.length/2:a.series+.5)/p.length],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),u.elementMouseout({value:h(a,b),point:a,series:p[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){u.elementClick({value:h(a,b),point:a,series:p[a.series],pos:[e(g(a,b))+e.rangeBand()*(l?p.length/2:a.series+.5)/p.length,f(h(a,b)+(l?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(a,b){u.elementDblClick({value:h(a,b),point:a,series:p[a.series],pos:[e(g(a,b))+e.rangeBand()*(l?p.length/2:a.series+.5)/p.length,f(h(a,b)+(l?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()});I.append("rect").attr("width",0).attr("height",e.rangeBand()/(l?1:p.length)),m&&!l?(I.append("text").attr("text-anchor",function(a,b){return h(a,b)<0?"end":"start"}),H.selectAll("text").attr("y",e.rangeBand()/2).attr("dy","-.5em").text(function(a,b){return o(h(a,b))}),d3.transition(H).selectAll("text").attr("dx",function(a,b){return h(a,b)<0?-4:f(h(a,b))-f(0)+4})):H.selectAll("text").remove(),H.attr("class",function(a,b){return h(a,b)<0?"bar negative":"bar positive"}),l?d3.transition(H).attr("transform",function(a,b){return"translate("+f(a.y0)+","+(l?0:j*e.rangeBand()/p.length)+")"}).selectAll("rect").attr("width",function(a,b){return Math.abs(f(h(a,b)+a.y0)-f(a.y0))}).attr("height",e.rangeBand()):d3.transition(H).attr("transform",function(a,b){return"translate("+(h(a,b)<0?f(h(a,b)):f(0))+","+(a.series*e.rangeBand()/p.length+e(g(a,b)))+")"}).selectAll("rect").attr("height",e.rangeBand()/p.length).attr("width",function(a,b){return Math.abs(f(h(a,b))-f(0))}),v.update=function(){d.transition().call(v)},s=e.copy(),t=f.copy()});return v}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=Math.floor(Math.random()*1e4),e=d3.scale.ordinal(),f=d3.scale.linear(),g=function(a){return a.x},h=function(a){return a.y},i=[0],k=d3.scale.category20().range(),l=!1,m=!1,n=60,o=d3.format(",.2f"),p=1200,q,r,s,t,u=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");v.dispatch=u,v.x=function(a){if(!arguments.length)return g;g=a;return v},v.y=function(a){if(!arguments.length)return h;h=a;return v},v.margin=function(b){if(!arguments.length)return a;a=b;return v},v.width=function(a){if(!arguments.length)return b;b=a;return v},v.height=function(a){if(!arguments.length)return c;c=a;return v},v.xScale=function(a){if(!arguments.length)return e;e=a;return v},v.yScale=function(a){if(!arguments.length)return f;f=a;return v},v.xDomain=function(a){if(!arguments.length)return q;q=a;return v},v.yDomain=function(a){if(!arguments.length)return r;r=a;return v},v.forceY=function(a){if(!arguments.length)return i;i=a;return v},v.stacked=function(a){if(!arguments.length)return l;l=a;return v},v.color=function(a){if(!arguments.length)return k;k=a;return v},v.id=function(a){if(!arguments.length)return d;d=a;return v},v.delay=function(a){if(!arguments.length)return p;p=a;return v},v.showValues=function(a){if(!arguments.length)return m;m=a;return v},v.valueFormat=function(a){if(!arguments.length)return o;o=a;return v},v.valuePadding=function(a){if(!arguments.length)return n;n=a;return v};return v},a.models.multiBarHorizontalChart=function(){function t(i){i.each(function(k){var l=d3.select(this),u=this,v=(c||parseInt(l.style("width"))||960)-b.left-b.right,w=(d||parseInt(l.style("height"))||400)-b.top-b.bottom,x=l.selectAll("g.wrap.multiBarHorizontalChart").data([k]),y=x.enter().append("g").attr("class","wrap nvd3 multiBarHorizontalChart").append("g");y.append("g").attr("class","x axis"),y.append("g").attr("class","y axis"),y.append("g").attr("class","barsWrap"),y.append("g").attr("class","legendWrap"),y.append("g").attr("class","controlsWrap"),b.top=o.height();var z=x.select("g");g&&(o.width(v/2),z.select(".legendWrap").datum(k).call(o),b.top!=o.height()&&(b.top=o.height(),w=(d||parseInt(l.style("height"))||400)-b.top-b.bottom),z.select(".legendWrap").attr("transform","translate("+v/2+","+ -b.top+")")),j.width(v).height(w).color(k.map(function(a,b){return a.color||e[b%e.length]}).filter(function(a,b){return!k[b].disabled})),f&&(p.width(180).color(["#444","#444","#444"]),z.select(".controlsWrap").datum(s).attr("transform","translate(0,"+ -b.top+")").call(p)),z.attr("transform","translate("+b.left+","+b.top+")");var A=z.select(".barsWrap").datum(k.filter(function(a){return!a.disabled}));d3.transition(A).call(j),m.ticks(w/24).tickSize(-v,0),z.select(".x.axis").transition().duration(0).call(m);var B=z.select(".x.axis").selectAll("g");B.selectAll("line, text").style("opacity",1),n.ticks(v/100).tickSize(-w,0),z.select(".y.axis").attr("transform","translate(0,"+w+")"),d3.transition(z.select(".y.axis")).call(n),o.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,k.filter(function(a){return!a.disabled}).length||k.map(function(a){a.disabled=!1,x.selectAll(".series").classed("disabled",!1);return a}),i.transition().call(t)}),p.dispatch.on("legendClick",function(a,b){if(!!a.disabled){s=s.map(function(a){a.disabled=!0;return a}),a.disabled=!1;switch(a.key){case"Grouped":j.stacked(!1);break;case"Stacked":j.stacked(!0)}i.transition().call(t)}}),j.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],q.tooltipShow(a)}),h&&q.on("tooltipShow",function(a){r(a,u.parentNode)}),j.dispatch.on("elementMouseout.tooltip",function(a){q.tooltipHide(a)}),h&&q.on("tooltipHide",a.tooltip.cleanup),t.update=function(){i.transition().call(t)},t.container=this});return t}var b={top:30,right:20,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!0,g=!0,h=!0
,i=function(a,b,c,d,e){return"<h3>"+b+"</h3>"+"<p>"+c+"</p>"},j=a.models.multiBarHorizontal().stacked(!1),k=j.xScale(),l=j.yScale(),m=a.models.axis().scale(k).orient("left").highlightZero(!1).showMaxMin(!1),n=a.models.axis().scale(l).orient("bottom"),o=a.models.legend().height(30),p=a.models.legend().height(30),q=d3.dispatch("tooltipShow","tooltipHide");m.tickFormat(function(a){return a}),n.tickFormat(d3.format(",.1f"));var r=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=m.tickFormat()(j.x()(b.point)),g=n.tickFormat()(j.y()(b.point)),h=i(b.series.key,f,g,b,t);a.tooltip.show([d,e],h,b.value<0?"e":"w")},s=[{key:"Grouped"},{key:"Stacked",disabled:!0}];t.dispatch=q,t.multibar=j,t.legend=o,t.xAxis=m,t.yAxis=n,d3.rebind(t,j,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id","delay","showValues","valueFormat"),t.margin=function(a){if(!arguments.length)return b;b=a;return t},t.width=function(a){if(!arguments.length)return c;c=a;return t},t.height=function(a){if(!arguments.length)return d;d=a;return t},t.color=function(a){if(!arguments.length)return e;e=a,o.color(a);return t},t.showControls=function(a){if(!arguments.length)return f;f=a;return t},t.showLegend=function(a){if(!arguments.length)return g;g=a;return t},t.tooltips=function(a){if(!arguments.length)return h;h=a;return t},t.tooltipContent=function(a){if(!arguments.length)return i;i=a;return t};return t},a.models.pie=function(){function p(m){m.each(function(m){function z(a){a.innerRadius=0;var b=d3.interpolate({startAngle:0,endAngle:0},a);return function(a){return t(b(a))}}function y(a){var b=(a.startAngle+a.endAngle)*90/Math.PI-90;return b>90?b-180:b}var n=d3.select(this).on("click",function(a,b){o.chartClick({data:a,index:b,pos:d3.event,id:h})}),p=n.selectAll("svg.margin").data([m]),q=p.enter();q.append("text").attr("class","title").attr("dy",".91em").attr("text-anchor","start").text(l),q.append("svg").attr("class","margin").attr("x",a.left).attr("y",a.top).style("overflow","visible");var r=p.selectAll("g.wrap").data([m]);r.exit().remove();var s=r.enter();s.append("g").attr("class","wrap").attr("id","wrap-"+h).append("g").attr("class","pie"),r.attr("width",b).attr("height",c).attr("transform","translate("+e+","+e+")");var t=d3.svg.arc().outerRadius(e-e/5);k&&t.innerRadius(e/2);var u=d3.layout.pie().value(function(a){return a[g]}),v=p.select(".pie").selectAll(".slice").data(u);v.exit().remove();var w=v.enter().append("svg:g").attr("class","slice").on("mouseover",function(a,b){d3.select(this).classed("hover",!0),o.tooltipShow({label:a.data[f],value:a.data[g],data:a.data,index:b,pos:[d3.event.pageX,d3.event.pageY],id:h})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),o.tooltipHide({label:a.data[f],value:a.data[g],data:a.data,index:b,id:h})}).on("click",function(a,b){o.elementClick({label:a.data[f],value:a.data[g],data:a.data,index:b,pos:d3.event,id:h}),d3.event.stopPropagation()}).on("dblclick",function(a,b){o.elementDblClick({label:a.data[f],value:a.data[g],data:a.data,index:b,pos:d3.event,id:h}),d3.event.stopPropagation()}),x=w.append("svg:path").attr("class","path").attr("fill",function(a,b){return i(b)});v.select(".path").attr("d",t).transition().ease("bounce").duration(d).attrTween("d",z),j&&(w.append("text"),v.select("text").transition().duration(d).ease("bounce").attr("transform",function(a){a.outerRadius=e+10,a.innerRadius=e+15;return"translate("+t.centroid(a)+")"}).attr("text-anchor","middle").style("font","bold 12px Arial").text(function(a,b){return a.data[f]}))});return p}var a={top:20,right:20,bottom:20,left:20},b=500,c=500,d=2e3,e=Math.min(b-(a.right+a.left),c-(a.top+a.bottom))/2,f="label",g="y",h=Math.floor(Math.random()*1e4),i=d3.scale.category20(),j=!0,k=!1,l="",m=0,n=0,o=d3.dispatch("chartClick","elementClick","elementDblClick","tooltipShow","tooltipHide");p.margin=function(b){if(!arguments.length)return a;a=b;return p},p.width=function(d){if(!arguments.length)return b;a.left+a.right+20>d?b=a.left+a.right+20:b=d,e=Math.min(b-(a.left+a.right),c-(a.top+a.bottom))/2;return p},p.height=function(d){if(!arguments.length)return c;a.top+a.bottom+20>d?c=a.top+a.bottom+20:c=d,e=Math.min(b-(a.left+a.right),c-(a.top+a.bottom))/2;return p},p.animate=function(a){if(!arguments.length)return d;d=a;return p},p.labelField=function(a){if(!arguments.length)return f;f=a;return p},p.dataField=function(a){if(!arguments.length)return g;g=a;return p},p.showLabels=function(a){if(!arguments.length)return j;j=a;return p},p.donut=function(a){if(!arguments.length)return k;k=a;return p},p.title=function(a){if(!arguments.length)return l;l=a;return p},p.id=function(a){if(!arguments.length)return h;h=a;return p},p.dispatch=o;return p},a.models.scatter=function(){function B(C){C.each(function(B){function L(){if(!p)return!1;J.append("g").attr("class","point-paths");var b=d3.merge(B.map(function(a,b){return a.values.map(function(a,c){return[g(j(a,c))*(Math.random()/1e12+1),h(k(a,c))*(Math.random()/1e12+1),b,c]})}));if(r){I.append("clipPath").attr("id","points-clip-"+f);var c=G.select("#points-clip-"+f).selectAll("circle").data(b);c.enter().append("circle").attr("r",s),c.exit().remove(),c.attr("cx",function(a){return a[0]}).attr("cy",function(a){return a[1]}),G.select(".point-paths").attr("clip-path","url(#points-clip-"+f+")")}var d=d3.geom.voronoi(b).map(function(a,c){return{data:a,series:b[c][2],point:b[c][3]}}),e=G.select(".point-paths").selectAll("path").data(d);e.enter().append("path").attr("class",function(a,b){return"path-"+b}),e.exit().remove(),e.attr("d",function(a){return"M"+a.data.join(",")+"Z"}).on("click",function(b){var c=B[b.series],d=c.values[b.point];w.elementClick({point:d,series:c,pos:[g(j(d,b.point))+a.left,h(k(d,b.point))+a.top],seriesIndex:b.series,pointIndex:b.point})}).on("mouseover",function(b){var c=B[b.series],d=c.values[b.point];w.elementMouseover({point:d,series:c,pos:[g(j(d,b.point))+a.left,h(k(d,b.point))+a.top],seriesIndex:b.series,pointIndex:b.point})}).on("mouseout",function(a,b){w.elementMouseout({point:B[a.series].values[a.point],series:B[a.series],seriesIndex:a.series,pointIndex:a.point})}),w.on("elementMouseover.point",function(a){d3.select(".chart-"+f+" .series-"+a.seriesIndex+" .point-"+a.pointIndex).classed("hover",!0)}),w.on("elementMouseout.point",function(a){d3.select(".chart-"+f+" .series-"+a.seriesIndex+" .point-"+a.pointIndex).classed("hover",!1)})}var C=b-a.left-a.right,D=c-a.top-a.bottom,E=d3.select(this);x=x||g,y=y||h,z=z||i,B=B.map(function(a,b){a.values=a.values.map(function(a){a.series=b;return a});return a});var F=t&&u&&v?[]:B.map(function(a){return a.values.map(function(a,b){return{x:j(a,b),y:k(a,b),size:l(a,b)}})});g.domain(t||d3.extent(d3.merge(F).map(function(a){return a.x}).concat(m))).range([0,C]),h.domain(u||d3.extent(d3.merge(F).map(function(a){return a.y}).concat(n))).range([D,0]),i.domain(v||d3.extent(d3.merge(F).map(function(a){return a.size}).concat(o))).range([16,256]);var G=E.selectAll("g.wrap.scatter").data([B]),H=G.enter().append("g").attr("class","wrap nvd3 scatter chart-"+f),I=H.append("defs"),J=H.append("g"),K=G.select("g");J.append("g").attr("class","groups"),G.attr("transform","translate("+a.left+","+a.top+")"),I.append("clipPath").attr("id","edge-clip-"+f).append("rect"),G.select("#edge-clip-"+f+" rect").attr("width",C).attr("height",D),K.attr("clip-path",q?"url(#edge-clip-"+f+")":"");var M=G.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});M.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(M.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),M.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}),d3.transition(M).style("fill",function(a,b){return d[b%d.length]}).style("stroke",function(a,b){return d[b%d.length]}).style("stroke-opacity",1).style("fill-opacity",.5);var N=M.selectAll("path.point").data(function(a){return a.values});N.enter().append("path").attr("transform",function(a,b){return"translate("+x(j(a,b))+","+y(k(a,b))+")"}).attr("d",d3.svg.symbol().type(function(a,b){return a.shape||e}).size(function(a,b){return i(l(a,b))})),d3.transition(M.exit().selectAll("path.point")).attr("transform",function(a,b){return"translate("+g(j(a,b))+","+h(k(a,b))+")"}).remove(),N.attr("class",function(a,b){return"point point-"+b}),d3.transition(N).attr("transform",function(a,b){return"translate("+g(j(a,b))+","+h(k(a,b))+")"}).attr("d",d3.svg.symbol().type(function(a,b){return a.shape||e}).size(function(a,b){return i(l(a,b))})),clearTimeout(A),A=setTimeout(L,750),x=g.copy(),y=h.copy(),z=i.copy()});return B}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=d3.scale.category20().range(),e="circle",f=Math.floor(Math.random()*1e5),g=d3.scale.linear(),h=d3.scale.linear(),i=d3.scale.linear(),j=function(a){return a.x},k=function(a){return a.y},l=function(a){return a.size},m=[],n=[],o=[],p=!0,q=!1,r=!0,s=function(){return 25},t,u,v,w=d3.dispatch("elementClick","elementMouseover","elementMouseout"),x,y,z,A;B.dispatch=w,B.x=function(a){if(!arguments.length)return j;j=d3.functor(a);return B},B.y=function(a){if(!arguments.length)return k;k=d3.functor(a);return B},B.size=function(a){if(!arguments.length)return l;l=d3.functor(a);return B},B.margin=function(b){if(!arguments.length)return a;a=b;return B},B.width=function(a){if(!arguments.length)return b;b=a;return B},B.height=function(a){if(!arguments.length)return c;c=a;return B},B.xScale=function(a){if(!arguments.length)return g;g=a;return B},B.yScale=function(a){if(!arguments.length)return h;h=a;return B},B.zScale=function(a){if(!arguments.length)return i;i=a;return B},B.xDomain=function(a){if(!arguments.length)return t;t=a;return B},B.yDomain=function(a){if(!arguments.length)return u;u=a;return B},B.sizeDomain=function(a){if(!arguments.length)return v;v=a;return B},B.forceX=function(a){if(!arguments.length)return m;m=a;return B},B.forceY=function(a){if(!arguments.length)return n;n=a;return B},B.forceSize=function(a){if(!arguments.length)return o;o=a;return B},B.interactive=function(a){if(!arguments.length)return p;p=a;return B},B.clipEdge=function(a){if(!arguments.length)return q;q=a;return B},B.clipVoronoi=function(a){if(!arguments.length)return r;r=a;return B},B.clipRadius=function(a){if(!arguments.length)return s;s=a;return B},B.color=function(a){if(!arguments.length)return d;d=a;return B},B.shape=function(a){if(!arguments.length)return e;e=a;return B},B.id=function(a){if(!arguments.length)return f;f=a;return B};return B},a.models.scatterChart=function(){function D(f){f.each(function(g){function J(){if(k){H.select(".point-paths").style("pointer-events","all");return!1}H.select(".background").style("pointer-events","all"),H.select(".point-paths").style("pointer-events","none");var a=d3.mouse(this);p.distortion(j).focus(a[0]),q.distortion(j).focus(a[1]),I.call(r),H.select(".x.axis").call(s),H.select(".y.axis").call(t),H.select(".distributionX").datum(g.filter(function(a){return!a.disabled})).call(w),H.select(".distributionY").datum(g.filter(function(a){return!a.disabled})).call(x)}var m=d3.select(this),n=this,o=(c||parseInt(m.style("width"))||960)-b.left-b.right,E=(d||parseInt(m.style("height"))||400)-b.top-b.bottom;z=z||r.xScale(),A=A||r.yScale();var F=m.selectAll("g.wrap.scatterChart").data([g]),G=F.enter().append("g").attr("class","wrap nvd3 scatterChart chart-"+r.id()).append("g");G.append("rect").attr("class","nvd3 background").attr("width",o).attr("height",E),G.append("g").attr("class","x axis"),G.append("g").attr("class","y axis"),G.append("g").attr("class","scatterWrap"),G.append("g").attr("class","distWrap"),G.append("g").attr("class","legendWrap"),G.append("g").attr("class","controlsWrap");var H=F.select("g");h&&(u.width(o/2),F.select(".legendWrap").datum(g).call(u),b.top!=u.height()&&(b.top=u.height(),E=(d||parseInt(m.style("height"))||400)-b.top-b.bottom),F.select(".legendWrap").attr("transform","translate("+o/2+","+ -b.top+")")),i&&(v.width(180).color(["#444"]),H.select(".controlsWrap").datum(C).attr("transform","translate(0,"+ -b.top+")").call(v)),r.width(o).height(E).color(g.map(function(a,b){return a.color||e[b%e.length]}).filter(function(a,b){return!g[b].disabled})),H.attr("transform","translate("+b.left+","+b.top+")");var I=F.select(".scatterWrap").datum(g.filter(function(a){return!a.disabled}));d3.transition(I).call(r),s.ticks(o/100).tickSize(-E,0),H.select(".x.axis").attr("transform","translate(0,"+q.range()[0]+")"),d3.transition(H.select(".x.axis")).call(s),t.ticks(E/36).tickSize(-o,0),d3.transition(H.select(".y.axis")).call(t),w.width(o).color(g.map(function(a,b){return a.color||e[b%e.length]}).filter(function(a,b){return!g[b].disabled})),G.select(".distWrap").append("g").attr("class","distributionX").attr("transform","translate(0,"+q.range()[0]+")"),H.select(".distributionX").datum(g.filter(function(a){return!a.disabled})).call(w),x.width(E).color(g.map(function(a,b){return a.color||e[b%e.length]}).filter(function(a,b){return!g[b].disabled})),G.select(".distWrap").append("g").attr("class","distributionY").attr("transform","translate(-"+x.size()+",0)"),H.select(".distributionY").datum(g.filter(function(a){return!a.disabled})).call(x),H.select(".background").on("mousemove",J),H.select(".background").on("click",function(){k=!k}),v.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,j=a.disabled?0:2.5,H.select(".background").style("pointer-events",a.disabled?"none":"all"),H.select(".point-paths").style("pointer-events",a.disabled?"all":"none"),a.disabled?(p.distortion(j).focus(0),q.distortion(j).focus(0),I.call(r),H.select(".x.axis").call(s),H.select(".y.axis").call(t)):k=!1,f.transition().call(D)}),u.dispatch.on("legendClick",function(a,b,c){a.disabled=!a.disabled,g.filter(function(a){return!a.disabled}).length||g.map(function(a){a.disabled=!1,F.selectAll(".series").classed("disabled",!1);return a}),f.transition().call(D)}),r.dispatch.on("elementMouseover.tooltip",function(a){d3.select(".chart-"+r.id()+" .series-"+a.seriesIndex+" .distx-"+a.pointIndex).attr("y1",a.pos[1]-E),d3.select(".chart-"+r.id()+" .series-"+a.seriesIndex+" .disty-"+a.pointIndex).attr("x2",a.pos[0]+w.size()),a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],y.tooltipShow(a)}),l&&y.on("tooltipShow",function(a){B(a,n.parentNode)}),r.dispatch.on("elementMouseout.tooltip",function(a){y.tooltipHide(a),d3.select(".chart-"+r.id()+" .series-"+a.seriesIndex+" .distx-"+a.pointIndex).attr("y1",0),d3.select(".chart-"+r.id()+" .series-"+a.seriesIndex+" .disty-"+a.pointIndex).attr("x2",x.size())}),l&&y.on("tooltipHide",a.tooltip.cleanup),z=p.copy(),A=q.copy(),D.update=function(){f.transition().call(D)},D.container=this});return D}var b={top:30,right:20,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!1,g=!1,h=!0,i=!0,j=0,k=!1,l=!0,m=function(a,b,c){return"<strong>"+b+"</strong>"},n=function(a,b,c){return"<strong>"+c+"</strong>"},o=function(a,b,c,d,e){return"<h3>"+a+"</h3>"+"<p>"+c+" at "+b+"</p>"},p=d3.fisheye.scale(d3.scale.linear).distortion(0),q=d3.fisheye.scale(d3.scale.linear).distortion(0),r=a.models.scatter().xScale(p).yScale(q),s=a.models.axis().orient("bottom").scale(p).tickPadding(10),t=a.models.axis().orient("left").scale(q).tickPadding(10),u=a.models.legend().height(30),v=a.models.legend().height(30),w=a.models.distribution().axis("x").scale(p),x=a.models.distribution().axis("y").scale(q),y=d3.dispatch("tooltipShow","tooltipHide"),z,A,B=function(c,d){var e=c.pos[0]+(d.offsetLeft||0),f=q.range()[0]+b.top+(d.offsetTop||0),g=p.range()[0]+b.left+(d.offsetLeft||0),h=c.pos[1]+(d.offsetTop||0),i=s.tickFormat()(r.x()(c.point)),j=t.tickFormat()(r.y()(c.point)),k=m(c.series.key,i,j,c,D),l=n(c.series.key,i,j,c,D);a.tooltip.show([e,f],k,"n",1),a.tooltip.show([g,h],l,"e",1)},C=[{key:"Magnify",disabled:!0}];D.dispatch=y,D.legend=u,D.xAxis=s,D.yAxis=t,d3.rebind(D,r,"interactive","shape","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius","fisheye","fisheyeRadius"),D.margin=function(a){if(!arguments.length)return b;b=a;return D},D.width=function(a){if(!arguments.length)return c;c=a;return D},D.height=function(a){if(!arguments.length)return d;d=a;return D},D.color=function(a){if(!arguments.length)return e;e=a,u.color(a),w.color(a),x.color(a);return D},D.showDistX=function(a){if(!arguments.length)return f;f=a;return D},D.showDistY=function(a){if(!arguments.length)return g;g=a;return D},D.showControls=function(a){if(!arguments.length)return i;i=a;return D},D.showLegend=function(a){if(!arguments.length)return h;h=a;return D},D.fisheye=function(a){if(!arguments.length)return j;j=a;return D},D.tooltips=function(a){if(!arguments.length)return l;l=a;return D},D.tooltipContent=function(a){if(!arguments.length)return o;o=a;return D};return D},a.models.sparkline=function(){function l(d){d.each(function(d){var l=b-a.left-a.right,m=c-a.top-a.bottom;j.domain(h||d3.extent(d,e)).range([0,l]),k.domain(i||d3.extent(d,f)).range([m,0]);var n=d3.select(this).selectAll("g.sparkline").data([d]),o=n.enter().append("g").attr("class","nvd3 sparkline");o.attr("transform","translate("+a.left+","+a.top+")").style("stroke",function(a,b){return a.color||g[b*g.length]});var p=o.selectAll("path").data(function(a){return[a]});p.enter().append("path"),p.exit().remove(),p.attr("d",d3.svg.line().x(function(a,b){return j(e(a,b))}).y(function(a,b){return k(f(a,b))}));var q=o.selectAll("circle.point").data(function(a){return a.filter(function(a,b){return k.domain().indexOf(f(a,b))!=-1||e(a,b)==j.domain()[1]})});q.enter().append("circle").attr("class","point"),q.exit().remove(),q.attr("cx",function(a,b){return j(e(a,b))}).attr("cy",function(a,b){return k(f(a,b))}).attr("r",2).style("stroke",function(a,b){return a.x==j.domain()[1]?"#444":a.y==k.domain()[0]?"#d62728":"#2ca02c"}).style("fill",function(a,b){return a.x==j.domain()[1]?"#444":a.y==k.domain()[0]?"#d62728":"#2ca02c"})});return l}var a={top:0,right:0,bottom:0,left:0},b=400,c=32,d=!0,e=function(a){return a.x},f=function(a){return a.y},g=d3.scale.category20().range(),h,i,j=d3.scale.linear(),k=d3.scale.linear();l.margin=function(b){if(!arguments.length)return a;a=b;return l},l.width=function(a){if(!arguments.length)return b;b=a;return l},l.height=function(a){if(!arguments.length)return c;c=a;return l},l.x=function(a){if(!arguments.length)return e;e=d3.functor(a);return l},l.y=function(a){if(!arguments.length)return f;f=d3.functor(a);return l},l.xDomain=function(a){if(!arguments.length)return h;h=a;return l},l.yDomain=function(a){if(!arguments.length)return i;i=a;return l},l.animate=function(a){if(!arguments.length)return d;d=a;return l};return l},a.models.sparklinePlus=function(){function o(a){a.each(function(a){function w(){var c=d3.event.offsetX-b.left;t.attr("x1",c).attr("x2",c),u.attr("transform",function(a){return"translate("+(c-6)+","+ -b.top+")"}).text(j(Math.round(l.invert(c)))),v.attr("transform",function(a){return"translate("+(c+6)+","+ -b.top+")"}).text(k(g(a[Math.round(l.invert(c))])))}var e=c-b.left-b.right,i=d-b.top-b.bottom;l.domain(d3.extent(a,f)).range([0,e]),m.domain(d3.extent(a,g)).range([i,0]);var o=d3.select(this).selectAll("g.sparklineplus").data([a]),p=o.enter().append("g"),q=p.append("g").attr("class","nvd3 sparklineplus").attr("transform","translate("+b.left+","+b.top+")").style("stroke",function(a,b){return a.color||h[b%h.length]});n.xDomain(l.domain()).yDomain(m.domain()),q.call(n);var r=q.append("g").attr("class","hoverValue"),s=q.append("g").attr("class","hoverArea");r.attr("transform",function(a){return"translate("+l(a)+",0)"});var t=r.append("line").attr("x1",l.range()[1]).attr("y1",-b.top).attr("x2",l.range()[1]).attr("y2",d),u=r.append("text").attr("class","xValue").attr("text-anchor","end").attr("dy",".9em"),v=r.append("text").attr("class","yValue").attr("text-anchor","start").attr("dy",".9em");s.append("rect").attr("width",e).attr("height",i).on("mousemove",w)});return o}var b={top:15,right:40,bottom:3,left:40},c=400,d=50,e=!0,f=function(a){return a.x},g=function(a){return a.y},h=d3.scale.category20().range(),i=Math.floor(Math.random()*1e5),j=d3.format(",r"),k=d3.format(",.2f"),l=d3.scale.linear(),m=d3.scale.linear(),n=a.models.sparkline();o.margin=function(a){if(!arguments.length)return b;b=a;return o},o.width=function(a){if(!arguments.length)return c;c=a,n.width(a-b.left-b.right);return o},o.height=function(a){if(!arguments.length)return d;d=a,n.height(a-b.top-b.bottom);return o},o.x=function(a){if(!arguments.length)return f;f=d3.functor(a),n.x(a);return o},o.y=function(a){if(!arguments.length)return g;g=d3.functor(a),n.y(a);return o},o.id=function(a){if(!arguments.length)return i;i=a;return o},o.animate=function(a){if(!arguments.length)return e;e=a;return o};return o},a.models.stackedArea=function(){function r(a){a.each(function(a){var i=c-b.left-b.right,m=d-b.top-b.bottom;a=a.map(function(a,b){a.values=a.values.map(function(b,c){b.index=c,b.stackedY=a.disabled?0:h(b,c);return b});return a}),a=d3.layout.stack().order(k).offset(j).values(function(a){return a.values}).x(g).y(function(a){return a.stackedY}).out(function(a,b,c){a.display={y:c,y0:b}})(a);var r=d3.select(this).selectAll("g.wrap.stackedarea").data([a]),s=r.enter().append("g").attr("class","wrap nvd3 stackedarea"),t=s.append("defs"),u=s.append("g"),v=r.select("g");u.append("g").attr("class","areaWrap"),n.width(i).height(m).x(g).y(function(a){return a.display.y+a.display.y0}).forceY([0]).color(a.map(function(a,b){return a.color||e[b%e.length]}).filter(function(b,c){return!a[c].disabled})),u.append("g").attr("class","scatterWrap");var w=v.select(".scatterWrap").datum(a.filter(function(a){return!a.disabled}));d3.transition(w).call(n),r.attr("transform","translate("+b.left+","+b.top+")"),t.append("clipPath").attr("id","edge-clip-"+f).append("rect"),r.select("#edge-clip-"+f+" rect").attr("width",i).attr("height",m),v.attr("clip-path",l?"url(#edge-clip-"+f+")":"");var z=d3.svg.area().x(function(a,b){return o(g(a,b))}).y0(function(a){return p(a.display.y0)}).y1(function(a){return p(a.display.y+a.display.y0)}),A=d3.svg.area().x(function(a,b){return o(g(a,b))}).y0(function(a){return p(a.display.y0)}).y1(function(a){return p(a.display.y0)}),B=v.select(".areaWrap").selectAll("path.area").data(function(a){return a});B.enter().append("path").attr("class",function(a,b){return"area area-"+b}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),q.areaMouseover({point:a,series:a.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:b})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),q.areaMouseout({point:a,series:a.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:b})}).on("click",function(a,b){d3.select(this).classed("hover",!1),q.areaClick({point:a,series:a.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:b})}),d3.transition(B.exit()).attr("d",function(a,b){return A(a.values,b)}).remove(),B.style("fill",function(a,b){return a.color||e[b%e.length]}).style("stroke",function(a,b){return a.color||e[b%e.length]}),d3.transition(B).attr("d",function(a,b){return z(a.values,b)}),n.dispatch.on("elementClick.area",function(a){q.areaClick(a)}),n.dispatch.on("elementMouseover.area",function(a){v.select(".area-"+a.seriesIndex).classed("hover",!0)}),n.dispatch.on("elementMouseout.area",function(a){v.select(".area-"+a.seriesIndex).classed("hover",!1)})});return r}var b={top:0,right:0,bottom:0,left:0},c=960,d=500,e=d3.scale.category20().range(),f=Math.floor(Math.random()*1e5),g=function(a){return a.x},h=function(a){return a.y},i="stack",j="zero",k="default",l=!1,m=d3.layout.stack().values(function(a){return a.values}).x(g).y(function(a){return a.stackedY}).out(function(a,b,c){a.display={y:c,y0:b}}),n=a.models.scatter().size(2.2).sizeDomain([2.5]),o=n.xScale(),p=n.yScale(),q=d3.dispatch("tooltipShow","tooltipHide","areaClick","areaMouseover","areaMouseout");r.dispatch=q,r.scatter=n,d3.rebind(r,n,"interactive","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius"),r.x=function(a){if(!arguments.length)return g;g=d3.functor(a);return r},r.y=function(a){if(!arguments.length)return h;h=d3.functor(a);return r},r.margin=function(a){if(!arguments.length)return b;b=a;return r},r.width=function(a){if(!arguments.length)return c;c=a;return r},r.height=function(a){if(!arguments.length)return d;d=a;return r},r.clipEdge=function(a){if(!arguments.length)return l;l=a;return r},r.color=function(a){if(!arguments.length)return e;e=a;return r},r.offset=function(a){if(!arguments.length)return j;j=a;return r},r.order=function(a){if(!arguments.length)return k;k=a;return r},r.style=function(a){if(!arguments.length)return i;i=a;switch(i){case"stack":r.offset("zero"),r.order("default");break;case"stream":r.offset("wiggle"),r.order("inside-out");break;case"expand":r.offset("expand"),r.order("default")}return r},n.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],q.tooltipShow(a)}),n.dispatch.on("elementMouseout.tooltip",function(a){q.tooltipHide(a)});return r},a.models.stackedAreaChart=function(){function t(e){e.each(function(i){var k=d3.select(this),l=this,u=(c||parseInt(k.style("width"))||960)-b.left-b.right,v=(d||parseInt(k.style("height"))||400)-b.top-b.bottom,w=k.selectAll("g.wrap.stackedAreaChart").data([i]),x=w.enter().append("g").attr("class","wrap nvd3 stackedAreaChart").append("g");x.append("g").attr("class","x axis"),x.append("g").attr("class","y axis"),x.append("g").attr("class","stackedWrap"),x.append("g").attr("class","legendWrap"),x.append("g").attr("class","controlsWrap");var y=w.select("g");g&&(o.width(u/2),y.select(".legendWrap").datum(i).call(o),b.top!=o.height()&&(b.top=o.height(),v=(d||parseInt(k.style("height"))||400)-b.top-b.bottom),y.select(".legendWrap").attr("transform","translate("+(u/2-b.left)+","+ -b.top+")")),j.width(u).height(v),f&&(p.width(280).color(["#444","#444","#444"]),y.select(".controlsWrap").datum(r).attr("transform","translate(0,"+ -b.top+")").call(p)),y.attr("transform","translate("+b.left+","+b.top+")");var z=y.select(".stackedWrap").datum(i);d3.transition(z).call(j),m.ticks(u/100).tickSize(-v,0),y.select(".x.axis").attr("transform","translate(0,"+v+")"),d3.transition(y.select(".x.axis")).call(m),n.ticks(j.offset()=="wiggle"?0:v/36).tickSize(-u,0).tickFormat(j.offset()=="expand"?d3.format("%"):d3.format(",.2f")),d3.transition(y.select(".y.axis")).call(n),j.dispatch.on("areaClick.toggle",function(a){i.filter(function(a){return!a.disabled}).length===1?i=i.map(function(a){a.disabled=!1;return a}):i=i.map(function(b,c){b.disabled=c!=a.seriesIndex;return b}),e.transition().call(t)}),o.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,i.filter(function(a){return!a.disabled}).length||i.map(function(a){a.disabled=!1;return a}),e.transition().call(t)}),p.dispatch.on("legendClick",function(a,b){if(!!a.disabled){r=r.map(function(a){a.disabled=!0;return a}),a.disabled=!1;switch(a.key){case"Stacked":j.style("stack");break;case"Stream":j.style("stream");break;case"Expanded":j.style("expand")}e.transition().call(t)}}),j.dispatch.on("tooltipShow",function(a){if(!Math.round(j.y()(a.point)*100)){setTimeout(function(){d3.selectAll(".point.hover").classed("hover",!1)},0);return!1}a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],q.tooltipShow(a)}),h&&q.on("tooltipShow",function(a){s(a,l.parentNode)}),j.dispatch.on("tooltipHide",function(a){q.tooltipHide(a)}),h&&q.on("tooltipHide",a.tooltip.cleanup),t.update=function(){e.transition().call(t)},t.container=this});return t}var b={top:30,right:25,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!0,g=!0,h=!0,i=function(a,b,c,d,e){return"<h3>"+a+"</h3>"+"<p>"+c+" on "+b+"</p>"},j=a.models.stackedArea(),k=j.xScale(),l=j.yScale(),m=a.models.axis().scale(k).orient("bottom").tickPadding(5),n=a.models.axis().scale(l).orient("left"),o=a.models.legend().height(30),p=a.models.legend().height(30),q=d3.dispatch("tooltipShow","tooltipHide"),r=[{key:"Stacked"},{key:"Stream",disabled:!0},{key:"Expanded",disabled:!0}],s=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=m.tickFormat()(j.x()(b.point)),g=n.tickFormat()(j.y()(b.point)),h=i(b.series.key,f,g,b,t);a.tooltip.show([d,e],h,b.value<0?"n":"s")};t.dispatch=q,t.stacked=j,t.xAxis=m,t.yAxis=n,d3.rebind(t,j,"x","y","interactive","offset","order","style","clipEdge","size","forceX","forceY","forceSize"),t.margin=function(a){if(!arguments.length)return b;b=a;return t},t.width=function(a){if(!arguments.length)return getWidth;c=a;return t},t.height=function(a){if(!arguments.length)return getHeight;d=a;return t},t.color=function(a){if(!arguments.length)return e;e=a,o.color(a);return t},t.showControls=function(a){if(!arguments.length)return f;f=a;return t},t.showLegend=function(a){if(!arguments.length)return g;g=a;return t},t.tooltips=function(a){if(!arguments.length)return h;h=a;return t},t.tooltipContent=function(a){if(!arguments.length)return i;i=a;return t};return t}})()