nvd3/nv.d3.min.js

3 lines
93 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 f(g){g.each(function(f){var g=d3.select(this),h=g.selectAll("g.wrap.axis").data([f]),i=h.enter().append("g").attr("class","wrap axis"),j=i.append("g"),k=h.select("g");(e.orient()=="top"||e.orient()=="bottom")&&e.ticks(Math.abs(a.range()[1]-a.range()[0])/100);var l=k.selectAll("text.axislabel").data([b||null]);l.exit().remove();switch(e.orient()){case"top":l.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",0),l.attr("x",a.range()[1]/2);break;case"bottom":l.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",25),l.attr("x",a.range()[1]/2);break;case"right":l.enter().append("text").attr("class","axislabel").attr("transform","rotate(90)").attr("y",-40),l.attr("x",-a.range()[0]/2);if(c){var m=h.selectAll("g.axisMaxMin").data(a.domain());m.enter().append("g").attr("class","axisMaxMin").append("text"),m.exit().remove(),m.attr("transform",function(b,c){return"translate(0,"+a.range()[c]+")"}).select("text").attr("dy",".32em").attr("dx",e.tickPadding()).attr("text-anchor","start").text(function(a,b){return e.tickFormat()(a)})}break;case"left":l.enter().append("text").attr("class","axislabel").attr("transform","rotate(-90)").attr("y",-40),l.attr("x",-a.range()[0]/2);if(c){var m=h.selectAll("g.axisMaxMin").data(a.domain());m.enter().append("g").attr("class","axisMaxMin").append("text"),m.exit().remove(),m.attr("transform",function(b,c){return"translate(0,"+a.range()[c]+")"}).select("text").attr("dy",".32em").attr("dx",-e.tickPadding()).attr("text-anchor","end").text(function(a,b){return e.tickFormat()(a)})}}l.text(function(a){return a}),d3.transition(k).call(e),c&&(e.orient()==="left"||e.orient()==="right")&&k.selectAll("g").filter(function(b,c){return a(b)<8||a(b)>a.range()[0]-8}).remove(),d&&k.selectAll("line.tick").filter(function(a){return!parseFloat(Math.round(a*1e5)/1e6)}).classed("zero",!0)});return f}var a=d3.scale.linear(),b=null,c=!0,d=!0,e=d3.svg.axis().scale(a).orient("bottom").tickFormat(function(a){return a});d3.rebind(f,e,"orient","ticks","tickValues","tickSubdivide","tickSize","tickPadding","tickFormat"),d3.rebind(f,a,"domain","range","rangeBand","rangeBands"),f.axisLabel=function(a){if(!arguments.length)return b;b=a;return f},f.showMaxMin=function(a){if(!arguments.length)return c;c=a;return f},f.highlightZero=function(a){if(!arguments.length)return d;d=a;return f},f.scale=function(b){if(!arguments.length)return a;a=b,e.scale(a),d3.rebind(f,a,"domain","range","rangeBand","rangeBands");return f};return f},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.cumulativeLine=function(){function B(a,b){return b.map(function(b,c){var d=h(b.values[a],a);return{key:b.key,values:b.values.map(function(a,b){return{x:g(a,b),y:(h(a,b)-d)/(1+d)}}),disabled:b.disabled,hover:b.hover}})}function A(a){a.each(function(f){var g=c(),h=d(),x=g-b.left-b.right,y=h-b.top-b.bottom,z=B(u.i,f),C=z.filter(function(a){return!k||!a.disabled}).map(function(a){return a.values});l.domain(d3.extent(d3.merge(C),function(a){return a.x})).range([0,x]),m.domain([0,f[0].values.length-1]).range([0,x]).clamp(!0),n.domain(d3.extent(d3.merge(C),function(a){return a.y})).range([y,0]),s.width(x).height(y).color(f.map(function(a,b){return a.color||e[b%e.length]}).filter(function(a,b){return!f[b].disabled}));var D=d3.select(this).classed("chart-"+i,!0).selectAll("g.wrap").data([z]),E=D.enter().append("g").attr("class","wrap nvd3 cumulativeLine").append("g");E.append("g").attr("class","x axis"),E.append("g").attr("class","y axis"),E.append("g").attr("class","linesWrap"),E.append("g").attr("class","legendWrap"),E.append("g").attr("class","controlsWrap"),b.top=q.height();var F=D.select("g").attr("transform","translate("+b.left+","+b.top+")");q.width(g/2-b.right),F.select(".legendWrap").datum(f).attr("transform","translate("+(g/2-b.left)+","+ -b.top+")").call(q),j&&(r.width(140).color(["#444","#444","#444"]),F.select(".controlsWrap").datum(v).attr("transform","translate(0,"+ -b.top+")").call(r));var G=F.select(".linesWrap").datum(z.filter(function(a){return!a.disabled}));d3.transition(G).call(s);var H=G.selectAll(".indexLine").data([u]);H.enter().append("rect").attr("class","indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).call(w),H.attr("transform",function(a){return"translate("+m(a.i)+",0)"}).attr("height",y),o.domain(l.domain()).range(l.range()).ticks(g/100).tickSize(-y,0),F.select(".x.axis").attr("transform","translate(0,"+n.range()[0]+")"),d3.transition(F.select(".x.axis")).call(o),p.domain(n.domain()).range(n.range()).ticks(h/36).tickSize(-x,0),d3.transition(F.select(".y.axis")).call(p),q.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,f.filter(function(a){return!a.disabled}).length||f.map(function(a){a.disabled=!1,D.selectAll(".series").classed("disabled",!1);return a}),a.transition().call(A)}),r.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,k=!b.disabled,a.transition().call(A)}),s.dispatch.on("elementMouseover.tooltip",function(a){t.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),s.dispatch.on("elementMouseout.tooltip",function(a){t.tooltipHide(a)})});return A}function z(a,b){d3.transition(d3.select(".chart-"+i)).call(A)}function y(a,b){a.x+=d3.event.dx,a.i=Math.round(m.invert(a.x)),d3.select(this).attr("transform","translate("+m(a.i)+",0)")}function x(a,b){}var b={top:30,right:20,bottom:30,left:60},c=function(){return 960},d=function(){return 500},e=d3.scale.category20().range(),f=function(){return 2.5},g=function(a){return a.x},h=function(a){return a.y},i=Math.floor(Math.random()*1e4),j=!0,k=!0,l=d3.scale.linear(),m=d3.scale.linear(),n=d3.scale.linear(),o=a.models.axis().scale(l).orient("bottom"),p=a.models.axis().scale(n).orient("left"),q=a.models.legend().height(30),r=a.models.legend().height(30),s=a.models.line(),t=d3.dispatch("tooltipShow","tooltipHide"),u={i:0,x:0},v=[{key:"Re-scale y-axis"}],w=d3.behavior.drag().on("dragstart",x).on("drag",y).on("dragend",z);A.dispatch=t,A.x=function(a){if(!arguments.length)return g;g=a;return A},A.y=function(a){if(!arguments.length)return h;h=a;return A},A.margin=function(a){if(!arguments.length)return b;b=a;return A},A.width=function(a){if(!arguments.length)return c;c=d3.functor(a);return A},A.height=function(a){if(!arguments.length)return d;d=d3.functor(a);return A},A.color=function(a){if(!arguments.length)return e;e=a,q.color(a);return A},A.dotRadius=function(a){if(!arguments.length)return f;f=d3.functor(a),s.dotRadius=a;return A},A.showRescaleToggle=function(a){if(!arguments.length)return j;j=a;return A},A.xAxis=o,A.yAxis=p;return A},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)};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"),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)}});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),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(k){k.each(function(j){var k=b-(d==="x"?a.left+a.right:a.top+a.bottom),l=d=="x"?"y":"x";i=i||h,h.domain(g||d3.extent(j,e)).range(d=="x"?[0,k]:[k,0]);var m=d3.select(this).selectAll("g.distribution").data([j]),n=m.enter().append("g").attr("class","nvd3 distribution"),o=n.append("g"),p=m.select("g");m.attr("transform","translate("+a.left+","+a.top+")");var q=p.selectAll("g.dist").data(function(a){return a},function(a){return a.key});q.enter().append("g").attr("class",function(a,b){return"dist series-"+b}),q.style("stroke",function(a,b){return f.filter(function(a,b){return j[b]&&!j[b].disabled})[b%f.length]});var r=q.selectAll("line.dist"+d).data(function(a){return a.values});r.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(q.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))}).remove(),r.attr("class",function(a,b){return"dist"+d+" dist"+d+"-"+b}).attr(l+"1",0).attr(l+"2",c),d3.transition(r).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.domain=function(a){if(!arguments.length)return g;g=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,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");r.append("g").attr("class","scatterWrap");var v=q.select(".scatterWrap").datum(a);t.append("g").attr("class","groups"),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))})).remove(),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=j.xScale(),l=j.yScale(),m=k,n=l,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)};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"),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)}});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"),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.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.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)};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"),r=a.models.axis().scale(n).orient("left"),s=a.models.axis().scale(o).orient("bottom"),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)}});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(w){var z=b-a.left-a.right,A=c-a.top-a.bottom;l&&(w=d3.layout.stack().offset("zero").values(function(a){return a.values}).y(h)(w)),w=w.map(function(a,b){a.values=a.values.map(function(a){a.series=b;return a});return a});var B=q&&r?[]:w.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(B).map(function(a){return a.x})).rangeBands([0,A],.1),f.domain(r||d3.extent(d3.merge(B).map(function(a){return a.y+(l?a.y0:0)}).concat(i))),m&&!l?f.range([f.domain()[0]<0?n:0,z-(f.domain()[1]>0?n:0)]):f.range([0,z]),s=s||e,t=t||d3.scale.linear().domain(f.domain()).range([f(0),f(0)]);var C=d3.select(this).selectAll("g.wrap.multibarHorizontal").data([w]),D=C.enter().append("g").attr("class","wrap nvd3 multibarHorizontal"),E=D.append("defs"),F=D.append("g");F.append("g").attr("class","groups");var G=C.select("g");C.attr("transform","translate("+a.left+","+a.top+")");var H=C.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});H.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(H.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),H.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(H).style("stroke-opacity",1).style("fill-opacity",.75);var I=H.selectAll("g.bar").data(function(a){return a.values});I.exit().remove();var J=I.enter().append("g").attr("transform",function(a,b,c){return"translate("+t(l?a.y0:0)+","+(l?0:c*e.rangeBand()/w.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:w[a.series],pos:[f(h(a,b)+(l?a.y0:0)),e(g(a,b))+e.rangeBand()*(l?w.length/2:a.series+.5)/w.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:w[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){u.elementClick({value:h(a,b),point:a,series:w[a.series],pos:[e(g(a,b))+e.rangeBand()*(l?w.length/2:a.series+.5)/w.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:w[a.series],pos:[e(g(a,b))+e.rangeBand()*(l?w.length/2:a.series+.5)/w.length,f(h(a,b)+(l?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()});J.append("rect").attr("width",0).attr("height",e.rangeBand()/(l?1:w.length)),m&&!l?(J.append("text").attr("text-anchor",function(a,b){return h(a,b)<0?"end":"start"}),I.selectAll("text").attr("y",e.rangeBand()/2).attr("dy","-.5em").text(function(a,b){return o(h(a,b))}),d3.transition(I).delay(function(a,b){return b*p/w[0].values.length}).selectAll("text").attr("dx",function(a,b){return h(a,b)<0?-4:f(h(a,b))-f(0)+4})):I.selectAll("text").remove(),I.attr("class",function(a,b){return h(a,b)<0?"bar negative":"bar positive"}),l?d3.transition(I).delay(function(a,b){return b*p/w[0].values.length}).attr("transform",function(a,b){return"translate("+f(a.y0)+","+(l?0:j*e.rangeBand()/w.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(I).delay(function(a,b){return b*p/w[0].values.length}).attr("transform",function(a,b){return"translate("+(h(a,b)<0?f(h(a,b)):f(0))+","+(a.series*e.rangeBand()/w.length+e(g(a,b)))+")"}).selectAll("rect").attr("height",e.rangeBand()/w.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),B.filter(function(a,b){return b%Math.ceil(k[0].values.length/(v/100))!==0}).selectAll("line, text").style("opacity",0),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)}});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),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 y(f){f.each(function(g){var j=d3.select(this),k=this;y.update=function(){f.transition().call(y)};var l=(c||parseInt(j.style("width"))||960)-b.left-b.right,z=(d||parseInt(j.style("height"))||400)-b.top-b.bottom;v=v||m.xScale(),w=w||m.yScale();var A=j.selectAll("g.wrap.scatterChart").data([g]),B=A.enter().append("g").attr("class","wrap nvd3 scatterChart chart-"+m.id()).append("g");B.append("g").attr("class","legendWrap"),B.append("g").attr("class","x axis"),B.append("g").attr("class","y axis"),B.append("g").attr("class","scatterWrap"),B.append("g").attr("class","distWrap");var C=A.select("g");h&&(r.width(l/2),A.select(".legendWrap").datum(g).call(r),b.top!=r.height()&&(b.top=r.height(),z=(d||parseInt(j.style("height"))||400)-b.top-b.bottom),A.select(".legendWrap").attr("transform","translate("+l/2+","+ -b.top+")")),m.width(l).height(z).color(g.map(function(a,b){return a.color||e[b%e.length]}).filter(function(a,b){return!g[b].disabled})),C.attr("transform","translate("+b.left+","+b.top+")");var D=A.select(".scatterWrap").datum(g.filter(function(a){return!a.disabled}));d3.transition(D).call(m),p.ticks(l/100).tickSize(-z,0),C.select(".x.axis").attr("transform","translate(0,"+o.range()[0]+")"),d3.transition(C.select(".x.axis")).call(p),q.ticks(z/36).tickSize(-l,0),d3.transition(C.select(".y.axis")).call(q),s.domain(n.domain()).width(l),B.select(".distWrap").append("g").attr("class","distributionX").attr("transform","translate(0,"+o.range()[0]+")"),C.select(".distributionX").call(s),t.domain(o.domain()).width(z),B.select(".distWrap").append("g").attr("class","distributionY").attr("transform","translate(-"+t.size()+",0)"),C.select(".distributionY").call(t),r.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,A.selectAll(".series").classed("disabled",!1);return a}),f.transition().call(y)}),m.dispatch.on("elementMouseover.tooltip",function(a){d3.select(".chart-"+m.id()+" .series-"+a.seriesIndex+" .distx-"+a.pointIndex).attr("y1",a.pos[1]-z),d3.select(".chart-"+m.id()+" .series-"+a.seriesIndex+" .disty-"+a.pointIndex).attr("x2",a.pos[0]+s.size()),a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],u.tooltipShow(a)}),i&&u.on("tooltipShow",function(a){x(a,k.parentNode)}),m.dispatch.on("elementMouseout.tooltip",function(a){u.tooltipHide(a),d3.select(".chart-"+m.id()+" .series-"+a.seriesIndex+" .distx-"+a.pointIndex).attr("y1",0),d3.select(".chart-"+m.id()+" .series-"+a.seriesIndex+" .disty-"+a.pointIndex).attr("x2",t.size())}),i&&u.on("tooltipHide",a.tooltip.cleanup),v=n.copy(),w=o.copy()});return y}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=function(a,b,c){return"<strong>"+b+"</strong>"},k=function(a,b,c){return"<strong>"+c+"</strong>"},l=function(a,b,c,d,e){return"<h3>"+a+"</h3>"+"<p>"+c+" at "+b+"</p>"},m=a.models.scatter(),n=m.xScale(),o=m.yScale(),p=a.models.axis().orient("bottom").scale(n).tickPadding(10),q=a.models.axis().orient("left").scale(o).tickPadding(10),r=a.models.legend().height(30),s=a.models.distribution().axis("x"),t=a.models.distribution().axis("y"),u=d3.dispatch("tooltipShow","tooltipHide"),v,w,x=function(c,d){var e=c.pos[0]+(d.offsetLeft||0),f=o.range()[0]+b.top+(d.offsetTop||0),g=n.range()[0]+b.left+(d.offsetLeft||0),h=c.pos[1]+(d.offsetTop||0),i=p.tickFormat()(m.x()(c.point)),l=q.tickFormat()(m.y()(c.point)),r=j(c.series.key,i,l,c,y),s=k(c.series.key,i,l,c,y);a.tooltip.show([e,f],r,"n",1),a.tooltip.show([g,h],s,"e",1)};y.dispatch=u,y.legend=r,y.xAxis=p,y.yAxis=q,d3.rebind(y,m,"interactive","shape","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius","fisheye","fisheyeRadius"),y.margin=function(a){if(!arguments.length)return b;b=a;return y},y.width=function(a){if(!arguments.length)return c;c=a;return y},y.height=function(a){if(!arguments.length)return d;d=a;return y},y.color=function(a){if(!arguments.length)return e;e=a,r.color(a),s.color(a),t.color(a);return y},y.showDistX=function(a){if(!arguments.length)return f;f=a;return y},y.showDistY=function(a){if(!arguments.length)return g;g=a;return y},y.showControls=function(a){if(!arguments.length)return showControls;showControls=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 l;l=a;return y};return y},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 q(a){a.each(function(a){var g=JSON.parse(JSON.stringify(a)),i=c-b.left-b.right,q=d-b.top-b.bottom;g=g.map(function(a,b){a.disabled&&(a.values=a.values.map(function(a,b){a._y=a.y||a._y,a.y=0;return a}));return a}),g=d3.layout.stack().offset(j).order(k).values(function(a){return a.values}).y(h)(g);var r=d3.select(this).selectAll("g.wrap.stackedarea").data([g]),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"),m.width(i).height(q).y(function(a){return a.y+a.y0}).forceY([0]).color(g.map(function(a,b){return a.color||e[b%e.length]}).filter(function(a,b){return!g[b].disabled})),u.append("g").attr("class","scatterWrap");var w=v.select(".scatterWrap").datum(g.filter(function(a){return!a.disabled}));d3.transition(w).call(m),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",q),v.attr("clip-path",l?"url(#edge-clip-"+f+")":"");var z=d3.svg.area().x(function(a,b){return n(m.x()(a,b))}).y0(function(a){return o(a.y0)}).y1(function(a){return o(a.y+a.y0)}),A=d3.svg.area().x(function(a,b){return n(m.x()(a,b))}).y0(function(a){return o(a.y0)}).y1(function(a){return o(a.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),p.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),p.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),p.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)}),m.dispatch.on("elementClick.area",function(a){p.areaClick(a)}),m.dispatch.on("elementMouseover.area",function(a){v.select(".area-"+a.seriesIndex).classed("hover",!0)}),m.dispatch.on("elementMouseout.area",function(a){v.select(".area-"+a.seriesIndex).classed("hover",!1)})});return q}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=a.models.scatter().size(2.2).sizeDomain([2.5]),n=m.xScale(),o=m.yScale(),p=d3.dispatch("tooltipShow","tooltipHide","areaClick","areaMouseover","areaMouseout");q.dispatch=p,q.scatter=m,d3.rebind(q,m,"x","interactive","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius"),q.y=function(a){if(!arguments.length)return h;h=d3.functor(a);return q},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.clipEdge=function(a){if(!arguments.length)return l;l=a;return q},q.color=function(a){if(!arguments.length)return e;e=a;return q},q.offset=function(a){if(!arguments.length)return j;j=a;return q},q.order=function(a){if(!arguments.length)return k;k=a;return q},q.style=function(a){if(!arguments.length)return i;i=a;switch(i){case"stack":j="zero",k="default";break;case"stream":j="wiggle",k="inside-out";break;case"expand":j="expand",k="default"}return q},m.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],p.tooltipShow(a)}),m.dispatch.on("elementMouseout.tooltip",function(a){p.tooltipHide(a)});return q},a.models.stackedAreaChart=function(){function t(e){e.each(function(i){var k=d3.select(this),l=this;t.update=function(){e.transition().call(t)};var 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)});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.stackedArea(),k=j.xScale(),l=j.yScale(),m=a.models.axis().scale(k).orient("bottom"),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}})()