nvd3/nv.d3.min.js

3 lines
69 KiB
JavaScript

(function(){function b(a,b){var c=[31,28,31,30,31,30,31,31,30,31,30,31];return a!=2?c[a-1]:b%4!=0?c[1]:b%100==0&&b%400!=0?c[1]:c[1]+1}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}}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 d(b){b=b||1,d.active=!0,a.dispatch.render_start(),setTimeout(function(){var c;for(var e=0;e<b&&(graph=d.queue[e]);e++)c=graph.generate(),typeof graph.callback=="function"&&graph.callback(c),a.graphs.push(c);d.queue.splice(0,e),d.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)}return f.style.left=n+"px",f.style.top=o+"px",f.style.opacity=1,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};return 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),a},a.models.axis=function(){function g(h){return h.each(function(g){e.domain(a).range(b),f.orient(c);var h=d3.select(this).selectAll("text.axislabel").data([d||null]);switch(c){case"top":h.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",0),h.attr("x",b[1]/2);break;case"right":h.enter().append("text").attr("class","axislabel").attr("transform","rotate(90)").attr("y",-40),h.attr("x",-b[0]/2);break;case"bottom":h.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",25),h.attr("x",b[1]/2);break;case"left":h.enter().append("text").attr("class","axislabel").attr("transform","rotate(-90)").attr("y",-40),h.attr("x",-b[0]/2)}h.exit().remove(),h.text(function(a){return a}),d3.transition(d3.select(this)).call(f),d3.select(this).selectAll("line.tick").filter(function(a){return!parseFloat(Math.round(a*1e5)/1e6)}).classed("zero",!0)}),g}var a=[0,1],b=[0,1],c="bottom",d=!1,e=d3.scale.linear(),f=d3.svg.axis().scale(e);return g.orient=function(a){return arguments.length?(c=a,g):c},g.domain=function(b){return arguments.length?(a=b,g):a},g.range=function(a){return arguments.length?(b=a,g):b},g.scale=function(a){return arguments.length?(e=a,f.scale(e),g):e},g.axisLabel=function(a){return arguments.length?(d=a,g):d},d3.rebind(g,f,"ticks","tickSubdivide","tickSize","tickPadding","tickFormat"),g},a.models.bar=function(){function q(r){return r.each(function(q){l.domain(q.map(function(a,b){return a[e]})).rangeRoundBands([0,b-a.left-a.right],.1);var r=d3.min(q,function(a){return a[j]}),s=d3.max(q,function(a){return a[j]}),t=Math.max(-r,s),u=-t;r>=0&&(u=0),m.domain([u,t]).range([c-a.top-a.bottom,0]).nice(),n.ticks(b/100),o.ticks(c/36).tickSize(-(b-a.right-a.left),0);var v=d3.select(this).on("click",function(a,b){p.chartClick({data:a,index:b,pos:d3.event,id:h})}),w=v.selectAll("g.wrap").data([q]),z=w.enter();z.append("text").attr("class","title").attr("dy",".91em").attr("text-anchor","start").text(k),z=z.append("g").attr("class","wrap").attr("id","wrap-"+h).append("g"),z.append("g").attr("class","x axis"),z.append("g").attr("class","y axis"),z.append("g").attr("class","bars"),w.attr("width",b).attr("height",c);var A=w.select("g").attr("transform","translate("+a.left+","+a.top+")"),B=w.select(".bars").selectAll(".bar").data(function(a){return a});B.exit().remove();var C=B.enter().append("svg:rect").attr("class",function(a){return a[j]<0?"bar negative":"bar positive"}).attr("fill",function(a,b){return i(b)}).attr("x",0).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),p.tooltipShow({label:a[e],value:a[j],data:a,index:b,pos:[d3.event.pageX,d3.event.pageY],id:h})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),p.tooltipHide({label:a[e],value:a[j],data:a,index:b,id:h})}).on("click",function(a,b){p.elementClick({label:a[e],value:a[j],data:a,index:b,pos:d3.event,id:h}),d3.event.stopPropagation()}).on("dblclick",function(a,b){p.elementDblClick({label:a[e],value:a[j],data:a,index:b,pos:d3.event,id:h}),d3.event.stopPropagation()});B.attr("class",function(a){return a[j]<0?"bar negative":"bar positive"}).attr("transform",function(a,b){return"translate("+l(a[e])+",0)"}).attr("width",l.rangeBand).order().transition().duration(d).attr("y",function(a){return m(Math.max(0,a[j]))}).attr("height",function(a){return Math.abs(m(a[j])-m(0))}),A.select(".x.axis").attr("transform","translate(0,"+m.range()[0]+")").call(n),f&&A.select(".x.axis").selectAll("text").attr("text-anchor","start").attr("transform",function(a){return"rotate(35)translate("+this.getBBox().height/2+","+"0"+")"}),g||(A.select(".x.axis").selectAll("text").attr("fill","rgba(0,0,0,0)"),A.select(".x.axis").selectAll("line").attr("style","opacity: 0")),A.select(".y.axis").call(o)}),q}var a={top:20,right:10,bottom:80,left:60},b=960,c=500,d=500,e="label",f=!0,g=!0,h=Math.floor(Math.random()*1e4),i=d3.scale.category20(),j="y",k="",l=d3.scale.ordinal(),m=d3.scale.linear(),n=d3.svg.axis().scale(l).orient("bottom"),o=d3.svg.axis().scale(m).orient("left"),p=d3.dispatch("chartClick","elementClick","elementDblClick","tooltipShow","tooltipHide");return q.margin=function(b){return arguments.length?(a=b,q):a},q.width=function(c){return arguments.length?(a.left+a.right+20>c?b=a.left+a.right+20:b=c,q):b},q.height=function(b){return arguments.length?(a.top+a.bottom+20>b?c=a.top+a.bottom+20:c=b,q):c},q.animate=function(a){return arguments.length?(d=a,q):d},q.labelField=function(a){return arguments.length?(e=a,q):e},q.dataField=function(a){return arguments.length?(j=a,q):j},q.id=function(a){return arguments.length?(h=a,q):h},q.rotatedLabel=function(a){return arguments.length?(f=a,q):f},q.showLabels=function(a){return arguments.length?(g=a,q):g},q.title=function(a){return arguments.length?(k=a,q):k},q.xaxis={},d3.rebind(q.xaxis,n,"tickFormat"),q.yaxis={},d3.rebind(q.yaxis,o,"tickFormat"),q.dispatch=p,q},a.models.historicalBar=function(){function r(g){return 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.d3bar").data([g[0].values]),s=r.enter().append("g").attr("class","d3bar"),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))})}),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");return r.dispatch=q,r.x=function(a){return arguments.length?(e=a,r):e},r.y=function(a){return arguments.length?(f=a,r):f},r.margin=function(b){return arguments.length?(a=b,r):a},r.width=function(c){return arguments.length?(a.left+a.right+20>c?b=a.left+a.right+20:b=c,r):b},r.height=function(b){return arguments.length?(a.top+a.bottom+20>b?c=a.top+a.bottom+20:c=b,r):c},r.xDomain=function(a){return arguments.length?(k=a,r):k},r.yDomain=function(a){return arguments.length?(l=a,r):l},r.forceX=function(a){return arguments.length?(g=a,r):g},r.forceY=function(a){return arguments.length?(h=a,r):h},r.clipEdge=function(a){return arguments.length?(i=a,r):i},r.color=function(a){return arguments.length?(j=a,r):j},r.id=function(a){return arguments.length?(d=a,r):d},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");return k.dispatch=j,k.orient=function(c){return arguments.length?(a=c,b=a=="right"||a=="bottom",k):a},k.ranges=function(a){return arguments.length?(d=a,k):d},k.markers=function(a){return arguments.length?(e=a,k):e},k.measures=function(a){return arguments.length?(f=a,k):f},k.width=function(a){return arguments.length?(g=a,k):g},k.height=function(a){return arguments.length?(h=a,k):h},k.tickFormat=function(a){return arguments.length?(i=a,k):i},k.duration=function(a){return arguments.length?(c=a,k):c},k},a.models.cumulativeLine=function(){function t(a,b){}function u(a,b){a.x+=d3.event.dx,a.i=Math.round(k.invert(a.x)),d3.select(this).attr("transform","translate("+k(a.i)+",0)")}function v(a,b){d3.transition(d3.select(".chart-"+i)).call(w)}function w(a){return a.each(function(f){var g=c(),h=d(),t=g-b.left-b.right,u=h-b.top-b.bottom,v=x(r.i,f),z=v.filter(function(a){return!a.disabled}).map(function(a){return a.values});j.domain(d3.extent(d3.merge(z),function(a){return a.x})).range([0,g-b.left-b.right]),k.domain([0,f[0].values.length-1]).range([0,g-b.left-b.right]).clamp(!0),l.domain(d3.extent(d3.merge(z),function(a){return a.y})).range([h-b.top-b.bottom,0]),p.width(g-b.left-b.right).height(h-b.top-b.bottom).color(f.map(function(a,b){return a.color||e[b%10]}).filter(function(a,b){return!f[b].disabled}));var A=d3.select(this).classed("chart-"+i,!0).selectAll("g.wrap").data([v]),B=A.enter().append("g").attr("class","wrap d3cumulativeLine").append("g");B.append("g").attr("class","x axis"),B.append("g").attr("class","y axis"),B.append("g").attr("class","linesWrap"),B.append("g").attr("class","legendWrap"),b.top=o.height();var C=A.select("g").attr("transform","translate("+b.left+","+b.top+")");o.width(g/2-b.right),C.select(".legendWrap").datum(f).attr("transform","translate("+(g/2-b.left)+","+ -b.top+")").call(o);var D=C.select(".linesWrap").datum(v.filter(function(a){return!a.disabled}));d3.transition(D).call(p);var E=D.selectAll(".indexLine").data([r]);E.enter().append("rect").attr("class","indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).call(s),E.attr("transform",function(a){return"translate("+k(a.i)+",0)"}).attr("height",h-b.top-b.bottom),m.domain(j.domain()).range(j.range()).ticks(g/100).tickSize(-(h-b.top-b.bottom),0),C.select(".x.axis").attr("transform","translate(0,"+l.range()[0]+")"),d3.transition(C.select(".x.axis")).call(m),n.domain(l.domain()).range(l.range()).ticks(h/36).tickSize(-(g-b.right-b.left),0),d3.transition(C.select(".y.axis")).call(n),o.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,f.filter(function(a){return!a.disabled}).length||f.map(function(a){return a.disabled=!1,A.selectAll(".series").classed("disabled",!1),a}),a.transition().call(w)}),p.dispatch.on("pointMouseover.tooltip",function(a){q.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),p.dispatch.on("pointMouseout.tooltip",function(a){q.tooltipHide(a)})}),w}function x(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}})}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=d3.scale.linear(),k=d3.scale.linear(),l=d3.scale.linear(),m=a.models.axis().scale(j).orient("bottom"),n=a.models.axis().scale(l).orient("left"),o=a.models.legend().height(30),p=a.models.line(),q=d3.dispatch("tooltipShow","tooltipHide"),r={i:0,x:0},s=d3.behavior.drag().on("dragstart",t).on("drag",u).on("dragend",v);return w.dispatch=q,w.x=function(a){return arguments.length?(g=a,w):g},w.y=function(a){return arguments.length?(h=a,w):h},w.margin=function(a){return arguments.length?(b=a,w):b},w.width=function(a){return arguments.length?(c=d3.functor(a),w):c},w.height=function(a){return arguments.length?(d=d3.functor(a),w):d},w.dotRadius=function(a){return arguments.length?(f=d3.functor(a),p.dotRadius=a,w):f},w.xAxis=m,w.yAxis=n,w},a.models.legend=function(){function f(g){return g.each(function(f){var g=d3.select(this).selectAll("g.legend").data([f]),h=g.enter().append("g").attr("class","legend").append("g"),i=g.select("g").attr("transform","translate("+a.left+","+a.top+")"),j=i.selectAll(".series").data(function(a){return a}),k=j.enter().append("g").attr("class","series").on("mouseover",function(a,b){e.legendMouseover(a,b)}).on("mouseout",function(a,b){e.legendMouseout(a,b)}).on("click",function(a,b){e.legendClick(a,b)});k.append("circle").style("fill",function(a,b){return a.color||d[b%20]}).style("stroke",function(a,b){return a.color||d[b%20]}).style("stroke-width",2).attr("r",5),k.append("text").text(function(a){return a.key}).attr("text-anchor","start").attr("dy",".32em").attr("dx","8"),j.classed("disabled",function(a){return a.disabled}),j.exit().remove();var l=5,m=5,n=0,o;j.attr("transform",function(c,d){var e=d3.select(this).select("text").node().getComputedTextLength()+28;return o=m,b<a.left+a.right+o+e&&(m=o=5,l+=20),m+=e,m>n&&(n=m),"translate("+o+","+l+")"}),i.attr("transform","translate("+(b-a.right-n)+","+a.top+")"),c=a.top+a.bottom+l+15}),f}var a={top:5,right:0,bottom:5,left:10},b=400,c=20,d=d3.scale.category20().range(),e=d3.dispatch("legendClick","legendMouseover","legendMouseout");return f.dispatch=e,f.margin=function(b){return arguments.length?(a=b,f):a},f.width=function(a){return arguments.length?(b=a,f):b},f.height=function(a){return arguments.length?(c=a,f):c},f.color=function(a){return arguments.length?(d=a,f):d},f},a.models.line=function(){function v(a){return a.each(function(a){var m=n&&o?[]:a.map(function(a){return a.values.map(function(a,b){return{x:g(a,b),y:h(a,b)}})}),u=c-b.left-b.right,v=d-b.top-b.bottom;s=s||p,t=t||q,p.domain(n||d3.extent(d3.merge(m).map(function(a){return a.x}).concat(i))).range([0,u]),q.domain(o||d3.extent(d3.merge(m).map(function(a){return a.y}).concat(j))).range([v,0]);var w=d3.select(this).selectAll("g.d3line").data([a]),z=w.enter().append("g").attr("class","d3line"),A=z.append("defs"),B=z.append("g");B.append("g").attr("class","groups"),w.attr("transform","translate("+b.left+","+b.top+")"),l&&(A.append("clipPath").attr("id","edge-clip-"+f).append("rect"),w.select("#edge-clip-"+f+" rect").attr("width",u).attr("height",v),B.attr("clip-path","url(#edge-clip-"+f+")"));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}).style("fill",function(a,b){return e[b%20]}).style("stroke",function(a,b){return e[b%20]}),d3.transition(C).style("stroke-opacity",1).style("fill-opacity",.5);var D=C.selectAll("path").data(function(a,b){return[a.values]});D.enter().append("path").attr("d",d3.svg.line().x(function(a,b){return s(g(a,b))}).y(function(a,b){return t(h(a,b))})),d3.transition(C.exit().selectAll("path")).attr("d",d3.svg.line().x(function(a,b){return p(g(a,b))}).y(function(a,b){return q(h(a,b))})).remove(),d3.transition(D).attr("d",d3.svg.line().x(function(a,b){return p(g(a,b))}).y(function(a,b){return q(h(a,b))})),r.id(f).interactive(k).width(u).height(v).xDomain(p.domain()).yDomain(q.domain()),z.append("g").attr("class","scatterWrap");var E=w.select(".scatterWrap").datum(a);d3.transition(E).call(r),s=p.copy(),t=q.copy()}),v}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=[],j=[],k=!0,l=!1,m=!0,n,o,p=d3.scale.linear(),q=d3.scale.linear(),r=a.models.scatter().size(2.5).sizeDomain([2.5]),s,t,u;return v.dispatch=r.dispatch,d3.rebind(v,r,"size"),v.margin=function(a){return arguments.length?(b=a,v):b},v.width=function(a){return arguments.length?(c=a,v):c},v.height=function(a){return arguments.length?(d=a,v):d},v.x=function(a){return arguments.length?(g=a,r.x(a),v):g},v.y=function(a){return arguments.length?(h=a,r.y(a),v):h},v.xDomain=function(a){return arguments.length?(n=a,v):n},v.yDomain=function(a){return arguments.length?(o=a,v):o},v.forceX=function(a){return arguments.length?(i=a,v):i},v.forceY=function(a){return arguments.length?(j=a,v):j},v.interactive=function(a){return arguments.length?(k=a,v):k},v.clipEdge=function(a){return arguments.length?(l=a,r.clipEdge(a),v):l},v.clipVoronoi=function(a){return arguments.length?(m=a,v):m},v.color=function(a){return arguments.length?(e=a,r.color(a),v):e},v.id=function(a){return arguments.length?(f=a,v):f},v},a.models.linePlusBar=function(){function s(a){return a.each(function(e){var t=c(),u=d(),v=t-b.left-b.right,w=u-b.top-b.bottom,y=e.filter(function(a){return!a.disabled&&a.bar}).map(function(a){return a.values.map(function(a,b){return{x:f(a,b),y:g(a,b)}})}),z=e.filter(function(a){return!a.disabled&&!a.bar}).map(function(a){return a.values.map(function(a,b){return{x:f(a,b),y:g(a,b)}})});j.domain(d3.extent(d3.merge(y.concat(z)),function(a){return a.x})).range([0,v]),k.domain(d3.extent(d3.merge(y),function(a){return a.y})).range([w,0]),l.domain(d3.extent(d3.merge(z),function(a){return a.y})).range([w,0]),q.width(v).height(w).color(e.map(function(a,b){return a.color||h[b%10]}).filter(function(a,b){return!e[b].disabled&&!e[b].bar})),r.width(v).height(w).color(e.map(function(a,b){return a.color||h[b%10]}).filter(function(a,b){return!e[b].disabled&&e[b].bar}));var A=d3.select(this).selectAll("g.wrap").data([e]),B=A.enter().append("g").attr("class","wrap d3linePlusBar").append("g");B.append("g").attr("class","x axis"),B.append("g").attr("class","y1 axis"),B.append("g").attr("class","y2 axis"),B.append("g").attr("class","barsWrap"),B.append("g").attr("class","linesWrap"),B.append("g").attr("class","legendWrap"),p.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,e.filter(function(a){return!a.disabled}).length||e.map(function(a){return a.disabled=!1,A.selectAll(".series").classed("disabled",!1),a}),a.transition().call(s)}),q.dispatch.on("pointMouseover.tooltip",function(a){i.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),q.dispatch.on("pointMouseout.tooltip",function(a){i.tooltipHide(a)}),r.dispatch.on("elementMouseover.tooltip",function(a){i.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),r.dispatch.on("elementMouseout.tooltip",function(a){i.tooltipHide(a)}),b.top=p.height();var C=A.select("g").attr("transform","translate("+b.left+","+b.top+")");p.width(t/2-b.right),C.select(".legendWrap").datum(e.map(function(a){return a.key=a.key+(a.bar?" (left axis)":" (right axis)"),a})).attr("transform","translate("+(t/2-b.left)+","+ -b.top+")").call(p);var D=e.filter(function(a){return!a.disabled&&a.bar}),E=C.select(".barsWrap").datum(D.length?D:[{values:[]}]),F=C.select(".linesWrap").datum(e.filter(function(a){return!a.disabled&&!a.bar}));d3.transition(E).call(r),d3.transition(F).call(q),m.domain(j.domain()).range(j.range()).ticks(t/100).tickSize(-w,0),C.select(".x.axis").attr("transform","translate(0,"+k.range()[0]+")"),d3.transition(C.select(".x.axis")).call(m),n.domain(k.domain()).range(k.range()).ticks(u/36).tickSize(-v,0),d3.transition(C.select(".y1.axis")).call(n),o.domain(l.domain()).range(l.range()).ticks(u/36).tickSize(y.length?0:-v,0),C.select(".y2.axis").attr("transform","translate("+j.range()[1]+",0)"),d3.transition(C.select(".y2.axis")).call(o)}),s}var b={top:30,right:60,bottom:50,left:60},c=function(){return 960},d=function(){return 500},e=function(){return 2.5},f=function(a){return a.x},g=function(a){return a.y},h=d3.scale.category20().range(),i=d3.dispatch("tooltipShow","tooltipHide"),j=d3.scale.linear(),k=d3.scale.linear(),l=d3.scale.linear(),m=a.models.axis().scale(j).orient("bottom"),n=a.models.axis().scale(k).orient("left"),o=a.models.axis().scale(l).orient("right"),p=a.models.legend().height(30),q=a.models.line(),r=a.models.historicalBar();return s.dispatch=i,s.legend=p,s.lines=q,s.bars=r,s.xAxis=m,s.yAxis1=n,s.yAxis2=o,s.x=function(a){return arguments.length?(f=a,q.x(a),r.x(a),s):f},s.y=function(a){return arguments.length?(g=a,q.y(a),r.y(a),s):g},s.margin=function(a){return arguments.length?(b=a,s):b},s.width=function(a){return arguments.length?(c=d3.functor(a),s):c},s.height=function(a){return arguments.length?(d=d3.functor(a),s):d},s.dotRadius=function(a){return arguments.length?(e=d3.functor(a),q.dotRadius=a,s):e},s},a.models.lineWithFocus=function(){function y(a){return a.each(function(k){function K(){L(),H.call(u),D.select(".x.axis").call(p),D.select(".y.axis").call(q)}function L(){var a=x.empty()?o.domain():d3.extent(d3.merge(z).filter(function(a){return i(a)>=x.extent()[0]&&i(a)<=x.extent()[1]}),j);typeof a[0]=="undefined"&&(a=o.domain()),l.domain(x.empty()?n.domain():x.extent()),m.domain(a),u.xDomain(l.domain()),u.yDomain(m.domain())}var z=k.filter(function(a){return!a.disabled}).map(function(a){return a.values}),A=d-b.left-b.right,B=f-b.top-b.bottom,C=g-c.top-c.bottom;n.domain(d3.extent(d3.merge(z),i)).range([0,A]),o.domain(d3.extent(d3.merge(z),j)).range([C,0]),l.domain(x.empty()?n.domain():x.extent()).range([0,A]),m.domain(o.domain()).range([B,0]),x.on("brush",K),u.width(A).height(B).color(k.map(function(a,b){return a.color||h[b%10]}).filter(function(a,b){return!k[b].disabled})),v.width(A).height(C).color(k.map(function(a,b){return a.color||h[b%10]}).filter(function(a,b){return!k[b].disabled})),L();var D=d3.select(this).selectAll("g.wrap").data([k]),E=D.enter().append("g").attr("class","wrap d3lineWithFocus").append("g");E.append("g").attr("class","focus"),E.append("g").attr("class","context"),E.append("g").attr("class","legendWrap");var F=D.select("g");t.width(d/2-b.right),F.select(".legendWrap").datum(k).attr("transform","translate("+A/2+",0)").call(t),b.top=t.height();var G=F.select(".focus").attr("transform","translate("+b.left+","+b.top+")");E.select(".focus").append("g").attr("class","x axis"),E.select(".focus").append("g").attr("class","y axis"),E.select(".focus").append("g").attr("class","focusLines");var H=G.select(".focusLines").datum(k.filter(function(a){return!a.disabled}));d3.transition(H).call(u),p.domain(l.domain()).range(l.range()).ticks(d/100).tickSize(-B,0),G.select(".x.axis").attr("transform","translate(0,"+m.range()[0]+")"),d3.transition(F.select(".x.axis")).call(p),q.domain(m.domain()).range(m.range()).ticks(e/36).tickSize(-A,0),d3.transition(F.select(".y.axis")).call(q);var I=F.select(".context").attr("transform","translate("+c.left+","+f+")");E.select(".context").append("g").attr("class","x2 axis"),E.select(".context").append("g").attr("class","y2 axis"),E.select(".context").append("g").attr("class","contextLines"),E.select(".context").append("g").attr("class","x brush").attr("class","x brush").call(x).selectAll("rect").attr("y",-5).attr("height",g+4);var J=I.select(".contextLines").datum(k.filter(function(a){return!a.disabled}));d3.transition(J).call(v),r.domain(n.domain()).range(n.range()).ticks(d/100).tickSize(-C,0),I.select(".x2.axis").attr("transform","translate(0,"+o.range()[0]+")"),d3.transition(I.select(".x2.axis")).call(r),s.domain(o.domain()).range(o.range()).ticks(C/24).tickSize(-A,0),I.select(".y2.axis"),d3.transition(I.select(".y2.axis")).call(s),t.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,k.filter(function(a){return!a.disabled}).length||k.map(function(a){return a.disabled=!1,D.selectAll(".series").classed("disabled",!1),a}),a.transition().call(y)}),u.dispatch.on("pointMouseover.tooltip",function(a){w.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),u.dispatch.on("pointMouseout.tooltip",function(a){w.tooltipHide(a)})}),y}var b={top:30,right:20,bottom:30,left:60},c={top:0,right:20,bottom:20,left:60},d=960,e=500,f=400,g=100,h=d3.scale.category20().range(),i=function(a){return a.x},j=function(a){return a.y},k=Math.floor(Math.random()*1e4),l=d3.scale.linear(),m=d3.scale.linear(),n=d3.scale.linear(),o=d3.scale.linear(),p=a.models.axis().scale(l).orient("bottom"),q=a.models.axis().scale(m).orient("left"),r=a.models.axis().scale(n).orient("bottom"),s=a.models.axis().scale(o).orient("left"),t=a.models.legend().height(30),u=a.models.line().clipEdge(!0),v=a.models.line().interactive(!1),w=d3.dispatch("tooltipShow","tooltipHide"),x=d3.svg.brush().x(n);return y.dispatch=w,y.x=function(a){return arguments.length?(i=a,u.x(a),v.x(a),y):i},y.y=function(a){return arguments.length?(j=a,u.y(a),v.y(a),y):j},y.margin=function(a){return arguments.length?(b=a,y):b},y.width=function(a){return arguments.length?(d=a,y):d},y.height=function(a){return arguments.length?(e=a,f=a-g,y):e},y.contextHeight=function(a){return arguments.length?(g=a,f=e-a,y):g},y.id=function(a){return arguments.length?(k=a,y):k},y.xTickFormat=function(a){return arguments.length?(p.tickFormat(a),r.tickFormat(a),y):l.tickFormat()},y.yTickFormat=function(a){return arguments.length?(q.tickFormat(a),s.tickFormat(a),y):m.tickFormat()},y.xAxis=p,y.yAxis=q,y},a.models.lineWithLegend=function(){function m(a){return a.each(function(n){var o=n.filter(function(a){return!a.disabled}).map(function(a){return a.values.map(function(a,b){return{x:k.x()(a,b),y:k.y()(a,b)}})}),p=c()-b.left-b.right,q=d()-b.top-b.bottom;f.domain(d3.extent(d3.merge(o).map(function(a){return a.x}).concat(k.forceX))).range([0,p]),g.domain(d3.extent(d3.merge(o).map(function(a){return a.y}).concat(k.forceY))).range([q,0]),k.width(p).height(q).xDomain(f.domain()).yDomain(g.domain()).color(n.map(function(a,b){return a.color||e[b%10]}).filter(function(a,b){return!n[b].disabled}));var r=d3.select(this).selectAll("g.wrap").data([n]),s=r.enter().append("g").attr("class","wrap d3lineWithLegend").append("g");s.append("g").attr("class","x axis"),s.append("g").attr("class","y axis"),s.append("g").attr("class","linesWrap"),s.append("g").attr("class","legendWrap"),b.top=j.height();var t=r.select("g").attr("transform","translate("+b.left+","+b.top+")");j.width(p/2),t.select(".legendWrap"
).datum(n).attr("transform","translate("+p/2+","+ -b.top+")").call(j);var u=t.select(".linesWrap").datum(n.filter(function(a){return!a.disabled}));d3.transition(u).call(k),h.domain(f.domain()).range(f.range()).ticks(p/100).tickSize(-q,0),t.select(".x.axis").attr("transform","translate(0,"+g.range()[0]+")"),d3.transition(t.select(".x.axis")).call(h),i.domain(g.domain()).range(g.range()).ticks(q/36).tickSize(-p,0),d3.transition(t.select(".y.axis")).call(i),j.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,n.filter(function(a){return!a.disabled}).length||n.map(function(a){return a.disabled=!1,r.selectAll(".series").classed("disabled",!1),a}),a.transition().call(m)}),k.dispatch.on("pointMouseover.tooltip",function(a){l.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),k.dispatch.on("pointMouseout.tooltip",function(a){l.tooltipHide(a)})}),m}var b={top:30,right:20,bottom:50,left:60},c=function(){return 960},d=function(){return 500},e=d3.scale.category20().range(),f=d3.scale.linear(),g=d3.scale.linear(),h=a.models.axis().scale(f).orient("bottom"),i=a.models.axis().scale(g).orient("left"),j=a.models.legend().height(30),k=a.models.line(),l=d3.dispatch("tooltipShow","tooltipHide");return m.dispatch=l,m.legend=j,m.xAxis=h,m.yAxis=i,d3.rebind(m,k,"x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),m.margin=function(a){return arguments.length?(b=a,m):b},m.width=function(a){return arguments.length?(c=d3.functor(a),m):c},m.height=function(a){return arguments.length?(d=d3.functor(a),m):d},m},a.models.multiBar=function(){function s(g){return g.each(function(g){j&&(g=d3.layout.stack().offset("zero").values(function(a){return a.values}).y(f)(g));var i=l&&m?[]:g.map(function(a){return a.values.map(function(a,b){return{x:e(a,b),y:f(a,b),y0:a.y0}})}),p=b-a.left-a.right,q=c-a.top-a.bottom;n.domain(d3.merge(i).map(function(a){return a.x})).rangeRoundBands([0,p],.1),o.domain(m||d3.extent(d3.merge(i).map(function(a){return a.y+(a.y0||0)}).concat(h))).range([q,0]);var s=d3.select(this).selectAll("g.d3multibar").data([g]),t=s.enter().append("g").attr("class","d3multibar"),u=t.append("defs"),v=t.append("g");v.append("g").attr("class","groups");var w=s.select("g").attr("transform","translate("+a.left+","+a.top+")"),z=v.append("g").attr("class","shiftWrap"),A=s.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});A.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6).attr("transform",function(a,b){return j?"translate(0,0)":"translate("+b*n.rangeBand(.9)/g.length+",0)"}),d3.transition(A.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),A.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return k[b%10]}).style("stroke",function(a,b){return k[b%10]}),d3.transition(A).attr("transform",function(a,b){return j?"translate(0,0)":"translate("+b*n.rangeBand(.9)/g.length+",0)"}).style("stroke-opacity",1).style("fill-opacity",.5);var B=A.selectAll("rect.bar").data(function(a){return a.values});B.exit().remove();var C=B.enter().append("rect").attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("x",0).attr("y",function(a,b){return o(Math.max(0,f(a,b)))}).attr("y",o(0)).attr("height",0).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),r.elementMouseover({point:a,series:g[0],pos:[n(e(a,b)),o(f(a,b))],pointIndex:b,seriesIndex:0,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),r.elementMouseout({point:a,series:g[0],pointIndex:b,seriesIndex:0,e:d3.event})}).on("click",function(a,b){r.elementClick({value:f(a,b),data:a,index:b,pos:[n(e(a,b)),o(f(a,b))],e:d3.event,id:d}),d3.event.stopPropagation()}).on("dblclick",function(a,b){r.elementDblClick({value:f(a,b),data:a,index:b,pos:[n(e(a,b)),o(f(a,b))],e:d3.event,id:d}),d3.event.stopPropagation()});B.attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("transform",function(a,b){return"translate("+n(e(a,b))+",0)"}).attr("width",n.rangeBand()/(j?1:g.length)),d3.transition(B).attr("y",function(a,b){return j?o(Math.max(0,a.y+a.y0)):o(Math.max(0,f(a,b)))}).attr("height",function(a,b){return Math.abs(o(f(a,b))-o(0))})}),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=[],h=[],i=!0,j=!1,k=d3.scale.category20().range(),l,m,n=d3.scale.ordinal(),o=d3.scale.linear(),p=d3.svg.axis().scale(n).orient("bottom"),q=d3.svg.axis().scale(o).orient("left"),r=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return s.dispatch=r,s.x=function(a){return arguments.length?(e=a,s):e},s.y=function(a){return arguments.length?(f=a,s):f},s.margin=function(b){return arguments.length?(a=b,s):a},s.width=function(a){return arguments.length?(b=a,s):b},s.height=function(a){return arguments.length?(c=a,s):c},s.xDomain=function(a){return arguments.length?(l=a,s):l},s.yDomain=function(a){return arguments.length?(m=a,s):m},s.forceX=function(a){return arguments.length?(g=a,s):g},s.forceY=function(a){return arguments.length?(h=a,s):h},s.stacked=function(a){return arguments.length?(j=a,s):j},s.clipEdge=function(a){return arguments.length?(i=a,s):i},s.color=function(a){return arguments.length?(k=a,s):k},s.id=function(a){return arguments.length?(d=a,s):d},s},a.models.pie=function(){function p(m){return m.each(function(m){function y(a){var b=(a.startAngle+a.endAngle)*90/Math.PI-90;return b>90?b-180:b}function z(a){a.innerRadius=0;var b=d3.interpolate({startAngle:0,endAngle:0},a);return function(a){return t(b(a))}}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){return a.outerRadius=e+10,a.innerRadius=e+15,"translate("+t.centroid(a)+")"}).attr("text-anchor","middle").style("font","bold 12px Arial").text(function(a,b){return a.data[f]}))}),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");return p.margin=function(b){return arguments.length?(a=b,p):a},p.width=function(d){return arguments.length?(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,p):b},p.height=function(d){return arguments.length?(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,p):c},p.animate=function(a){return arguments.length?(d=a,p):d},p.labelField=function(a){return arguments.length?(f=a,p):f},p.dataField=function(a){return arguments.length?(g=a,p):g},p.showLabels=function(a){return arguments.length?(j=a,p):j},p.donut=function(a){return arguments.length?(k=a,p):k},p.title=function(a){return arguments.length?(l=a,p):l},p.id=function(a){return arguments.length?(h=a,p):h},p.dispatch=o,p},a.models.scatter=function(){function A(B){return B.each(function(A){function I(){if(!l)return E.select("#points-clip-"+e).remove(),E.select(".point-paths").remove(),!1;H.append("g").attr("class","point-paths");var b=d3.merge(A.map(function(a,b){return a.values.map(function(a,c){return[s(f(a,c))*(Math.random()/1e12+1),t(g(a,c))*(Math.random()/1e12+1),b,c]})}));if(n){G.append("clipPath").attr("id","points-clip-"+e);var c=E.select("#points-clip-"+e).selectAll("circle").data(b);c.enter().append("circle").attr("r",o),c.exit().remove(),c.attr("cx",function(a){return a[0]}).attr("cy",function(a){return a[1]}),E.select(".point-paths").attr("clip-path","url(#points-clip-"+e+")")}var d=d3.geom.voronoi(b).map(function(a,c){return{data:a,series:b[c][2],point:b[c][3]}}),h=E.select(".point-paths").selectAll("path").data(d);h.enter().append("path").attr("class",function(a,b){return"path-"+b}),h.exit().remove(),h.attr("d",function(a){return"M"+a.data.join(",")+"Z"}).on("click",function(b){var c=A[b.series],d=c.values[b.point];v.pointClick({point:d,series:c,pos:[s(f(d,b.point))+a.left,t(g(d,b.point))+a.top],seriesIndex:b.series,pointIndex:b.point})}).on("mouseover",function(b){var c=A[b.series],d=c.values[b.point];v.pointMouseover({point:d,series:c,pos:[s(f(d,b.point))+a.left,t(g(d,b.point))+a.top],seriesIndex:b.series,pointIndex:b.point})}).on("mouseout",function(a,b){v.pointMouseout({point:A[a.series].values[a.point],series:A[a.series],seriesIndex:a.series,pointIndex:a.point})}),v.on("pointMouseover.point",function(a){E.select(".series-"+a.seriesIndex+" .point-"+a.pointIndex).classed("hover",!0)}),v.on("pointMouseout.point",function(a){E.select(".series-"+a.seriesIndex+" circle.point-"+a.pointIndex).classed("hover",!1)})}var B=p&&q&&r?[]:A.map(function(a){return a.values.map(function(a,b){return{x:f(a,b),y:g(a,b),size:h(a,b)}})}),C=b-a.left-a.right,D=c-a.top-a.bottom;w=w||s,x=x||t,y=y||u,A=A.map(function(a,b){return a.values=a.values.map(function(a){return a.series=b,a}),a}),s.domain(p||d3.extent(d3.merge(B).map(function(a){return a.x}).concat(i))).range([0,C]),t.domain(q||d3.extent(d3.merge(B).map(function(a){return a.y}).concat(j))).range([D,0]),u.domain(r||d3.extent(d3.merge(B).map(function(a){return a.size}).concat(k))).range([2,10]);var E=d3.select(this).selectAll("g.d3scatter").data([A]),F=E.enter().append("g").attr("class","d3scatter"),G=F.append("defs"),H=F.append("g");H.append("g").attr("class","groups"),E.attr("transform","translate("+a.left+","+a.top+")"),m&&(G.append("clipPath").attr("id","edge-clip-"+e).append("rect"),E.select("#edge-clip-"+e+" rect").attr("width",C).attr("height",D),H.attr("clip-path","url(#edge-clip-"+e+")"));var J=E.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});J.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(J.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),J.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover&&!a.disabled}),d3.transition(J).style("fill",function(a,b){return d[b%20]}).style("stroke",function(a,b){return d[b%20]}).style("stroke-opacity",1).style("fill-opacity",.5);var K=J.selectAll("circle.point").data(function(a){return a.values});K.enter().append("circle").attr("cx",function(a,b){return w(f(a,b))}).attr("cy",function(a,b){return x(g(a,b))}).attr("r",function(a,b){return y(h(a,b))}),d3.transition(J.exit().selectAll("circle.point")).attr("cx",function(a,b){return s(f(a,b))}).attr("cy",function(a,b){return t(g(a,b))}).attr("r",function(a,b){return u(h(a,b))}).remove(),K.attr("class",function(a,b){return"point point-"+b}),d3.transition(K).attr("cx",function(a,b){return s(f(a,b))}).attr("cy",function(a,b){return t(g(a,b))}).attr("r",function(a,b){return u(h(a,b))}),clearTimeout(z),z=setTimeout(I,750),w=s.copy(),x=t.copy(),y=u.copy()}),A}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=d3.scale.category20().range(),e=Math.floor(Math.random()*1e5),f=function(a){return a.x},g=function(a){return a.y},h=function(a){return a.size},i=[],j=[],k=[],l=!0,m=!1,n=!0,o=function(){return 25},p,q,r,s=d3.scale.linear(),t=d3.scale.linear(),u=d3.scale.sqrt(),v=d3.dispatch("pointClick","pointMouseover","pointMouseout"),w,x,y,z;return A.dispatch=v,A.x=function(a){return arguments.length?(f=d3.functor(a),A):f},A.y=function(a){return arguments.length?(g=d3.functor(a),A):g},A.size=function(a){return arguments.length?(h=d3.functor(a),A):h},A.margin=function(b){return arguments.length?(a=b,A):a},A.width=function(a){return arguments.length?(b=a,A):b},A.height=function(a){return arguments.length?(c=a,A):c},A.xDomain=function(a){return arguments.length?(p=a,A):p},A.yDomain=function(a){return arguments.length?(q=a,A):q},A.sizeDomain=function(a){return arguments.length?(r=a,A):r},A.forceX=function(a){return arguments.length?(i=a,A):i},A.forceY=function(a){return arguments.length?(j=a,A):j},A.forceSize=function(a){return arguments.length?(k=a,A):k},A.interactive=function(a){return arguments.length?(l=a,A):l},A.clipEdge=function(a){return arguments.length?(m=a,A):m},A.clipVoronoi=function(a){return arguments.length?(n=a,A):n},A.clipRadius=function(a){return arguments.length?(o=a,A):o},A.color=function(a){return arguments.length?(d=a,A):d},A.id=function(a){return arguments.length?(e=a,A):e},A},a.models.scatterWithLegend=function(){function w(a){return a.each(function(e){var f=e.filter(function(a){return!a.disabled}).map(function(a){return a.values.map(function(a,b){return{x:s.x()(a,b),y:s.y()(a,b)}})}),g=c()-b.left-b.right,h=d()-b.top-b.bottom;u=u||n,v=v||o,n.domain(d3.extent(d3.merge(f).map(function(a){return a.x}).concat(s.forceX))).range([0,g]),o.domain(d3.extent(d3.merge(f).map(function(a){return a.y}).concat(s.forceY))).range([h,0]),s.width(g).height(h).xDomain(n.domain()).yDomain(o.domain()).color(e.map(function(a,b){return a.color||k[b%20]}).filter(function(a,b){return!e[b].disabled}));var l=d3.select(this).selectAll("g.wrap").data([e]),m=l.enter().append("g").attr("class","wrap d3scatterWithLegend").append("g");m.append("g").attr("class","legendWrap"),m.append("g").attr("class","x axis"),m.append("g").attr("class","y axis"),m.append("g").attr("class","scatterWrap"),b.top=r.height();var z=l.select("g").attr("transform","translate("+b.left+","+b.top+")");r.width(g/2),l.select(".legendWrap").datum(e).attr("transform","translate("+g/2+","+ -b.top+")").call(r);var A=l.select(".scatterWrap").datum(e.filter(function(a){return!a.disabled}));d3.transition(A).call(s);if(i||j){var B=A.selectAll("g.distribution").data(function(a){return a},function(a){return a.key});B.enter().append("g").attr("class",function(a,b){return"distribution series-"+b}),B.style("stroke",function(a,b){return k.filter(function(a,b){return e[b]&&!e[b].disabled})[b%10]})}if(i){var C=B.selectAll("line.distX").data(function(a){return a.values});C.enter().append("line").attr("x1",function(a,b){return u(s.x()(a,b))}).attr("x2",function(a,b){return u(s.x()(a,b))}),d3.transition(B.exit().selectAll("line.distX")).attr("x1",function(a,b){return n(s.x()(a,b))}).attr("x2",function(a,b){return n(s.x()(a,b))}).remove(),C.attr("class",function(a,b){return"distX distX-"+b}).attr("y1",o.range()[0]).attr("y2",o.range()[0]+8),d3.transition(C).attr("x1",function(a,b){return n(s.x()(a,b))}).attr("x2",function(a,b){return n(s.x()(a,b))})}if(j){var D=B.selectAll("line.distY").data(function(a){return a.values});D.enter().append("line").attr("y1",function(a,b){return v(s.y()(a,b))}).attr("y2",function(a,b){return v(s.y()(a,b))}),d3.transition(B.exit().selectAll("line.distY")).attr("y1",function(a,b){return o(s.y()(a,b))}).attr("y2",function(a,b){return o(s.y()(a,b))}).remove(),D.attr("class",function(a,b){return"distY distY-"+b}).attr("x1",n.range()[0]).attr("x2",n.range()[0]-8),d3.transition(D).attr("y1",function(a,b){return o(s.y()(a,b))}).attr("y2",function(a,b){return o(s.y()(a,b))})}p.domain(n.domain()).range(n.range()).ticks(g/100).tickSize(-h,0),z.select(".x.axis").attr("transform","translate(0,"+o.range()[0]+")"),d3.transition(z.select(".x.axis")).call(p),q.domain(o.domain()).range(o.range()).ticks(h/36).tickSize(-g,0),d3.transition(z.select(".y.axis")).call(q),r.dispatch.on("legendClick",function(b,c,d){b.disabled=!b.disabled,e.filter(function(a){return!a.disabled}).length||e.map(function(a){return a.disabled=!1,l.selectAll(".series").classed("disabled",!1),a}),a.transition().call(w)}),s.dispatch.on("pointMouseover.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("pointMouseout.tooltip",function(a){t.tooltipHide(a)}),s.dispatch.on("pointMouseover.dist",function(a){A.select(".series-"+a.seriesIndex+" .distX-"+a.pointIndex).attr("y1",a.pos[1]),A.select(".series-"+a.seriesIndex+" .distY-"+a.pointIndex).attr("x1",a.pos[0])}),s.dispatch.on("pointMouseout.dist",function(a){A.select(".series-"+a.seriesIndex+" .distX-"+a.pointIndex).attr("y1",o.range()[0]),A.select(".series-"+a.seriesIndex+" .distY-"+a.pointIndex).attr("x1",n.range()[0])}),u=n.copy(),v=o.copy()}),w}var b={top:30,right:20,bottom:50,left:60},c=function(){return 960},d=function(){return 500},e=!0,f=!0,g=!1,h=!1,i=!1,j=!1,k=d3.scale.category20().range(),l=[],m=[],n=d3.scale.linear(),o=d3.scale.linear(),p=a.models.axis().scale(n).orient("bottom").tickPadding(10),q=a.models.axis().scale(o).orient("left").tickPadding(10),r=a.models.legend().height(30),s=a.models.scatter(),t=d3.dispatch("tooltipShow","tooltipHide"),u,v;return w.dispatch=t,w.legend=r,w.xAxis=p,w.yAxis=q,d3.rebind(w,s,"x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id","showDistX","showDistY"),w.margin=function(a){return arguments.length?(b=a,w):b},w.width=function(a){return arguments.length?(c=d3.functor(a),w):c},w.height=function(a){return arguments.length?(d=d3.functor(a),w):d},w.showDistX=function(a){return arguments.length?(i=a,w):i},w.showDistY=function(a){return arguments.length?(j=a,w):j},w},a.models.sparkline=function(){function l(d){return 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","sparkline");o.attr("transform","translate("+a.left+","+a.top+")").style("stroke",function(a,b){return a.color||g[b*2%20]});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"})}),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();return l.margin=function(b){return arguments.length?(a=b,l):a},l.width=function(a){return arguments.length?(b=a,l):b},l.height=function(a){return arguments.length?(c=a,l):c},l.x=function(a){return arguments.length?(e=d3.functor(a),l):e},l.y=function(a){return arguments.length?(f=d3.functor(a),l):f},l.xDomain=function(a){return arguments.length?(h=a,l):h},l.yDomain=function(a){return arguments.length?(i=a,l):i},l.animate=function(a){return arguments.length?(d=a,l):d},l},a.models.sparklinePlus=function(){function o(a){return 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","sparklineplus").attr("transform","translate("+b.left+","+b.top+")").style("stroke",function(a,b){return a.color||h[b%10]});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)}),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();return o.margin=function(a){return arguments.length?(b=a,o):b},o.width=function(a){return arguments.length?(c=a,n.width(a-b.left-b.right),o):c},o.height=function(a){return arguments.length?(d=a,n.height(a-b.top-b.bottom),o):d},o.x=function(a){return arguments.length?(f=d3.functor(a),n.x(a),o):f},o.y=function(a){return arguments.length?(g=d3.functor(a),n.y(a),o):g},o.id=function(a){return arguments.length?(i=a,o):i},o.animate=function(a){return arguments.length?(e=a,o):e},o},a.models.stackedArea=function(){function s(a){return a.each(function(a){var h=JSON.parse(JSON.stringify(a)),s=h.map(function(a){return a.values.map(function(a,b){return{x:f(a,b),y:g(a,b)}})}),t=c-b.left-b.right,u=d-b.top-b.bottom;h=d3.layout.stack().offset(i).order(j).values(function(a){return a.values}).y(g)(h),p.domain(m||d3.extent(d3.merge(s),function(a){return a.x})).range([0,t]),q.domain(n||[0,d3.max(h,function(a){return d3.max(a.values,function(a){return a.y0+a.y})})]).range([u,0]);var v=d3.select(this).selectAll("g.d3stackedarea").data([h]),w=v.enter().append("g").attr("class","d3stackedarea"),z=w.append("defs"),A=w.append("g"),B=v.select("g");A.append("g").attr("class","areaWrap"),v.attr("transform","translate("+b.left+","+b.top+")"),l&&(z.append("clipPath").attr("id","edge-clip-"+id).append("rect"),v.select("#edge-clip-"+id+" rect").attr("width",t).attr("height",u),A.attr("clip-path","url(#edge-clip-"+id+")"));if(k){o.width(t).height(u).xDomain(p.domain()).yDomain(q.domain()).x(f).y(function(a){return a.y+a.y0}).color(a.map(function(a,b){return a.color||e[b%20]}).filter(function(b,c){return!a[c].disabled})),A.append("g").attr("class","scatterWrap");var C=B.select(".scatterWrap").datum(h.filter(function(a){return!a.disabled}));d3.transition(C).call(o)}var D=d3.svg.area().x(function(a,b){return p(f(a,b))}).y0(function(a){return q(a.y0)}).y1(function(a){return q(a.y+a.y0)}),E=d3.svg.area().x(function(a,b){return p(f(a,b))}).y0(function(a){return q(a.y0)}).y1(function(a){return q(a.y0)}),F=B.select(".areaWrap").selectAll("path.area").data(function(a){return a});F.enter().append("path").attr("class",function(a,b){return"area area-"+b}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),r.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),r.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),r.areaClick({point:a,series:a.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:b})}),d3.transition(F.exit()).attr("d",function(a,b){return E(a.values,b)}).remove(),F.style("fill",function(a,b){return e[b%20]}).style("stroke",function(a,b){return e[b%20]}),d3.transition(F).attr("d",function(a,b){return D(a.values,b)}),o.dispatch.on("pointClick.area",function(a){r.areaClick(a)}),o.dispatch.on("pointMouseover.area",function(a){B.select(".area-"+a.seriesIndex).classed("hover",!0)}),o.dispatch.on("pointMouseout.area",function(a){B.select(".area-"+a.seriesIndex).classed("hover",!1)})}),s}var b={top:0,right:0,bottom:0,left:0},c=960,d=500,e=d3.scale.category20().range(),f=function(a){return a.x},g=function(a){return a.y},h="stack",i="zero",j="default",k=!0,l=!1,m,n,o=a.models.scatter().size(2.2).sizeDomain([2.5]),p=d3.scale.linear(),q=d3.scale.linear(),r=d3.dispatch("tooltipShow","tooltipHide","areaClick","areaMouseover","areaMouseout");return s.x=function(a){return arguments.length?(f=d3.functor(a),s):f},s.y=function(a){return arguments.length?(g=d3.functor(a),s):g},s.margin=function(a){return arguments.length?(b=a,s):b},s.width=function(a){return arguments.length?(c=a,s):c},s.height=function(a){return arguments.length?(d=a,s):d},s.interactive=function(a){return arguments.length?(k=a,s):k},s.clipEdge=function(a){return arguments.length?(l=a,s):l},s.color=function(a){return arguments.length?(e=a,s):e},s.offset=function(a){return arguments.length?(i=a,s):i},s.order=function(a){return arguments.length?(j=a,s):j},s.style=function(a){if(!arguments.length)return h;h=a;switch(h){case"stack":i="zero",j="default";break;case"stream":i="wiggle",j="inside-out";break;case"expand":i="expand",j="default"}return s},s.dispatch=r,s.scatter=o,o.dispatch.on("pointMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],r.tooltipShow(a)}),o.dispatch.on("pointMouseout.tooltip",function(a){r.tooltipHide(a)}),s},a.models.stackedAreaWithLegend=function(){function r(a){return a.each(function(e){var s=c(),t=d(),u=s-b.left-b.right,v=t-b.top-b.bottom,w=e.filter(function(a){return!a.disabled}).reduce(function(a,b,c){return b.values.forEach(function(b,d){c||(a[d]={x:i(b,d),y:0}),a[d].y+=j(b,d)}),a},[]);g.domain(d3.extent(d3.merge(w),function(a){return a.x})).range([0,u]),h.domain(o.offset()=="zero"?[0,d3.max(w,function(a){return a.y})]:[0,1]).range([v,0]),o.width(u).height(v).color(f);var z=d3.select(this).selectAll("g.wrap").data([e]),A=z.enter().append("g").attr("class","wrap d3stackedWithLegend").append("g");A.append("g").attr("class","x axis"),A.append("g").attr("class","y axis"),A.append("g").attr("class","stackedWrap"),A.append("g").attr("class","legendWrap"),A.append("g").attr("class","controlsWrap"),b.top=m.height();var B=z.select("g").attr("transform","translate("+b.left+","+b.top+")");m.width(s/2-b.right).color(f),B.select(".legendWrap").datum(e).attr("transform","translate("+(s/2-b.left)+","+ -b.top+")").call(m),n.width(280).color(["#444","#444","#444"]),B.select(".controlsWrap").datum(q).attr("transform","translate(0,"+ -b.top+")").call(n);var C=B.select(".stackedWrap").datum(e);d3.transition(C).call(o),k.domain(g.domain()).range(g.range()).ticks(s/100).tickSize(-v,0),B.select(".x.axis").attr("transform","translate(0,"+v+")"),d3.transition(B.select(".x.axis")).call(k),l.domain(h.domain()).range(h.range()).ticks(o.offset()=="wiggle"?0:t/36).tickSize(-u,0).tickFormat(o.offset()=="zero"?d3.format(",.2f"):d3.format("%")),d3.transition(B.select(".y.axis")).call(l),o.dispatch.on("areaClick.toggle",function(b){e.filter(function(a){return!a.disabled}).length===1?e=e.map(function(a){return a.disabled=!1,a.disabled?a.values.map(function(a){return a._y=a.y,a.y=0,a}):a.values.map(function(a){return a.y=a._y||a.y,a}),a}):e=e.map(function(a,c){return a.disabled=c!=b.seriesIndex,a.disabled?a.values.map(function(a){return a._y=a.y,a.y=0,a}):a.values.map(function(a){return a.y=a._y||a.y,a}),a}),a.transition().call(r)}),m.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,b.disabled?b.values.map(function(a){return a._y=a.y,a.y=0,a}):b.values.map(function(a){return a.y=a._y,a}),e.filter(function(a){return!a.disabled}).length||e.map(function(a){return a.disabled=!1,a.values.map(function(a){return a.y=a._y,a}),a}),a.transition().call(r)}),n.dispatch.on("legendClick",function(b,c){if(!b.disabled)return;q=q.map(function(a){return a.disabled=!0,a}),b.disabled=!1;switch(b.key){case"Stacked":o.style("stack");break;case"Stream":o.style("stream");break;case"Expanded":o.style("expand")}a.transition().call(r)}),o.dispatch.on("tooltipShow",function(a){if(!Math.round(j(a.point)*100))return setTimeout(function(){d3.selectAll(".point.hover").classed("hover",!1)},0),!1;p.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),o.dispatch.on("tooltipHide",function(a){p.tooltipHide(a)})}),r}var b={top:30,right:20,bottom:50,left:60},c=function(){return 960},d=function(){return 500},e=function(){return 2.5},f=d3.scale.category20().range(),g=d3.scale.linear(),h=d3.scale.linear(),i=function(a){return a.x},j=function(a){return a.y},k=a.models.axis().scale(g).orient("bottom"),l=a.models.axis().scale(h).orient("left"),m=a.models.legend().height(30),n=a.models.legend().height(30),o=a.models.stackedArea(),p=d3.dispatch("tooltipShow","tooltipHide"),q=[{key:"Stacked"},{key:"Stream",disabled:!0},{key:"Expanded",disabled:!0}];return r.dispatch=p,d3.rebind(r,o,"interactive"),r.x=function(a){return arguments.length?(i=d3.functor(a),o.x(i),r):i},r.y=function(a){return arguments.length?(j=d3.functor(a),o.y(j),r):j},r.margin=function(a){return arguments.length?(b=a,r):b},r.width=function(a){return arguments.length?(c=d3.functor(a),r):c},r.height=function(a){return arguments.length?(d=d3.functor(a),r):d},r.dotRadius=function(a){return arguments.length?(e=d3.functor(a),o.dotRadius=a,r):e},r.stacked=o,r.xAxis=k,r.yAxis=l,r},a.charts.cumulativeLineChartDaily=function(){function h(){return!b||!c.length?h:(d3.select(b).select("svg").datum(c).transition().duration(d).call(f),h)}var b=null,c=[],d=500,e=function(a,b,c,d,e){return"<h3>"+a+"</h3>"+"<p>"+c+" at "+b+"</p>"},f=a.models.cumulativeLine().x(function(a,b){return b}),g=function(c){var d=document.getElementById(b.substr(1)),g=c.pos[0]+d.offsetLeft,h=c.pos[1]+d.offsetTop,i=f.xAxis.tickFormat(),j=f.yAxis.tickFormat(),k=i(f.x()(c,c.pointIndex)),l=j(f.y()(c.point)),m=e(c.series.key,k,l,c,f);a.tooltip.show([g,h],m)};return f.xAxis.tickFormat(function(a){return d3.time.format("%x")(new Date(c[0].values[a].x))}),f.yAxis.tickFormat(d3.format(",.2%")),h.build=function(){return!b||!c.length?h:(a.addGraph({generate:function(){var a=d3.select(b),e=function(){return parseInt(a.style("width"))},g=function(){return parseInt(a.style("height"))},h=a.append("svg");return f.width(e).height(g),h.attr("width",e()).attr("height",g()).datum(c).transition().duration(d).call(f),f},callback:function(c){c.dispatch.on("tooltipShow",g),c.dispatch.on("tooltipHide",a.tooltip.cleanup),window.onresize=function(){d3.select(b+" svg").attr("width",c.width()()).attr("height",c.height()()).call(c)}}}),h)},h.data=function(a){return arguments.length?(c=a,h):c},h.selector=function(a){return arguments.length?(b=a,h):b},h.duration=function(a){return arguments.length?(d=a,h):d},h.tooltip=function(a){return arguments.length?(e=a,h):e},h.xTickFormat=function(a){return arguments.length?(f.xAxis.tickFormat(typeof a=="function"?a:d3.format(a)),h):f.xAxis.tickFormat()},h.yTickFormat=function(a){return arguments.length?(f.yAxis.tickFormat(typeof a=="function"?a:d3.format(a)),h):f.yAxis.tickFormat()},h.xAxisLabel=function(a){return arguments.length?(f.xAxis.axisLabel(a),h):f.xAxis.axisLabel()},h.yAxisLabel=function(a){return arguments.length?(f.yAxis.axisLabel(a),h):f.yAxis.axisLabel()},d3.rebind(h,f,"x","y"),h.graph=f,h},a.charts.line=function(){function h(){return!b||!c.length?h:(d3.select(b).select("svg").datum(c).transition().duration(d).call(f),h)}var b=null,c=[],d=500,e=function(a,b,c,d,e){return"<h3>"+a+"</h3>"+"<p>"+
c+" at "+b+"</p>"},f=a.models.lineWithLegend(),g=function(c){var d=document.getElementById(b.substr(1)),g=c.pos[0]+d.offsetLeft,h=c.pos[1]+d.offsetTop,i=f.xAxis.tickFormat(),j=f.yAxis.tickFormat(),k=i(f.x()(c.point)),l=j(f.y()(c.point)),m=e(c.series.key,k,l,c,f);a.tooltip.show([g,h],m)};return f.xAxis.tickFormat(d3.format(",r")),f.yAxis.tickFormat(d3.format(",.2f")),h.build=function(){return!b||!c.length?h:(a.addGraph({generate:function(){var a=d3.select(b),e=function(){return parseInt(a.style("width"))},g=function(){return parseInt(a.style("height"))},h=a.append("svg");return f.width(e).height(g),h.attr("width",e()).attr("height",g()).datum(c).transition().duration(d).call(f),f},callback:function(c){c.dispatch.on("tooltipShow",g),c.dispatch.on("tooltipHide",a.tooltip.cleanup),window.onresize=function(){d3.select(b+" svg").attr("width",c.width()()).attr("height",c.height()()).call(c)}}}),h)},h.data=function(a){return arguments.length?(c=a,h):c},h.selector=function(a){return arguments.length?(b=a,h):b},h.duration=function(a){return arguments.length?(d=a,h):d},h.tooltip=function(a){return arguments.length?(e=a,h):e},h.xTickFormat=function(a){return arguments.length?(f.xAxis.tickFormat(typeof a=="function"?a:d3.format(a)),h):f.xAxis.tickFormat()},h.yTickFormat=function(a){return arguments.length?(f.yAxis.tickFormat(typeof a=="function"?a:d3.format(a)),h):f.yAxis.tickFormat()},h.xAxisLabel=function(a){return arguments.length?(f.xAxis.axisLabel(a),h):f.xAxis.axisLabel()},h.yAxisLabel=function(a){return arguments.length?(f.yAxis.axisLabel(a),h):f.yAxis.axisLabel()},d3.rebind(h,f,"x","y"),h.graph=f,h},a.charts.lineChartDaily=function(){function h(){return!b||!c.length?h:(d3.select(b).select("svg").datum(c).transition().duration(d).call(f),h)}var b=null,c=[],d=500,e=function(a,b,c,d,e){return"<h3>"+a+"</h3>"+"<p>"+c+" at "+b+"</p>"},f=a.models.lineWithLegend().x(function(a,b){return b}),g=function(c){var d=document.getElementById(b.substr(1)),g=c.pos[0]+d.offsetLeft,h=c.pos[1]+d.offsetTop,i=f.xAxis.tickFormat(),j=f.yAxis.tickFormat(),k=i(f.x()(c,c.pointIndex)),l=j(f.y()(c.point)),m=e(c.series.key,k,l,c,f);a.tooltip.show([g,h],m)};return f.xAxis.tickFormat(function(a){return d3.time.format("%x")(new Date(c[0].values[a].x))}),f.yAxis.tickFormat(d3.format(",.2%")),h.build=function(){return!b||!c.length?h:(a.addGraph({generate:function(){var a=d3.select(b),e=function(){return parseInt(a.style("width"))},g=function(){return parseInt(a.style("height"))},h=a.append("svg");return f.width(e).height(g),h.attr("width",e()).attr("height",g()).datum(c).transition().duration(d).call(f),f},callback:function(c){c.dispatch.on("tooltipShow",g),c.dispatch.on("tooltipHide",a.tooltip.cleanup),window.onresize=function(){d3.select(b+" svg").attr("width",c.width()()).attr("height",c.height()()).call(c)}}}),h)},h.data=function(a){return arguments.length?(c=a,h):c},h.selector=function(a){return arguments.length?(b=a,h):b},h.duration=function(a){return arguments.length?(d=a,h):d},h.tooltip=function(a){return arguments.length?(e=a,h):e},h.xTickFormat=function(a){return arguments.length?(f.xAxis.tickFormat(typeof a=="function"?a:d3.format(a)),h):f.xAxis.tickFormat()},h.yTickFormat=function(a){return arguments.length?(f.yAxis.tickFormat(typeof a=="function"?a:d3.format(a)),h):f.yAxis.tickFormat()},h.xAxisLabel=function(a){return arguments.length?(f.xAxis.axisLabel(a),h):f.xAxis.axisLabel()},h.yAxisLabel=function(a){return arguments.length?(f.yAxis.axisLabel(a),h):f.yAxis.axisLabel()},d3.rebind(h,f,"x","y"),h.graph=f,h},a.charts.stackedAreaChart=function(){function h(){return!b||!c.length?h:(d3.select(b).select("svg").datum(c).transition().duration(d).call(f),h)}var b=null,c=[],d=500,e=function(a,b,c,d,e){return"<h3>"+a+"</h3>"+"<p>"+c+" at "+b+"</p>"},f=a.models.stackedAreaWithLegend().x(function(a,b){return b}),g=function(c){var d=document.getElementById(b.substr(1)),g=c.pos[0]+d.offsetLeft,h=c.pos[1]+d.offsetTop,i=f.xAxis.tickFormat(),j=f.yAxis.tickFormat(),k=i(f.x()(c,c.pointIndex)),l=j(f.y()(c.point)),m=e(c.series.key,k,l,c,f);a.tooltip.show([g,h],m)};return f.xAxis.tickFormat(function(a){return d3.time.format("%x")(new Date(c[0].values[a].x))}),f.yAxis.tickFormat(d3.format(",.2%")),h.build=function(){return!b||!c.length?h:(a.addGraph({generate:function(){var a=d3.select(b),e=function(){return parseInt(a.style("width"))},g=function(){return parseInt(a.style("height"))},h=a.append("svg");return f.width(e).height(g),h.attr("width",e()).attr("height",g()).datum(c).transition().duration(d).call(f),f},callback:function(c){c.dispatch.on("tooltipShow",g),c.dispatch.on("tooltipHide",a.tooltip.cleanup),window.onresize=function(){d3.select(b+" svg").attr("width",c.width()()).attr("height",c.height()()).call(c)}}}),h)},h.data=function(a){return arguments.length?(c=a,h):c},h.selector=function(a){return arguments.length?(b=a,h):b},h.duration=function(a){return arguments.length?(d=a,h):d},h.tooltip=function(a){return arguments.length?(e=a,h):e},h.xTickFormat=function(a){return arguments.length?(f.xAxis.tickFormat(typeof a=="function"?a:d3.format(a)),h):f.xAxis.tickFormat()},h.yTickFormat=function(a){return arguments.length?(f.yAxis.tickFormat(typeof a=="function"?a:d3.format(a)),h):f.yAxis.tickFormat()},h.xAxisLabel=function(a){return arguments.length?(f.xAxis.axisLabel(a),h):f.xAxis.axisLabel()},h.yAxisLabel=function(a){return arguments.length?(f.yAxis.axisLabel(a),h):f.yAxis.axisLabel()},d3.rebind(h,f,"x","y"),h.graph=f,h}})();