4 lines
113 KiB
JavaScript
4 lines
113 KiB
JavaScript
(function(){function b(a,b){return(new Date(b,a+1,0)).getDate()}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.logs={},a.dispatch=d3.dispatch("render_start","render_end"),a.dispatch.on("render_start",function(b){a.logs.startTime=+(new Date)}),a.dispatch.on("render_end",function(b){a.logs.endTime=+(new Date),a.logs.totalTime=a.logs.endTime-a.logs.startTime,a.dev&&console.log&&console.log("total",a.logs.totalTime)}),a.log=function(){return a.dev&&console.log&&console.log.apply(console,arguments),arguments[arguments.length-1]},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,f,g){var h=document.createElement("div");h.className="nvtooltip "+(g?g:"xy-tooltip"),d=d||"s",e=e||20;var i=f?f:document.getElementsByTagName("body")[0];h.innerHTML=c,h.style.left=0,h.style.top=0,h.style.opacity=0,i.appendChild(h);var j=parseInt(h.offsetHeight),k=parseInt(h.offsetWidth),l=a.utils.windowSize().width,m=a.utils.windowSize().height,n=i.scrollTop,o=i.scrollLeft,p,q;switch(d){case"e":p=b[0]-k-e,q=b[1]-j/2,p<o&&(p=b[0]+e),q<n&&(q=n+5),q+j>n+m&&(q=n-j-5);break;case"w":p=b[0]+e,q=b[1]-j/2,p+k>l&&(p=b[0]-k-e),q<n&&(q=n+5),q+j>n+m&&(q=n-j-5);break;case"n":p=b[0]-k/2,q=b[1]+e,p<o&&(p=o+5),p+k>l&&(p=l-k-5),q+j>n+m&&(q=b[1]-j-e);break;case"s":p=b[0]-k/2,q=b[1]-j-e,p<o&&(p=o+5),p+k>l&&(p=l-k-5),n>q&&(q=b[1]+20)}return h.style.left=p+"px",h.style.top=q+"px",h.style.opacity=1,h.style.position="absolute",h.style.pointerEvents="none",h},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.utils.windowResize=function(a){var b=window.onresize;window.onresize=function(c){typeof b=="function"&&b(c),a(c)}},a.models.axis=function(){function i(b){return b.each(function(b){var i=d3.select(this),j=i.selectAll("g.wrap.axis").data([b]),k=j.enter().append("g").attr("class","wrap axis"),l=k.append("g"),m=j.select("g");(g.orient()=="top"||g.orient()=="bottom")&&g.ticks(Math.abs(c.range()[1]-c.range()[0])/100),d3.transition(m).call(g),h=h||g.scale();var n=m.selectAll("text.axislabel").data([d||null]);n.exit().remove();switch(g.orient()){case"top":n.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",0);var o=c.range().length==2?c.range()[1]:c.range()[c.range().length-1]+(c.range()[1]-c.range()[0]);n.attr("x",o/2);if(e){var p=j.selectAll("g.axisMaxMin").data(c.domain());p.enter().append("g").attr("class","axisMaxMin").append("text"),p.exit().remove(),p.attr("transform",function(a,b){return"translate("+c(a)+",0)"}).select("text").attr("dy","0em").attr("y",-g.tickPadding()).attr("text-anchor","middle").text(function(a,b){return(""+g.tickFormat()(a)).match("NaN")?"":g.tickFormat()(a)}),d3.transition(p).attr("transform",function(a,b){return"translate("+c.range()[b]+",0)"})}break;case"bottom":n.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",30);var o=c.range().length==2?c.range()[1]:c.range()[c.range().length-1]+(c.range()[1]-c.range()[0]);n.attr("x",o/2);if(e){var p=j.selectAll("g.axisMaxMin").data(c.domain());p.enter().append("g").attr("class","axisMaxMin").append("text"),p.exit().remove(),p.attr("transform",function(a,b){return"translate("+c(a)+",0)"}).select("text").attr("dy",".71em").attr("y",g.tickPadding()).attr("text-anchor","middle").text(function(a,b){return(""+g.tickFormat()(a)).match("NaN")?"":g.tickFormat()(a)}),d3.transition(p).attr("transform",function(a,b){return"translate("+c.range()[b]+",0)"})}break;case"right":n.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("transform","rotate(90)").attr("y",-a+12),n.attr("x",-c.range()[0]/2);if(e){var p=j.selectAll("g.axisMaxMin").data(c.domain());p.enter().append("g").attr("class","axisMaxMin").append("text").style("opacity",0),p.exit().remove(),p.attr("transform",function(a,b){return"translate(0,"+c(a)+")"}).select("text").attr("dy",".32em").attr("y",0).attr("x",g.tickPadding()).attr("text-anchor","start").text(function(a,b){return(""+g.tickFormat()(a)).match("NaN")?"":g.tickFormat()(a)}),d3.transition(p).attr("transform",function(a,b){return"translate(0,"+c.range()[b]+")"}).select("text").style("opacity",1)}break;case"left":n.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("transform","rotate(-90)").attr("y",-a+12),n.attr("x",-c.range()[0]/2);if(e){var p=j.selectAll("g.axisMaxMin").data(c.domain());p.enter().append("g").attr("class","axisMaxMin").append("text").style("opacity",0),p.exit().remove(),p.attr("transform",function(a,b){return"translate(0,"+h(a)+")"}).select("text").attr("dy",".32em").attr("y",0).attr("x",-g.tickPadding()).attr("text-anchor","end").text(function(a,b){return(""+g.tickFormat()(a)).match("NaN")?"":g.tickFormat()(a)}),d3.transition(p).attr("transform",function(a,b){return"translate(0,"+c.range()[b]+")"}).select("text").style("opacity",1)}}n.text(function(a){return a}),e&&(g.orient()==="left"||g.orient()==="right")&&m.selectAll("g").each(function(a,b){if(c(a)<c.range()[1]+10||c(a)>c.range()[0]-10)a>1e-10||a<-1e-10?d3.select(this).remove():d3.select(this).select("text").remove()});if(e&&(g.orient()==="top"||g.orient()==="bottom")){var q=[];j.selectAll("g.axisMaxMin").each(function(a,b){b?q.push(c(a)-this.getBBox().width-4):q.push(c(a)+this.getBBox().width+4)}),m.selectAll("g").each(function(a,b){if(c(a)<q[0]||c(a)>q[1])a>1e-10||a<-1e-10?d3.select(this).remove():d3.select(this).select("text").remove()})}f&&m.selectAll("line.tick").filter(function(a){return!parseFloat(Math.round(a*1e5)/1e6)}).classed("zero",!0),h=c.copy()}),i}var a=60,b=60,c=d3.scale.linear(),d=null,e=!0,f=!0,g=d3.svg.axis().scale(c).orient("bottom").tickFormat(function(a){return a}),h;return d3.rebind(i,g,"orient","ticks","tickValues","tickSubdivide","tickSize","tickPadding","tickFormat"),d3.rebind(i,c,"domain","range","rangeBand","rangeBands"),i.width=function(b){return arguments.length?(a=b,i):a},i.height=function(a){return arguments.length?(b=a,i):b},i.axisLabel=function(a){return arguments.length?(d=a,i):d},i.showMaxMin=function(a){return arguments.length?(e=a,i):e},i.highlightZero=function(a){return arguments.length?(f=a,i):f},i.scale=function(a){return arguments.length?(c=a,g.scale(c),d3.rebind(i,c,"domain","range","rangeBand","rangeBands"),i):c},i},a.models.historicalBar=function(){function r(o){return o.each(function(o){var p=b-a.left-a.right,r=c-a.top-a.bottom;m.domain(k||d3.extent(o[0].values.map(e).concat(g))).range([0,p]),n.domain(l||d3.extent(o[0].values.map(f).concat(h))).range([r,0]);if(m.domain()[0]===m.domain()[1]||n.domain()[0]===n.domain()[1])singlePoint=!0;m.domain()[0]===m.domain()[1]&&(m.domain()[0]?m.domain([m.domain()[0]-m.domain()[0]*.01,m.domain()[1]+m.domain()[1]*.01]):m.domain([-1,1])),n.domain()[0]===n.domain()[1]&&(n.domain()[0]?n.domain([n.domain()[0]+n.domain()[0]*.01,n.domain()[1]-n.domain()[1]*.01]):n.domain([-1,1]));var s=d3.select(this).on("click",function(a,b){q.chartClick({data:a,index:b,pos:d3.event,id:d})}),t=d3.select(this).selectAll("g.wrap.bar").data([o[0].values]),u=t.enter().append("g").attr("class","wrap nvd3 bar"),v=u.append("g");v.append("g").attr("class","bars"),t.attr("width",b).attr("height",c);var w=t.select("g").attr("transform","translate("+a.left+","+a.top+")");u.append("defs").append("clipPath").attr("id","chart-clip-path-"+d).append("rect"),t.select("#chart-clip-path-"+d+" rect").attr("width",p).attr("height",r),v.attr("clip-path",i?"url(#chart-clip-path-"+d+")":"");var z=v.append("g").attr("class","shiftWrap"),A=t.select(".bars").selectAll(".bar").data(function(a){return a});A.exit().remove();var B=A.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:o[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:o[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()});A.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))-p/o[0].values.length*.5)+",0)"}).attr("width",p/o[0].values.length*.9),d3.transition(A).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(a){return arguments.length?(b=a,r):b},r.height=function(a){return arguments.length?(c=a,r):c},r.xScale=function(a){return arguments.length?(m=a,r):m},r.yScale=function(a){return arguments.length?(n=a,r):n},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,i){var k=g-c.left-c.right,l=h-c.top-c.bottom,m=d.call(this,a,i).slice().sort(d3.descending),n=e.call(this,a,i).slice().sort(d3.descending),o=f.call(this,a,i).slice().sort(d3.descending),p=d3.select(this).selectAll("g.wrap.bullet").data([a]),q=p.enter().append("g").attr("class","wrap nvd3 bullet"),r=q.append("g"),s=p.select("g");p.attr("transform","translate("+c.left+","+c.top+")");var t=d3.scale.linear().domain([0,Math.max(m[0],n[0],o[0])]).range(b?[k,0]:[0,k]),u=this.__chart__||d3.scale.linear().domain([0,Infinity]).range(t.range());this.__chart__=t;var v=function(a){return Math.abs(u(a)-u(0))},w=function(a){return Math.abs(t(a)-t(0))},x=s.selectAll("rect.range").data(m);x.enter().append("rect").attr("class",function(a,b){return"range s"+b}).attr("width",v).attr("height",l).attr("x",b?u:0).on("mouseover",function(a,b){j.elementMouseover({value:a,label:b<=0?"Maximum":b>1?"Minimum":"Mean",pos:[t(a),l/2]})}).on("mouseout",function(a,b){j.elementMouseout({value:a,label:b<=0?"Minimum":b>=1?"Maximum":"Mean"})}),d3.transition(x).attr("x",b?t:0).attr("width",w).attr("height",l);var y=s.selectAll("rect.measure").data(o);y.enter().append("rect").attr("class",function(a,b){return"measure s"+b}).attr("width",v).attr("height",l/3).attr("x",b?u:0).attr("y",l/3).on("mouseover",function(a){j.elementMouseover({value:a,label:"Current",pos:[t(a),l/2]})}).on("mouseout",function(a){j.elementMouseout({value:a,label:"Current"})}),d3.transition(y).attr("width",w).attr("height",l/3).attr("x",b?t:0).attr("y",l/3);var z=s.selectAll("path.markerTriangle").data(n),A=l/6;z.enter().append("path").attr("class","markerTriangle").attr("transform",function(a){return"translate("+u(a)+","+l/2+")"}).attr("d","M0,"+A+"L"+A+","+ -A+" "+ -A+","+ -A+"Z").on("mouseover",function(a,b){j.elementMouseover({value:a,label:"Previous",pos:[t(a),l/2]})}).on("mouseout",function(a,b){j.elementMouseout({value:a,label:"Previous"})}),d3.transition(z).attr("transform",function(a){return"translate("+t(a)+","+l/2+")"}),z.exit().remove()}),d3.timer.flush()}var a="left",b=!1,c={top:0,right:0,bottom:0,left: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.margin=function(a){return arguments.length?(c=a,k):c},k.tickFormat=function(a){return arguments.length?(i=a,k):i},k},a.models.bulletChart=function(){function p(b){b.each(function(b,l){var p=d3.select(this),q=(h||parseInt(p.style("width"))||960)-d.left-d.right,r=i-d.top-d.bottom,s=this,t=e.call(this,b,l).slice().sort(d3.descending),u=f.call(this,b,l).slice().sort(d3.descending),v=g.call(this,b,l).slice().sort(d3.descending),w=p.selectAll("g.wrap.bulletChart").data([b]),x=w.enter().append("g").attr("class","wrap nvd3 bulletChart"),y=x.append("g");y.append("g").attr("class","bulletWrap"),y.append("g").attr("class","titles");var z=w.select("g");w.attr("transform","translate("+d.left+","+d.top+")");var A=d3.scale.linear().domain([0,Math.max(t[0],u[0],v[0])]).range(c?[q,0]:[0,q]),B=this.__chart__||d3.scale.linear().domain([0,Infinity]).range(A.range());this.__chart__=A;var C=function(a){return Math.abs(B(a)-B(0))},D=function(a){return Math.abs(A(a)-A(0))},E=z.select(".titles").append("g").attr("text-anchor","end").attr("transform","translate(-6,"+(i-d.top-d.bottom)/2+")");E.append("text").attr("class","title").text(function(a){return a.title}),E.append("text").attr("class","subtitle").attr("dy","1em").text(function(a){return a.subtitle}),n.width(q).height(r);var F=z.select(".bulletWrap");d3.transition(F).call(n);var G=j||A.tickFormat(8),H=z.selectAll("g.tick").data(A.ticks(8),function(a){return this.textContent||G(a)}),I=H.enter().append("g").attr("class","tick").attr("transform",function(a){return"translate("+B(a)+",0)"}).style("opacity",1e-6);I.append("line").attr("y1",r).attr("y2",r*7/6),I.append("text").attr("text-anchor","middle").attr("dy","1em").attr("y",r*7/6).text(G),d3.transition(I).attr("transform",function(a){return"translate("+A(a)+",0)"}).style("opacity",1);var J=d3.transition(H).attr("transform",function(a){return"translate("+A(a)+",0)"}).style("opacity",1);J.select("line").attr("y1",r).attr("y2",r*7/6),J.select("text").attr("y",r*7/6),d3.transition(H.exit()).attr("transform",function(a){return"translate("+A(a)+",0)"}).style("opacity",1e-6).remove(),n.dispatch.on("elementMouseover.tooltip",function(a){m.tooltipShow(a)}),k&&m.on("tooltipShow",function(a){o(a,s.parentNode)}),n.dispatch.on("elementMouseout.tooltip",function(a){m.tooltipHide(a)}),k&&m.on("tooltipHide",a.tooltip.cleanup)}),d3.timer.flush()}var b="left",c=!1,d={top:5,right:40,bottom:20,left:120},e=function(a){return a.ranges},f=function(a){return a.markers},g=function(a){return a.measures},h=null,i=55,j=null,k=!0,l=function(a,b,c,d,e){return"<h3>"+d.label+"</h3>"+"<p>"+d.value+"</p>"},m=d3.dispatch("tooltipShow","tooltipHide"),n=a.models.bullet(),o=function(b,c){var c=document.getElementById("chart"),e=b.pos[0]+c.offsetLeft+d.left,f=b.pos[1]+c.offsetTop+d.top,g="<h3>"+b.label+"</h3>"+"<p>"+b.value+"</p>";a.tooltip.show([e,f],g,b.value<0?"e":"w")};return p.dispatch=m,p.bullet=n,p.orient=function(a){return arguments.length?(b=a,c=b=="right"||b=="bottom",p):b},p.ranges=function(a){return arguments.length?(e=a,p):e},p.markers=function(a){return arguments.length?(f=a,p):f},p.measures=function(a){return arguments.length?(g=a,p):g},p.width=function(a){return arguments.length?(h=a,p):h},p.height=function(a){return arguments.length?(i=a,p):i},p.margin=function(a){return arguments.length?(d=a,p):d},p.tickFormat=function(a){return arguments.length?(j=a,p):j},p.tooltips=function(a){return arguments.length?(k=a,p):k},p.tooltipContent=function(a){return arguments.length?(l=a,p):l},p},a.models.cumulativeLineChart=function(){function y(a,b){}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 A(a,b){B.update()}function B(a){return a.each(function(j){var y=d3.select(this).classed("chart-"+o,!0),z=this,A=(d||parseInt(y.style("width"))||960)-b.left-b.right,D=(e||parseInt(y.style("height"))||400)-b.top-b.bottom;k=m.xScale(),l=m.yScale(),n.domain([0,j[0].values.length-1]).range([0,A]).clamp(!0);var j=C(u.i,j),E=y.selectAll("g.wrap.cumulativeLine").data([j]),F=E.enter().append("g").attr("class","wrap nvd3 cumulativeLine").append("g");F.append("g").attr("class","x axis"),F.append("g").attr("class","y axis"),F.append("g").attr("class","linesWrap"),F.append("g").attr("class","legendWrap"),F.append("g").attr("class","controlsWrap");var G=E.select("g");f&&(r.width(A),G.select(".legendWrap").datum(j).call(r),b.top!=r.height()&&(b.top=r.height(),D=(e||parseInt(y.style("height"))||400)-b.top-b.bottom),G.select(".legendWrap").attr("transform","translate(0,"+ -b.top+")")),h&&(s.width(140).color(["#444","#444","#444"]),G.select(".controlsWrap").datum(v).attr("transform","translate(0,"+ -b.top+")").call(s)),m.y(function(a){return a.display.y}).width(A).height(D).color(j.map(function(a,b){return a.color||c[b%c.length]}).filter(function(a,b){return!j[b].disabled})),G.attr("transform","translate("+b.left+","+b.top+")");var H=G.select(".linesWrap").datum(j.filter(function(a){return!a.disabled}));d3.transition(H).call(m);var I=H.selectAll(".indexLine").data([u]);I.enter().append("rect").attr("class","indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).call(x),I.attr("transform",function(a){return"translate("+n(a.i)+",0)"}).attr("height",D),p.scale(k).ticks(A/100).tickSize(-D,0),G.select(".x.axis").attr("transform","translate(0,"+l.range()[0]+")"),d3.transition(G.select(".x.axis")).call(p),q.scale(l).ticks(D/36).tickSize(-A,0),d3.transition(G.select(".y.axis")).call(q),s.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,i=!b.disabled,a.transition().call(B)}),r.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,j.filter(function(a){return!a.disabled}).length||j.map(function(a){return a.disabled=!1,E.selectAll(".series").classed("disabled",!1),a}),a.transition().call(B)}),t.on("tooltipShow",function(a){g&&w(a,z.parentNode)})}),B.update=function(){B(a)},B.container=this,B}function C(a,b){return b.map(function(b,c){var d=m.y()(b.values[a],a);return b.values=b.values.map(function(a,b){return a.display={y:(m.y()(a,b)-d)/(1+d)},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=!1,i=!0,j=function(a,b,c,d,e){return"<h3>"+a+"</h3>"+"<p>"+c+" at "+b+"</p>"},k,l,m=a.models.line(),n=d3.scale.linear(),o=m.id(),p=a.models.axis().orient("bottom").tickPadding(5),q=a.models.axis().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()(m.x()(b.point,b.pointIndex)),g=q.tickFormat()(m.y()(b.point,b.pointIndex)),h=j(b.series.key,f,g,b,B);a.tooltip.show([d,e],h)},x=d3.behavior.drag().on("dragstart",y).on("drag",z).on("dragend",A);return m.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],t.tooltipShow(a)}),m.dispatch.on("elementMouseout.tooltip",function(a){t.tooltipHide(a)}),t.on("tooltipHide",function(){g&&a.tooltip.cleanup()}),B.dispatch=t,B.legend=r,B.xAxis=p,B.yAxis=q,d3.rebind(B,m,"defined","isArea","x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),B.margin=function(a){return arguments.length?(b=a,B):b},B.width=function(a){return arguments.length?(d=a,B):d},B.height=function(a){return arguments.length?(e=a,B):e},B.color=function(a){return arguments.length?(c=a,r.color(a),B):c},B.showLegend=function(a){return arguments.length?(f=a,B):f},B.tooltips=function(a){return arguments.length?(g=a,B):g},B.tooltipContent=function(a){return arguments.length?(j=a,B):j},B},a.models.discreteBar=function(){function r(d){return d.each(function(s){var t=b-a.left-a.right,u=c-a.top-a.bottom;s=s.map(function(a,b){return a.values=a.values.map(function(a){return a.series=b,a}),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?12:0]):f.range([u,0]),p=p||e,q=q||f.copy().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),o.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),o.elementMouseout({value:h(a,b),point:a,series:s[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){o.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){o.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("x",e.rangeBand()/2).attr("y",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?q(0):q(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(){r(d)},p=e.copy(),q=f.copy()}),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=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout"),p,q;return r.dispatch=o,r.x=function(a){return arguments.length?(g=a,r):g},r.y=function(a){return arguments.length?(h=a,r):h},r.margin=function(b){return arguments.length?(a=b,r):a},r.width=function(a){return arguments.length?(b=a,r):b},r.height=function(a){return arguments.length?(c=a,r):c},r.xScale=function(a){return arguments.length?(e=a,r):e},r.yScale=function(a){return arguments.length?(f=a,r):f},r.xDomain=function(a){return arguments.length?(m=a,r):m},r.yDomain=function(a){return arguments.length?(n=a,r):n},r.forceY=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.showValues=function(a){return arguments.length?(k=a,r):k},r.valueFormat=function(a){return arguments.length?(l=a,r):l},r},a.models.discreteBarChart=function(){function r(e){return e.each(function(i){var q=d3.select(this),s=this,t=(c||parseInt(q.style("width"))||960)-b.left-b.right,u=(d||parseInt(q.style("height"))||400)-b.top-b.bottom;j.width(t).height(u);var v=q.selectAll("g.wrap.discreteBarWithAxes").data([i]),w=v.enter().append("g").attr("class","wrap nvd3 discreteBarWithAxes").append("g"),z=w.append("defs");w.append("g").attr("class","x axis"),w.append("g").attr("class","y axis"),w.append("g").attr("class","barsWrap");var A=v.select("g");A.attr("transform","translate("+b.left+","+b.top+")");var B=A.select(".barsWrap").datum(i.filter(function(a){return!a.disabled}));d3.transition(B).call(j),z.append("clipPath").attr("id","x-label-clip-"+j.id()).append("rect"),A.select("#x-label-clip-"+j.id()+" rect").attr("width",k.rangeBand()*(f?2:1)).attr("height",16).attr("x",-k.rangeBand()/(f?1:2)),m.ticks(t/100).tickSize(-u,0),A.select(".x.axis").attr("transform","translate(0,"+(l.range()[0]+(j.showValues()&&l.domain()[0]<0?16:0))+")"),A.select(".x.axis").transition().duration(0).call(m);var C=A.select(".x.axis").selectAll("g");f&&C.selectAll("text").attr("transform",function(a,b,c){return"translate(0,"+(c%2==0?"0":"12")+")"}),g&&C.selectAll("text").attr("transform",function(a,b,c){return"rotate("+g+" 0,0)"}).attr("text-anchor",g>0?"start":"end"),C.selectAll("text").attr("clip-path",function(a,b,c){return g?"":"url(#x-label-clip-"+j.id()+")"}),n.ticks(u/36).tickSize(-t,0),d3.transition(A.select(".y.axis")).call(n),j.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],o.tooltipShow(a)}),h&&o.on("tooltipShow",function(a){p(a,s.parentNode)}),j.dispatch.on("elementMouseout.tooltip",function(a){o.tooltipHide(a)}),h&&o.on("tooltipHide",a.tooltip.cleanup),r.update=function(){e.transition().call(r)},r.container=this}),r}var b={top:10,right:10,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!1,g=0,h=!0,i=function(a,b,c,d,e){return"<h3>"+b+"</h3>"+"<p>"+c+"</p>"},j=a.models.discreteBar(),k=j.xScale(),l=j.yScale(),m=a.models.axis().scale(k).orient("bottom").highlightZero(!1).showMaxMin(!1),n=a.models.axis().scale(l).orient("left"),o=d3.dispatch("tooltipShow","tooltipHide");m.tickFormat(function(a){return a}),n.tickFormat(d3.format(",.1f"));var p=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,b.pointIndex)),g=n.tickFormat()(j.y()(b.point,b.pointIndex)),h=i(b.series.key,f,g,b,r);a.tooltip.show([d,e],h,b.value<0?"n":"s")},q=[{key:"Grouped"},{key:"Stacked",disabled:!0}];return r.dispatch=o,r.discretebar=j,r.xAxis=m,r.yAxis=n,d3.rebind(r,j,"x","y","xDomain","yDomain","forceX","forceY","id","showValues","valueFormat"),r.margin=function(a){return arguments.length?(b=a,r):b},r.width=function(a){return arguments.length?(c=a,r):c},r.height=function(a){return arguments.length?(d=a,r):d},r.color=function(a){return arguments.length?(e=a,j.color(a),r):e},r.staggerLabels=function(a){return arguments.length?(f=a,r):f},r.rotateLabels=function(a){return arguments.length?(g=a,r):g},r.tooltips=function(a){return arguments.length?(h=a,r):h},r.tooltipContent=function(a){return arguments.length?(i=a,r):i},r},a.models.distribution=function(){function j(g){return g.each(function(g){var j=b-(d==="x"?a.left+a.right:a.top+a.bottom),k=d=="x"?"y":"x";i=i||h;var l=d3.select(this).selectAll("g.distribution").data([g]),m=l.enter().append("g").attr("class","nvd3 distribution"),n=m.append("g"),o=l.select("g");l.attr("transform","translate("+a.left+","+a.top+")");var p=o.selectAll("g.dist").data(function(a){return a},function(a){return a.key});p.enter().append("g"),p.attr("class",function(a,b){return"dist series-"+b}).style("stroke",function(a,b){return f[b%f.length]});var q=p.selectAll("line.dist"+d).data(function(a){return a.values});q.enter().append("line").attr(d+"1",function(a,b){return i(e(a,b))}).attr(d+"2",function(a,b){return i(e(a,b))}),d3.transition(p.exit().selectAll("line.dist"+d)).attr(d+"1",function(a,b){return h(e(a,b))}).attr(d+"2",function(a,b){return h(e(a,b))}).style("stroke-opacity",0).remove(),q.attr("class",function(a,b){return"dist"+d+" dist"+d+"-"+b}).attr(k+"1",0).attr(k+"2",c),d3.transition(q).attr(d+"1",function(a,b){return h(e(a,b))}).attr(d+"2",function(a,b){return h(e(a,b))}),i=h.copy()}),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;return j.margin=function(b){return arguments.length?(a=b,j):a},j.width=function(a){return arguments.length?(b=a,j):b},j.axis=function(a){return arguments.length?(d=a,j):d},j.size=function(a){return arguments.length?(c=a,j):c},j.getData=function(a){return arguments.length?(e=d3.functor(a),j):e},j.scale=function(a){return arguments.length?(h=a,j):h},j.color=function(a){return arguments.length?(f=a,j):f},j},a.models.historicalStockChart=function(){function J(j){return j.each(function(o){function Z(a){var b=+(a=="e"),c=b?1:-1,d=M/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)}function $(a,b){var c=G.extent();if(d3.event.dx<0&&c[1]>=t.domain()[1]||d3.event.dx>0&&c[0]<=t.domain()[0])return!1;d3.event.dx<0&&t(c[1])-d3.event.dx>t.range()[1]&&(d3.event.dx=t.range()[1]-t(c[1]));var d=(c[1]-c[0])/(t.domain()[1]-t.domain()[0]),e=[t.invert(t(c[0])-d3.event.dx*d),t.invert(t(c[1])-d3.event.dx*d)];G.extent(e),T.select(".x.brush").call(G),_()}function _(){var a=G.empty()?t.domain():G.extent();T.select(".brushBackground rect.left").attr("width",t(a[0])-s.range()[0]),T.select(".brushBackground rect.right").attr("x",t(a[1])).attr("width",s.range()[1]-t(a[1]));var c=T.select(".stocksWrap").datum([{key:O[0].key,values:O[0].values.filter(function(b,c){return i(b,c)>a[0]&&i(b,c)<a[1]})}]),d=T.select(".barsWrap").attr("transform","translate(0,"+(K+b.bottom)+")").datum([{key:N[0].key,values:N[0].values.filter(function(b,c){return i(b,c)>a[0]&&i(b,c)<a[1]})}]);d3.transition(d).call(q),d3.transition(c).call(p),d3.transition(T.select(".x.axis")).call(y),d3.transition(T.select(".x2.axis")).call(z),d3.transition(T.select(".y1.axis")).call(B),d3.transition(T.select(".y2.axis")).call
|
|
(C)}var v=d3.select(this),w=this,x=(e||parseInt(v.style("width"))||960)-b.left-b.right,K=(f||parseInt(v.style("height"))||400)-b.top-b.bottom-g-h,L=g-c.top-c.bottom,M=h-d.top-d.bottom;G.on("brush",_),H.on("drag",$);var N=o.filter(function(a){return!a.disabled&&a.bar}),O=o.filter(function(a){return!a.disabled&&!a.bar});t.domain(d3.extent(O[0].values.map(function(a,b){return i(a,b)}))).range([0,x]),u.domain(d3.extent(O[0].values,function(a){return a.x})).range([0,x]);var P=v.selectAll("g.wrap.historicalStockChart").data([o]),Q=P.enter().append("g").attr("class","wrap nvd3 historicalStockChart"),R=Q.append("defs"),S=Q.append("g");S.append("g").attr("class","brushBackground"),S.append("g").attr("class","x axis"),S.append("g").attr("class","x2 axis"),S.append("g").attr("class","y1 axis"),S.append("g").attr("class","y2 axis"),S.append("g").attr("class","y3 axis"),S.append("g").attr("class","barsWrap"),S.append("g").attr("class","stocksWrap"),S.append("g").attr("class","linesWrap"),S.append("g").attr("class","x3 axis"),S.append("g").attr("class","legendWrap"),S.append("g").attr("class","x brush");var T=P.select("g"),U=T.select("defs");m&&(E.width(x/2),T.select(".legendWrap").datum(o.map(function(a){return a.originalKey=a.originalKey===undefined?a.key:a.originalKey,a.key=a.originalKey,a})).call(E),b.top!=E.height()&&(b.top=E.height(),K=(f||parseInt(v.style("height"))||400)-b.top-b.bottom),T.select(".legendWrap").attr("transform","translate("+x/2+","+ -b.top+")")),p.width(x).height(K).color(o.map(function(a,b){return a.color||l[b%l.length]}).filter(function(a,b){return!o[b].disabled&&!o[b].bar})),r.width(x).height(M).color(o.map(function(a,b){return a.color||l[b%l.length]}).filter(function(a,b){return!o[b].disabled&&!o[b].bar})),q.width(x).height(L).color(o.map(function(a,b){return a.color||l[b%l.length]}).filter(function(a,b){return!o[b].disabled&&o[b].bar}));var V=T.select(".barsWrap").attr("transform","translate(0,"+(K+b.bottom)+")").datum(N.length?N:[{values:[]}]),W=T.select(".stocksWrap").datum(O.length?O:[{values:[]}]),X=T.select(".linesWrap").attr("transform","translate(0,"+(K+b.bottom+g)+")").datum(O.length?O:[{values:[]}]);W.selectAll("rect.dragTarget").data([{x:0}]).enter().append("rect").attr("class","dragTarget").attr("width",x).attr("height",K+b.bottom+g).call(H),d3.transition(V).call(q),d3.transition(W).call(p),d3.transition(X).call(r),P.select("#edge-clip-"+k+" rect").attr("width",x).attr("height",K);var Y=T.select(".brushBackground").attr("transform","translate(0,"+(K+b.bottom+g)+")");Y.append("rect").attr("class","left").attr("x",0).attr("y",0).attr("height",M),Y.append("rect").attr("class","right").attr("x",0).attr("y",0).attr("height",M),G.extent([t.domain()[1]/2,t.domain()[1]]),gBrush=T.select(".x.brush").attr("transform","translate(0,"+(K+b.bottom+g)+")").call(G),gBrush.selectAll("rect").attr("height",M),gBrush.selectAll(".resize").append("path").attr("d",Z),_(),T.attr("transform","translate("+b.left+","+b.top+")"),y.ticks(x/100).tickSize(-L,0),T.select(".x.axis").attr("transform","translate(0,"+(K+b.bottom+L+c.top)+")"),d3.transition(T.select(".x.axis")).call(y),z.ticks(x/100).tickSize(-K,0),T.select(".x2.axis").attr("transform","translate(0,"+K+")"),d3.transition(T.select(".x2.axis")).call(z),A.ticks(x/100).tickSize(-M,0),T.select(".x3.axis").attr("transform","translate(0,"+(K+b.bottom+g+M+d.top)+")"),d3.transition(T.select(".x3.axis")).call(A),B.ticks(L/36).tickSize(-x,0).width(c.left).axisLabel("Volume (K)"),T.select(".y1.axis").attr("transform","translate(0,"+(K+b.bottom)+")"),d3.transition(T.select(".y1.axis")).style("opacity",N.length?1:0).call(B),C.ticks(K/36).tickSize(-x,0).width(b.left).axisLabel("Price ($)"),T.select(".y2.axis").style("opacity",O.length?1:0),d3.transition(T.select(".y2.axis")).call(C),D.ticks(M/36).tickSize(-x,0).width(d.left),T.select(".y3.axis").style("opacity",O.length?1:0).attr("transform","translate(0,"+(K+b.bottom+g)+")"),d3.transition(T.select(".y3.axis")).call(D),p.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],F.tooltipShow(a)}),n&&F.on("tooltipShow",function(a){I(a,w.parentNode)}),p.dispatch.on("elementMouseout.tooltip",function(a){F.tooltipHide(a)}),n&&F.on("tooltipHide",a.tooltip.cleanup),q.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+c.left,a.pos[1]+K+b.top+b.bottom+c.top],F.tooltipShow(a)}),n&&F.on("tooltipShow",function(a){I(a,w.parentNode)}),q.dispatch.on("elementMouseout.tooltip",function(a){F.tooltipHide(a)}),n&&F.on("tooltipHide",a.tooltip.cleanup),J.update=function(){j.transition().call(J)},J.container=this}),J}var b={top:10,right:30,bottom:25,left:80},c={top:0,right:30,bottom:5,left:80},d={top:0,right:30,bottom:20,left:80},e=null,f=null,g=80,h=65,i=function(a){return a.x},j=function(a){return a.y},k=Math.floor(Math.random()*1e4),l=d3.scale.category20().range(),m=!1,n=!0,o=function(a,b,c,d,e){return"<h3>"+a+"</h3>"+"<p>Closed at "+c+" on "+b+"</p>"},p=a.models.ohlcBar(),q=a.models.historicalBar(),r=a.models.line().interactive(!1).isArea(!0),s=p.xScale(),t=d3.scale.linear().clamp(!0),u=d3.time.scale(),v=q.yScale(),w=p.yScale(),x=r.yScale(),y=a.models.axis().scale(s).orient("bottom").tickPadding(5),z=a.models.axis().scale(s).orient("bottom").tickPadding(5),A=d3.svg.axis().scale(u).orient("bottom"),B=a.models.axis().scale(v).orient("left"),C=a.models.axis().scale(w).orient("left"),D=a.models.axis().scale(x).orient("left"),E=a.models.legend().height(30),F=d3.dispatch("tooltipShow","tooltipHide"),G=d3.svg.brush().x(t),H=d3.behavior.drag(),I=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=z.tickFormat()(p.x()(b.point,b.pointIndex)),g=(b.series.bar?B:C).tickFormat()(p.y()(b.point,b.pointIndex)),h=o(b.series.key,f,g,b,J);a.tooltip.show([d,e],h,b.value<0?"n":"s")};return J.dispatch=F,J.legend=E,J.stocks=p,J.lines=r,J.bars=q,J.xAxis=y,J.xAxis2=z,J.xAxis3=A,J.yAxis1=B,J.yAxis2=C,J.yAxis3=D,d3.rebind(J,p,"getOpen","getClose","getHigh","getLow"),J.x=function(a){return arguments.length?(i=a,p.x(a),r.x(a),q.x(a),J):i},J.y=function(a){return arguments.length?(j=a,p.y(a),r.y(a),q.y(a),J):j},J.margin=function(a){return arguments.length?(b=a,J):b},J.margin2=function(a){return arguments.length?(c=a,J):c},J.margin3=function(a){return arguments.length?(d=a,J):d},J.width=function(a){return arguments.length?(e=a,J):e},J.height=function(a){return arguments.length?(f=a,J):f},J.height2=function(a){return arguments.length?(g=a,J):g},J.height3=function(a){return arguments.length?(h=a,J):h},J.color=function(a){return arguments.length?(l=a,E.color(a),J):l},J.id=function(a){return arguments.length?(k=a,J):k},J.showLegend=function(a){return arguments.length?(m=a,J):m},J.tooltips=function(a){return arguments.length?(n=a,J):n},J.tooltipContent=function(a){return arguments.length?(o=a,J):o},J},a.models.indentedTree=function(){function i(d){return d.each(function(e){function y(a,b,c){d3.event.stopPropagation();if(d3.event.shiftKey&&!c)return d3.event.shiftKey=!1,a.values&&a.values.forEach(function(a){(a.values||a._values)&&y(a,0,!0)}),!0;if(!B(a))return!0;a.values?(a._values=a.values,a.values=null):(a.values=a._values,a._values=null),i.update()}function z(a){return a._values&&a._values.length?iconOpen:a.values&&a.values.length?iconClose:""}function A(a){return a._values&&a._values.length}function B(a){var b=a.values||a._values;return b&&b.length}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]})})}),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");return i.margin=function(b){return arguments.length?(a=b,i):a},i.width=function(a){return arguments.length?(b=a,i):b},i.height=function(a){return arguments.length?(c=a,i):c},i.color=function(a){return arguments.length?(d=a,scatter.color(a),i):d},i.id=function(a){return arguments.length?(e=a,i):e},i.header=function(a){return arguments.length?(f=a,i):f},i.noResultsText=function(a){return arguments.length?(g=a,i):g},i.columns=function(a){return arguments.length?(columns=a,i):columns},i.tableClass=function(a){return arguments.length?(tableClass=a,i):tableClass},i.iconOpen=function(a){return arguments.length?(iconOpen=a,i):iconOpen},i.iconClose=function(a){return arguments.length?(iconClose=a,i):iconClose},i},a.models.legend=function(){function h(i){return i.each(function(h){var i=b-a.left-a.right,j=d3.select(this).selectAll("g.legend").data([h]),l=j.enter().append("g").attr("class","nvd3 legend").append("g"),m=j.select("g").attr("transform","translate("+a.left+","+a.top+")"),n=m.selectAll(".series").data(function(a){return a}),o=n.enter().append("g").attr("class","series").on("mouseover",function(a,b){g.legendMouseover(a,b)}).on("mouseout",function(a,b){g.legendMouseout(a,b)}).on("click",function(a,b){g.legendClick(a,b)}).on("dblclick",function(a,b){g.legendDblclick(a,b)});o.append("circle").style("fill",function(a,b){return a.color||e[b%e.length]}).style("stroke",function(a,b){return a.color||e[b%e.length]}).style("stroke-width",2).attr("r",5),o.append("text").text(d).attr("text-anchor","start").attr("dy",".32em").attr("dx","8"),n.classed("disabled",function(a){return a.disabled}),n.exit().remove();if(f){var p=[];n.each(function(a,b){p.push(d3.select(this).select("text").node().getComputedTextLength()+28)});var q=0,r=0,s=[];while(r<i&&q<p.length)s[q]=p[q],r+=p[q++];while(r>i&&q>1){s=[],q--;for(k=0;k<p.length;k++)p[k]>(s[k%q]||0)&&(s[k%q]=p[k]);r=s.reduce(function(a,b,c,d){return a+b})}var t=[];for(var u=0,v=0;u<q;u++)t[u]=v,v+=s[u];n.attr("transform",function(a,b){return"translate("+t[b%q]+","+(5+Math.floor(b/q)*20)+")"}),m.attr("transform","translate("+(b-a.right-r)+","+a.top+")"),c=a.top+a.bottom+Math.ceil(p.length/q)*20}else{var w=5,x=5,y=0,z;n.attr("transform",function(c,d){var e=d3.select(this).select("text").node().getComputedTextLength()+28;return z=x,b<a.left+a.right+z+e&&(x=z=5,w+=20),x+=e,x>y&&(y=x),"translate("+z+","+w+")"}),m.attr("transform","translate("+(b-a.right-y)+","+a.top+")"),c=a.top+a.bottom+w+15}}),h}var a={top:5,right:0,bottom:5,left:0},b=400,c=20,d=function(a){return a.key},e=d3.scale.category20().range(),f=!0,g=d3.dispatch("legendClick","legendDblclick","legendMouseover","legendMouseout");return h.dispatch=g,h.margin=function(b){return arguments.length?(a=b,h):a},h.width=function(a){return arguments.length?(b=a,h):b},h.height=function(a){return arguments.length?(c=a,h):c},h.key=function(a){return arguments.length?(d=a,h):d},h.color=function(a){return arguments.length?(e=a,h):e},h.align=function(a){return arguments.length?(f=a,h):f},h},a.models.line=function(){function s(a){return a.each(function(a){var r=c-b.left-b.right,s=d-b.top-b.bottom,t=d3.select(this);l=o.xScale(),m=o.yScale(),p=p||l,q=q||m;var u=t.selectAll("g.wrap.line").data([a]),v=u.enter().append("g").attr("class","wrap nvd3 line"),w=v.append("defs"),z=v.append("g"),A=u.select("g");z.append("g").attr("class","groups"),z.append("g").attr("class","scatterWrap");var B=u.select(".scatterWrap");o.width(r).height(s),d3.transition(B).call(o),u.attr("transform","translate("+b.left+","+b.top+")"),w.append("clipPath").attr("id","edge-clip-"+f).append("rect"),u.select("#edge-clip-"+f+" rect").attr("width",r).attr("height",s),A.attr("clip-path",k?"url(#edge-clip-"+f+")":""),B.attr("clip-path",k?"url(#edge-clip-"+f+")":"");var C=u.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%e.length]}).style("stroke",function(a,b){return e[b%e.length]}),d3.transition(C).style("stroke-opacity",1).style("fill-opacity",.5);var D=C.selectAll("path.area").data(function(a){return[a]});D.enter().append("path").filter(j).attr("class","area").attr("d",function(a){return d3.svg.area().interpolate(n).defined(i).x(function(a,b){return p(g(a,b))}).y0(function(a,b){return q(h(a,b))}).y1(function(a,b){return q(m.domain()[0]<=0?m.domain()[1]>=0?0:m.domain()[1]:m.domain()[0])}).apply(this,[a.values])}),d3.transition(C.exit().selectAll("path.area")).attr("d",function(a){return d3.svg.area().interpolate(n).defined(i).x(function(a,b){return p(g(a,b))}).y0(function(a,b){return q(h(a,b))}).y1(function(a,b){return q(m.domain()[0]<=0?m.domain()[1]>=0?0:m.domain()[1]:m.domain()[0])}).apply(this,[a.values])}),d3.transition(D.filter(j)).attr("d",function(a){return d3.svg.area().interpolate(n).defined(i).x(function(a,b){return p(g(a,b))}).y0(function(a,b){return q(h(a,b))}).y1(function(a,b){return q(m.domain()[0]<=0?m.domain()[1]>=0?0:m.domain()[1]:m.domain()[0])}).apply(this,[a.values])});var E=C.selectAll("path.line").data(function(a){return[a.values]});E.enter().append("path").attr("class",function(a){return"line"}).attr("d",d3.svg.line().interpolate(n).defined(i).x(function(a,b){return p(g(a,b))}).y(function(a,b){return q(h(a,b))})),d3.transition(C.exit().selectAll("path.line")).attr("d",d3.svg.line().interpolate(n).defined(i).x(function(a,b){return l(g(a,b))}).y(function(a,b){return m(h(a,b))})),d3.transition(E).attr("d",d3.svg.line().interpolate(n).defined(i).x(function(a,b){return l(g(a,b))}).y(function(a,b){return m(h(a,b))})),p=l.copy(),q=m.copy()}),s}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=function(a,b){return!isNaN(h(a,b))&&h(a,b)!==null},j=function(a){return a.area},k=!1,l,m,n="linear",o=a.models.scatter().id(f).size(16).sizeDomain([16,256]),p,q,r;return s.dispatch=o.dispatch,d3.rebind(s,o,"interactive","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius"),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.x=function(a){return arguments.length?(g=a,o.x(a),s):g},s.y=function(a){return arguments.length?(h=a,o.y(a),s):h},s.clipEdge=function(a){return arguments.length?(k=a,s):k},s.color=function(a){return arguments.length?(e=a,o.color(a),s):e},s.id=function(a){return arguments.length?(f=a,s):f},s.interpolate=function(a){return arguments.length?(n=a,s):n},s.defined=function(a){return arguments.length?(i=a,s):i},s.isArea=function(a){return arguments.length?(j=d3.functor(a),s):j},s},a.models.lineChart=function(){function q(a){return a.each(function(h){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;i=k.xScale(),j=k.yScale();var v=r.selectAll("g.wrap.lineChart").data([h]),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 z=v.select("g");f&&(n.width(t),z.select(".legendWrap").datum(h).call(n),b.top!=n.height()&&(b.top=n.height(),u=(e||parseInt(r.style("height"))||400)-b.top-b.bottom),z.select(".legendWrap").attr("transform","translate(0,"+ -b.top+")")),k.width(t).height(u).color(h.map(function(a,b){return a.color||c[b%c.length]}).filter(function(a,b){return!h[b].disabled})),z.attr("transform","translate("+b.left+","+b.top+")");var A=z.select(".linesWrap").datum(h.filter(function(a){return!a.disabled}));d3.transition(A).call(k),l.scale(i).ticks(t/100).tickSize(-u,0),z.select(".x.axis").attr("transform","translate(0,"+j.range()[0]+")"),d3.transition(z.select(".x.axis")).call(l),m.scale(j).ticks(u/36).tickSize(-t,0),d3.transition(z.select(".y.axis")).call(m),n.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,h.filter(function(a){return!a.disabled}).length||h.map(function(a){return a.disabled=!1,v.selectAll(".series").classed("disabled",!1),a}),a.transition().call(q)}),o.on("tooltipShow",function(a){g&&p(a,s.parentNode)})}),q.update=function(){q(a)},q.container=this,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,j,k=a.models.line(),l=a.models.axis().orient("bottom").tickPadding(5),m=a.models.axis().orient("left"),n=a.models.legend().height(30),o=d3.dispatch("tooltipShow","tooltipHide"),p=function(b,c){if(c){var d=d3.select(c).select("svg"),e=d.attr("viewBox");if(e){e=e.split(" ");var f=parseInt(d.style("width"))/e[2];b.pos[0]=b.pos[0]*f,b.pos[1]=b.pos[1]*f}}var g=b.pos[0]+(c.offsetLeft||0),i=b.pos[1]+(c.offsetTop||0),j=l.tickFormat()(k.x()(b.point,b.pointIndex)),n=m.tickFormat()(k.y()(b.point,b.pointIndex)),o=h(b.series.key,j,n,b,q);a.tooltip.show([g,i],o)};return k.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],o.tooltipShow(a)}),k.dispatch.on("elementMouseout.tooltip",function(a){o.tooltipHide(a)}),o.on("tooltipHide",function(){g&&a.tooltip.cleanup()}),q.dispatch=o,q.legend=n,q.xAxis=l,q.yAxis=m,d3.rebind(q,k,"defined","isArea","x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id","interpolate"),q.margin=function(a){return arguments.length?(b=a,q):b},q.width=function(a){return arguments.length?(d=a,q):d},q.height=function(a){return arguments.length?(e=a,q):e},q.color=function(a){return arguments.length?(c=a,n.color(a),q):c},q.showLegend=function(a){return arguments.length?(f=a,q):f},q.tooltips=function(a){return arguments.length?(g=a,q):g},q.tooltipContent=function(a){return arguments.length?(h=a,q):h},q},a.models.linePlusBarChart=function(){function v(j){return 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]);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/2),H.select(".legendWrap").datum(o.map(function(a){return a.originalKey=a.originalKey===undefined?a.key:a.originalKey,a.key=a.originalKey+(a.bar?" (left axis)":" (right axis)"),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("+z/2+","+ -b.top+")")),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 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")).style("opacity",B.length?1:0).call(q),r.ticks(A/36).tickSize(B.length?0:-z,0),H.select(".y2.axis").style("opacity",C.length?1:0).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){return a.disabled=!1,F.selectAll(".series").classed("disabled",!1),a}),j.transition().call(v)}),k.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],t.tooltipShow(a)}),i&&t.on("tooltipShow",function(a){u(a,y.parentNode)}),k.dispatch.on("elementMouseout.tooltip",function(a){t.tooltipHide(a)}),i&&t.on("tooltipHide",a.tooltip.cleanup),l.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],t.tooltipShow(a)}),i&&t.on("tooltipShow",function(a){u(a,y.parentNode)}),l.dispatch.on("elementMouseout.tooltip",function(a){t.tooltipHide(a)}),i&&t.on("tooltipHide",a.tooltip.cleanup),v.update=function(){j.transition().call(v)},v.container=this}),v}var b={top:30,right:60,bottom:50,left:60},c=null,d=null,e=function(a){return a.x},f=function(a){return a.y},g=d3.scale.category20().range(),h=!0,i=!0,j=function(a,b,c,d,e){return"<h3>"+a+"</h3>"+"<p>"+c+" at "+b+"</p>"},k=a.models.line(),l=a.models.historicalBar(),m=d3.scale.linear(),n=l.yScale(),o=k.yScale(),p=a.models.axis().scale(m).orient("bottom").tickPadding(5),q=a.models.axis().scale(n).orient("left"),r=a.models.axis().scale(o).orient("right"),s=a.models.legend().height(30),t=d3.dispatch("tooltipShow","tooltipHide"),u=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=p.tickFormat()(k.x()(b.point,b.pointIndex)),g=(b.series.bar?q:r).tickFormat()(k.y()(b.point,b.pointIndex)),h=j(b.series.key,f,g,b,v);a.tooltip.show([d,e],h,b.value<0?"n":"s")};return 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,"defined","size","clipVoronoi","interpolate"),v.x=function(a){return arguments.length?(e=a,k.x(a),l.x(a),v):e},v.y=function(a){return arguments.length?(f=a,k.y(a),l.y(a),v):f},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.color=function(a){return arguments.length?(g=a,s.color(a),v):g},v.showLegend=function(a){return arguments.length?(h=a,v):h},v.tooltips=function(a){return arguments.length?(i=a,v):i},v.tooltipContent=function(a){return arguments.length?(j=a,v):j},v},a.models.lineWithFocusChart=function(){function y(j){return j.each(function(z){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)}function N(){O(),K.call(k),J.select(".focus .x.axis").call(q),J.select(".focus .y.axis").call(r)}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())}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.defined(k.defined()).width(C).height(E).x(k.x()).y(k.y()).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){return a.disabled=!1,F.selectAll(".series").classed("disabled",!1),a}),j.transition().call(y)}),k.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],v.tooltipShow(a)}),i&&v.on("tooltipShow",function(a){x(a,B.parentNode)}),k.dispatch.on("elementMouseout.tooltip",function(a){v.tooltipHide(a)}),i&&v.on("tooltipHide",a.tooltip.cleanup)}),y.update=function(){y(j)},y.container=this,y}var b={top:30,right:20,bottom:50,left:60},c={top:0,right:20,bottom:20,left:60},d=d3.scale.category20().range(),e=null,f=null,g=100,h=!0,i=!0,j=function(a,b,c,d,e){return"<h3>"+a+"</h3>"+"<p>"+c+" at "+b+"</p>"},k=a.models.line().clipEdge(!0),l=a.models.line().interactive(!1),m=k.xScale(),n=k.yScale(),o=l.xScale(),p=l.yScale(),q=a.models.axis().scale(m).orient("bottom").tickPadding(5),r=a.models.axis().scale(n).orient("left"),s=a.models.axis().scale(m).orient("bottom").tickPadding(5),t=a.models.axis().scale(p).orient("left"),u=a.models.legend().height(30),v=d3.dispatch("tooltipShow","tooltipHide"),w=d3.svg.brush().x(o),x=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=q.tickFormat()(k.x()(b.point,b.pointIndex)),g=r.tickFormat()(k.y()(b.point,b.pointIndex)),h=j(b.series.key,f,g,b,y);a.tooltip.show([d,e],h)};return y.dispatch=v,y.legend=u,y.xAxis=q,y.yAxis=r,y.x2Axis=s,y.y2Axis=t,d3.rebind(y,k,"defined","isArea","x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),y.margin=function(a){return arguments.length?(b=a,y):b},y.width=function(a){return arguments.length?(e=a,y):e},y.height=function(a){return arguments.length?(f=a,y):f},y.color=function(a){return arguments.length?(d=a,u.color(a),y):d},y.showLegend=function(a){return arguments.length?(h=a,y):h},y.tooltips=function(a){return arguments.length?(i=a,y):i},y.tooltipContent=function(a){return arguments.length?(j=a,y):j},y.interpolate=function(a){return arguments.length?(k.interpolate(a),l.interpolate(a),y):k.interpolate()},y},a.models.multiBar=function(){function t(u){return u.each(function(v){var w=c-b.left-b.right,z=d-b.top-b.bottom;l&&(v=d3.layout.stack().offset("zero").values(function(a){return a.values}).y(i)(v)),v=v.map(function(a,b){return a.values=a.values.map(function(a){return a.series=b,a}),a});var A=o&&p?[]:v.map(function(a){return a.values.map(function(a,b){return{x:h(a,b),y:i(a,b),y0:a.y0}})});e.domain(d3.merge(A).map(function(a){return a.x})).rangeBands([0,w],.1),f.domain(p||d3.extent(d3.merge(A).map(function(a){return a.y+(l?a.y0:0)}).concat(j))).range([z,0]);if(e.domain()[0]===e.domain()[1]||f.domain()[0]===f.domain()[1])singlePoint=!0;e.domain()[0]===e.domain()[1]&&(e.domain()[0]?e.domain([e.domain()[0]-e.domain()[0]*.01,e.domain()[1]+e.domain()[1]*.01]):e.domain([-1,1])),a.log(f.domain()),f.domain()[0]===f.domain()[1]&&(f.domain()[0]?f.domain([f.domain()[0]+f.domain()[0]*.01,f.domain()[1]-f.domain()[1]*.01]):f.domain([-1,1])),r=r||e,s=s||f;var B=d3.select(this).selectAll("g.wrap.multibar").data([v]),C=B.enter().append("g").attr("class","wrap nvd3 multibar"),D=C.append("defs"),E=C.append("g");E.append("g").attr("class","groups");var F=B.select("g");B.attr("transform","translate("+b.left+","+b.top+")"),D.append("clipPath").attr("id","edge-clip-"+g).append("rect"),B.select("#edge-clip-"+g+" rect").attr("width",w).attr("height",z),F.attr("clip-path",k?"url(#edge-clip-"+g+")":"");var G=B.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});G.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(G.exit()).selectAll("rect.bar").delay(function(a,b){return b*n/v[0].values.length}).attr("y",function(a){return l?s(a.y0):s(0)}).attr("height",0).remove(),G.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return m[b%m.length]}).style("stroke",function(a,b){return m[b%m.length]}),d3.transition(G).style("stroke-opacity",1).style("fill-opacity",.75);var H=G.selectAll("rect.bar").data(function(a){return a.values});H.exit().remove();var I=H.enter().append("rect").attr("class",function(a,b){return i(a,b)<0?"bar negative":"bar positive"}).attr("x",function(a,b,c){return l?0:c*e.rangeBand()/v.length}).attr("y",function(a){return s(l?a.y0:0)}).attr("height",0).attr("width",e.rangeBand()/(l?1:v.length));H.on("mouseover",function(a,b){d3.select(this).classed("hover",!0),q.elementMouseover({value:i(a,b),point:a,series:v[a.series],pos:[e(h(a,b))+e.rangeBand()*(l?v.length/2:a.series+.5)/v.length,f(i(a,b)+(l?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),q.elementMouseout({value:i(a,b),point:a,series:v[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){q.elementClick({value:i(a,b),point:a,series:v[a.series],pos:[e(h(a,b))+e.rangeBand()*(l?v.length/2:a.series+.5)/v.length,f(i(a,b)+(l?a.y0:0))],pointIndex:b,seriesIndex:a.series
|
|
,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(a,b){q.elementDblClick({value:i(a,b),point:a,series:v[a.series],pos:[e(h(a,b))+e.rangeBand()*(l?v.length/2:a.series+.5)/v.length,f(i(a,b)+(l?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}),H.attr("class",function(a,b){return i(a,b)<0?"bar negative":"bar positive"}).attr("transform",function(a,b){return"translate("+e(h(a,b))+",0)"}),l?d3.transition(H).delay(function(a,b){return b*n/v[0].values.length}).attr("y",function(a,b){return f(i(a,b)+(l?a.y0:0))}).attr("height",function(a,b){return Math.abs(f(a.y+(l?a.y0:0))-f(l?a.y0:0))}).each("end",function(){d3.transition(d3.select(this)).attr("x",function(a,b){return l?0:a.series*e.rangeBand()/v.length}).attr("width",e.rangeBand()/(l?1:v.length))}):d3.transition(H).delay(function(a,b){return b*n/v[0].values.length}).attr("x",function(a,b){return a.series*e.rangeBand()/v.length}).attr("width",e.rangeBand()/v.length).each("end",function(){d3.transition(d3.select(this)).attr("y",function(a,b){return i(a,b)<0?f(0):f(i(a,b))}).attr("height",function(a,b){return Math.abs(f(i(a,b))-f(0))})}),t.update=function(){t(u)},r=e.copy(),s=f.copy()}),t}var b={top:0,right:0,bottom:0,left:0},c=960,d=500,e=d3.scale.ordinal(),f=d3.scale.linear(),g=Math.floor(Math.random()*1e4),h=function(a){return a.x},i=function(a){return a.y},j=[0],k=!0,l=!1,m=d3.scale.category20().range(),n=1200,o,p,q=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout"),r,s;return t.dispatch=q,t.x=function(a){return arguments.length?(h=a,t):h},t.y=function(a){return arguments.length?(i=a,t):i},t.margin=function(a){return arguments.length?(b=a,t):b},t.width=function(a){return arguments.length?(c=a,t):c},t.height=function(a){return arguments.length?(d=a,t):d},t.xScale=function(a){return arguments.length?(e=a,t):e},t.yScale=function(a){return arguments.length?(f=a,t):f},t.xDomain=function(a){return arguments.length?(o=a,t):o},t.yDomain=function(a){return arguments.length?(p=a,t):p},t.forceY=function(a){return arguments.length?(j=a,t):j},t.stacked=function(a){return arguments.length?(l=a,t):l},t.clipEdge=function(a){return arguments.length?(k=a,t):k},t.color=function(a){return arguments.length?(m=a,t):m},t.id=function(a){return arguments.length?(g=a,t):g},t.delay=function(a){return arguments.length?(n=a,t):n},t},a.models.multiBarChart=function(){function t(a){return a.each(function(j){var u=d3.select(this),v=this,w=(c||parseInt(u.style("width"))||960)-b.left-b.right,z=(d||parseInt(u.style("height"))||400)-b.top-b.bottom;k=m.xScale(),l=m.yScale();var A=u.selectAll("g.wrap.multiBarWithLegend").data([j]),B=A.enter().append("g").attr("class","wrap nvd3 multiBarWithLegend").append("g");B.append("g").attr("class","x axis"),B.append("g").attr("class","y axis"),B.append("g").attr("class","barsWrap"),B.append("g").attr("class","legendWrap"),B.append("g").attr("class","controlsWrap");var C=A.select("g");g&&(p.width(w/2),C.select(".legendWrap").datum(j).call(p),b.top!=p.height()&&(b.top=p.height(),z=(d||parseInt(u.style("height"))||400)-b.top-b.bottom),C.select(".legendWrap").attr("transform","translate("+w/2+","+ -b.top+")")),m.width(w).height(z).color(j.map(function(a,b){return a.color||e[b%e.length]}).filter(function(a,b){return!j[b].disabled}));if(f){var D=[{key:"Grouped",disabled:m.stacked()},{key:"Stacked",disabled:!m.stacked()}];q.width(180).color(["#444","#444","#444"]),C.select(".controlsWrap").datum(D).attr("transform","translate(0,"+ -b.top+")").call(q)}C.attr("transform","translate("+b.left+","+b.top+")");var E=C.select(".barsWrap").datum(j.filter(function(a){return!a.disabled}));d3.transition(E).call(m),n.scale(k).ticks(w/100).tickSize(-z,0),C.select(".x.axis").attr("transform","translate(0,"+l.range()[0]+")"),d3.transition(C.select(".x.axis")).call(n);var F=C.select(".x.axis > g").selectAll("g");F.selectAll("line, text").style("opacity",1),h&&F.filter(function(a,b){return b%Math.ceil(j[0].values.length/(w/100))!==0}).selectAll("text, line").style("opacity",0),o.scale(l).ticks(z/36).tickSize(-w,0),d3.transition(C.select(".y.axis")).call(o),p.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,j.filter(function(a){return!a.disabled}).length||j.map(function(a){return a.disabled=!1,A.selectAll(".series").classed("disabled",!1),a}),a.transition().call(t)}),q.dispatch.on("legendClick",function(b,c){if(!b.disabled)return;D=D.map(function(a){return a.disabled=!0,a}),b.disabled=!1;switch(b.key){case"Grouped":m.stacked(!1);break;case"Stacked":m.stacked(!0)}a.transition().call(t)}),r.on("tooltipShow",function(a){i&&s(a,v.parentNode)}),t.update=function(){a.transition().call(t)},t.container=this}),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=!0,j=function(a,b,c,d,e){return"<h3>"+a+"</h3>"+"<p>"+c+" on "+b+"</p>"},k,l,m=a.models.multiBar().stacked(!1),n=a.models.axis().orient("bottom").highlightZero(!1).showMaxMin(!1),o=a.models.axis().orient("left"),p=a.models.legend().height(30),q=a.models.legend().height(30),r=d3.dispatch("tooltipShow","tooltipHide");n.tickFormat(function(a){return a}),o.tickFormat(d3.format(",.1f"));var s=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=n.tickFormat()(m.x()(b.point,b.pointIndex)),g=o.tickFormat()(m.y()(b.point,b.pointIndex)),h=j(b.series.key,f,g,b,t);a.tooltip.show([d,e],h,b.value<0?"n":"s")};return m.dispatch.on("elementMouseover.tooltip2",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],r.tooltipShow(a)}),m.dispatch.on("elementMouseout.tooltip",function(a){r.tooltipHide(a)}),r.on("tooltipHide",function(){i&&a.tooltip.cleanup()}),t.dispatch=r,t.legend=p,t.xAxis=n,t.yAxis=o,d3.rebind(t,m,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id","stacked","delay"),t.margin=function(a){return arguments.length?(b=a,t):b},t.width=function(a){return arguments.length?(c=a,t):c},t.height=function(a){return arguments.length?(d=a,t):d},t.color=function(a){return arguments.length?(e=a,p.color(a),t):e},t.showControls=function(a){return arguments.length?(f=a,t):f},t.showLegend=function(a){return arguments.length?(g=a,t):g},t.reduceXTicks=function(a){return arguments.length?(h=a,t):h},t.tooltips=function(a){return arguments.length?(i=a,t):i},t.tooltipContent=function(a){return arguments.length?(j=a,t):j},t},a.models.multiBarHorizontal=function(){function v(d){return d.each(function(p){var w=b-a.left-a.right,z=c-a.top-a.bottom;l&&(p=d3.layout.stack().offset("zero").values(function(a){return a.values}).y(h)(p)),p=p.map(function(a,b){return a.values=a.values.map(function(a){return a.series=b,a}),a});var A=q&&r?[]:p.map(function(a){return a.values.map(function(a,b){return{x:g(a,b),y:h(a,b),y0:a.y0}})});e.domain(q||d3.merge(A).map(function(a){return a.x})).rangeBands([0,z],.1),f.domain(r||d3.extent(d3.merge(A).map(function(a){return a.y+(l?a.y0:0)}).concat(i))),m&&!l?f.range([f.domain()[0]<0?n:0,w-(f.domain()[1]>0?n:0)]):f.range([0,w]),s=s||e,t=t||d3.scale.linear().domain(f.domain()).range([f(0),f(0)]);var B=d3.select(this).selectAll("g.wrap.multibarHorizontal").data([p]),C=B.enter().append("g").attr("class","wrap nvd3 multibarHorizontal"),D=C.append("defs"),E=C.append("g");E.append("g").attr("class","groups");var F=B.select("g");B.attr("transform","translate("+a.left+","+a.top+")");var G=B.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});G.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(G.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),G.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return k[b%k.length]}).style("stroke",function(a,b){return k[b%k.length]}),d3.transition(G).style("stroke-opacity",1).style("fill-opacity",.75);var H=G.selectAll("g.bar").data(function(a){return a.values});H.exit().remove();var I=H.enter().append("g").attr("transform",function(a,b,c){return"translate("+t(l?a.y0:0)+","+(l?0:c*e.rangeBand()/p.length+e(g(a,b)))+")"});I.append("rect").attr("width",0).attr("height",e.rangeBand()/(l?1:p.length)),H.on("mouseover",function(a,b){d3.select(this).classed("hover",!0),u.elementMouseover({value:h(a,b),point:a,series:p[a.series],pos:[f(h(a,b)+(l?a.y0:0)),e(g(a,b))+e.rangeBand()*(l?p.length/2:a.series+.5)/p.length],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),u.elementMouseout({value:h(a,b),point:a,series:p[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){u.elementClick({value:h(a,b),point:a,series:p[a.series],pos:[e(g(a,b))+e.rangeBand()*(l?p.length/2:a.series+.5)/p.length,f(h(a,b)+(l?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(a,b){u.elementDblClick({value:h(a,b),point:a,series:p[a.series],pos:[e(g(a,b))+e.rangeBand()*(l?p.length/2:a.series+.5)/p.length,f(h(a,b)+(l?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}),m&&!l?(I.append("text").attr("text-anchor",function(a,b){return h(a,b)<0?"end":"start"}),H.select("text").attr("y",e.rangeBand()/2).attr("dy","-.32em").text(function(a,b){return o(h(a,b))}),d3.transition(H).select("text").attr("x",function(a,b){return h(a,b)<0?-4:f(h(a,b))-f(0)+4})):H.selectAll("text").remove(),H.attr("class",function(a,b){return h(a,b)<0?"bar negative":"bar positive"}),l?d3.transition(H).attr("transform",function(a,b){return"translate("+f(a.y0)+","+(l?0:j*e.rangeBand()/p.length)+")"}).select("rect").attr("width",function(a,b){return Math.abs(f(h(a,b)+a.y0)-f(a.y0))}).attr("height",e.rangeBand()):d3.transition(H).attr("transform",function(a,b){return"translate("+(h(a,b)<0?f(h(a,b)):f(0))+","+(a.series*e.rangeBand()/p.length+e(g(a,b)))+")"}).select("rect").attr("height",e.rangeBand()/p.length).attr("width",function(a,b){return Math.abs(f(h(a,b))-f(0))}),v.update=function(){d.transition().call(v)},s=e.copy(),t=f.copy()}),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");return v.dispatch=u,v.x=function(a){return arguments.length?(g=a,v):g},v.y=function(a){return arguments.length?(h=a,v):h},v.margin=function(b){return arguments.length?(a=b,v):a},v.width=function(a){return arguments.length?(b=a,v):b},v.height=function(a){return arguments.length?(c=a,v):c},v.xScale=function(a){return arguments.length?(e=a,v):e},v.yScale=function(a){return arguments.length?(f=a,v):f},v.xDomain=function(a){return arguments.length?(q=a,v):q},v.yDomain=function(a){return arguments.length?(r=a,v):r},v.forceY=function(a){return arguments.length?(i=a,v):i},v.stacked=function(a){return arguments.length?(l=a,v):l},v.color=function(a){return arguments.length?(k=a,v):k},v.id=function(a){return arguments.length?(d=a,v):d},v.delay=function(a){return arguments.length?(p=a,v):p},v.showValues=function(a){return arguments.length?(m=a,v):m},v.valueFormat=function(a){return arguments.length?(o=a,v):o},v.valuePadding=function(a){return arguments.length?(n=a,v):n},v},a.models.multiBarHorizontalChart=function(){function t(i){return i.each(function(k){var l=d3.select(this),u=this,v=(c||parseInt(l.style("width"))||960)-b.left-b.right,w=(d||parseInt(l.style("height"))||400)-b.top-b.bottom,x=l.selectAll("g.wrap.multiBarHorizontalChart").data([k]),y=x.enter().append("g").attr("class","wrap nvd3 multiBarHorizontalChart").append("g");y.append("g").attr("class","x axis"),y.append("g").attr("class","y axis"),y.append("g").attr("class","barsWrap"),y.append("g").attr("class","legendWrap"),y.append("g").attr("class","controlsWrap"),b.top=o.height();var z=x.select("g");g&&(o.width(v/2),z.select(".legendWrap").datum(k).call(o),b.top!=o.height()&&(b.top=o.height(),w=(d||parseInt(l.style("height"))||400)-b.top-b.bottom),z.select(".legendWrap").attr("transform","translate("+v/2+","+ -b.top+")")),j.width(v).height(w).color(k.map(function(a,b){return a.color||e[b%e.length]}).filter(function(a,b){return!k[b].disabled})),f&&(p.width(180).color(["#444","#444","#444"]),z.select(".controlsWrap").datum(s).attr("transform","translate(0,"+ -b.top+")").call(p)),z.attr("transform","translate("+b.left+","+b.top+")");var A=z.select(".barsWrap").datum(k.filter(function(a){return!a.disabled}));d3.transition(A).call(j),m.ticks(w/24).tickSize(-v,0),z.select(".x.axis").transition().duration(0).call(m);var B=z.select(".x.axis").selectAll("g");B.selectAll("line, text").style("opacity",1),n.ticks(v/100).tickSize(-w,0),z.select(".y.axis").attr("transform","translate(0,"+w+")"),d3.transition(z.select(".y.axis")).call(n),o.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,k.filter(function(a){return!a.disabled}).length||k.map(function(a){return a.disabled=!1,x.selectAll(".series").classed("disabled",!1),a}),i.transition().call(t)}),p.dispatch.on("legendClick",function(a,b){if(!a.disabled)return;s=s.map(function(a){return a.disabled=!0,a}),a.disabled=!1;switch(a.key){case"Grouped":j.stacked(!1);break;case"Stacked":j.stacked(!0)}i.transition().call(t)}),j.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],q.tooltipShow(a)}),h&&q.on("tooltipShow",function(a){r(a,u.parentNode)}),j.dispatch.on("elementMouseout.tooltip",function(a){q.tooltipHide(a)}),h&&q.on("tooltipHide",a.tooltip.cleanup),t.update=function(){i.transition().call(t)},t.container=this}),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+" - "+b+"</h3>"+"<p>"+c+"</p>"},j=a.models.multiBarHorizontal().stacked(!1),k=j.xScale(),l=j.yScale(),m=a.models.axis().scale(k).orient("left").highlightZero(!1).showMaxMin(!1),n=a.models.axis().scale(l).orient("bottom"),o=a.models.legend().height(30),p=a.models.legend().height(30),q=d3.dispatch("tooltipShow","tooltipHide");m.tickFormat(function(a){return a}),n.tickFormat(d3.format(",.1f"));var r=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=m.tickFormat()(j.x()(b.point,b.pointIndex)),g=n.tickFormat()(j.y()(b.point,b.pointIndex)),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}];return 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){return arguments.length?(b=a,t):b},t.width=function(a){return arguments.length?(c=a,t):c},t.height=function(a){return arguments.length?(d=a,t):d},t.color=function(a){return arguments.length?(e=a,o.color(a),t):e},t.showControls=function(a){return arguments.length?(f=a,t):f},t.showLegend=function(a){return arguments.length?(g=a,t):g},t.tooltips=function(a){return arguments.length?(h=a,t):h},t.tooltipContent=function(a){return arguments.length?(i=a,t):i},t},a.models.ohlcBar=function(){function v(n){return n.each(function(n){var s=b-a.left-a.right,t=c-a.top-a.bottom;q.domain(o||d3.extent(n[0].values.map(e).concat(k))).range([0,s]),r.domain(p||[d3.min(n[0].values.map(j).concat(l)),d3.max(n[0].values.map(i).concat(l))]).range([t,0]);if(q.domain()[0]===q.domain()[1]||r.domain()[0]===r.domain()[1])singlePoint=!0;q.domain()[0]===q.domain()[1]&&(q.domain()[0]?q.domain([q.domain()[0]-q.domain()[0]*.01,q.domain()[1]+q.domain()[1]*.01]):q.domain([-1,1])),r.domain()[0]===r.domain()[1]&&(r.domain()[0]?r.domain([r.domain()[0]+r.domain()[0]*.01,r.domain()[1]-r.domain()[1]*.01]):r.domain([-1,1]));var v=d3.select(this).on("click",function(a,b){u.chartClick({data:a,index:b,pos:d3.event,id:d})}),w=d3.select(this).selectAll("g.wrap.historicalStock").data([n[0].values]),z=w.enter().append("g").attr("class","wrap nvd3 historicalStock"),A=z.append("g");A.append("g").attr("class","ticks"),w.attr("width",b).attr("height",c);var B=w.select("g").attr("transform","translate("+a.left+","+a.top+")");z.append("defs").append("clipPath").attr("id","chart-clip-path-"+d).append("rect"),w.select("#chart-clip-path-"+d+" rect").attr("width",s).attr("height",t),A.attr("clip-path",m?"url(#chart-clip-path-"+d+")":"");var C=A.append("g").attr("class","shiftWrap"),D=w.select(".ticks").selectAll(".tick").data(function(a){return a});D.exit().remove();var E=D.enter().append("path").attr("class",function(a,b){return g(a,b)>h(a,b)?"tick negative":"tick positive"}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),u.elementMouseover({point:a,series:n[0],pos:[q(e(a,b)),r(f(a,b))],pointIndex:b,seriesIndex:0,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),u.elementMouseout({point:a,series:n[0],pointIndex:b,seriesIndex:0,e:d3.event})}).on("click",function(a,b){u.elementClick({value:f(a,b),data:a,index:b,pos:[q(e(a,b)),r(f(a,b))],e:d3.event,id:d}),d3.event.stopPropagation()}).on("dblclick",function(a,b){u.elementDblClick({value:f(a,b),data:a,index:b,pos:[q(e(a,b)),r(f(a,b))],e:d3.event,id:d}),d3.event.stopPropagation()});D.attr("class",function(a,b){return g(a,b)>h(a,b)?"tick negative":"tick positive"}).attr("transform",function(a,b){return"translate("+q(e(a,b))+","+r(i(a,b))+")"}).attr("d",function(a,b){var c=s/n[0].values.length*.9;return"m0,0l0,"+(r(g(a,b))-r(i(a,b)))+"l"+ -c/2+",0l"+c/2+",0l0,"+(r(j(a,b))-r(g(a,b)))+"l0,"+(r(h(a,b))-r(j(a,b)))+"l"+c/2+",0l"+ -c/2+",0z"})}),v}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=function(a){return a.open},h=function(a){return a.close},i=function(a){return a.high},j=function(a){return a.low},k=[],l=[],m=!0,n=d3.scale.category20().range(),o,p,q=d3.scale.linear(),r=d3.scale.linear(),s=d3.svg.axis().scale(q).orient("bottom"),t=d3.svg.axis().scale(r).orient("left"),u=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return v.dispatch=u,v.x=function(a){return arguments.length?(e=a,v):e},v.y=function(a){return arguments.length?(f=a,v):f},v.open=function(a){return arguments.length?(g=a,v):g},v.close=function(a){return arguments.length?(h=a,v):h},v.high=function(a){return arguments.length?(i=a,v):i},v.low=function(a){return arguments.length?(j=a,v):j},v.margin=function(b){return arguments.length?(a=b,v):a},v.width=function(a){return arguments.length?(b=a,v):b},v.height=function(a){return arguments.length?(c=a,v):c},v.xScale=function(a){return arguments.length?(q=a,v):q},v.yScale=function(a){return arguments.length?(r=a,v):r},v.xDomain=function(a){return arguments.length?(o=a,v):o},v.yDomain=function(a){return arguments.length?(p=a,v):p},v.forceX=function(a){return arguments.length?(k=a,v):k},v.forceY=function(a){return arguments.length?(l=a,v):l},v.clipEdge=function(a){return arguments.length?(m=a,v):m},v.color=function(a){return arguments.length?(n=a,v):n},v.id=function(a){return arguments.length?(d=a,v):d},v},a.models.pie=function(){function n(i){return i.each(function(i){function A(a){var b=(a.startAngle+a.endAngle)*90/Math.PI-90;return b>90?b-180:b}function B(a){l||(a.innerRadius=0);var b=d3.interpolate(this._current,a);return this._current=b(0),function(a){return v(b(a))}}function C(a){a.innerRadius=0;var b=d3.interpolate({startAngle:0,endAngle:0},a);return function(a){return v(b(a))}}var n=b-a.left-a.right,o=c-a.top-a.bottom,p=Math.min(n,o)/2,q=d3.select(this).on("click",function(a,b){m.chartClick({data:a,index:b,pos:d3.event,id:g})}),r=q.selectAll(".wrap.pie").data([d(i[0])]),s=r.enter().append("g").attr("class","wrap nvd3 pie chart-"+g),t=s.append("g"),u=r.select("g");t.append("g").attr("class","pie"),r.attr("transform","translate("+a.left+","+a.top+")"),u.select(".pie").attr("transform","translate("+n/2+","+o/2+")");var v=d3.svg.arc().outerRadius(p-p/5);l&&v.innerRadius(p/2);var w=d3.layout.pie().sort(null).value(function(a){return a.disabled?0:f(a)}),x=r.select(".pie").selectAll(".slice").data(w);x.exit().remove();var y=x.enter().append("svg:g").attr("class","slice").on("mouseover",function(a,b){d3.select(this).classed("hover",!0),m.elementMouseover({label:e(a.data),value:f(a.data),point:a.data,pointIndex:b,pos:[d3.event.pageX,d3.event.pageY],id:g})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),m.elementMouseout({label:e(a.data),value:f(a.data),point:a.data,index:b,id:g})}).on("click",function(a,b){m.elementClick({label:e(a.data),value:f(a.data),point:a.data,index:b,pos:d3.event,id:g}),d3.event.stopPropagation()}).on("dblclick",function(a,b){m.elementDblClick({label:e(a.data),value:f(a.data),point:a.data,index:b,pos:d3.event,id:g}),d3.event.stopPropagation()});x.attr("fill",function(a,b){return h[b]}).attr("stroke",function(a,b){return h[b]});var z=y.append("svg:path").each(function(a){this._current=a});d3.transition(x.select("path")).attr("d",v).attrTween("d",B),j&&(y.append("text").attr("transform",function(a){return a.outerRadius=p+10,a.innerRadius=p+15,"translate("+v.centroid(a)+")"}).style("text-anchor","middle").style("fill","#000"),d3.transition(x.select("text")).attr("transform",function(a){return a.outerRadius=p+10,a.innerRadius=p+15,"translate("+v.centroid(a)+")"}).text(function(a,b){var c=(a.endAngle-a.startAngle)/(2*Math.PI);return a.value&&c>k?e(a.data):""}))}),n}var a={top:0,right:0,bottom:0,left:0},b=500,c=500,d=function(a){return a.values},e=function(a){return a.x},f=function(a){return a.y},g=Math.floor(Math.random()*1e4),h=d3.scale.category20().range(),i=d3.format(",.2f"),j=!0,k=.02,l=!1,m=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return n.dispatch=m,n.margin=function(b){return arguments.length?(a=b,n):a},n.width=function(a){return arguments.length?(b=a,n):b},n.height=function(a){return arguments.length?(c=a,n):c},n.values=function(a){return arguments.length?(d=a,n):d},n.x=function(a){return arguments.length?(e=a,n):e},n.y=function(a){return arguments.length?(f=d3.functor(a),n):f},n.showLabels=function(a){return arguments.length?(j=a,n):j},n.donut=function(a){return arguments.length?(l=a,n):l},n.id=function(a){return arguments.length?(g=a,n):g},n.color=function(a){return arguments.length?(h=a,n):h},n.valueFormat=function(a){return arguments.length?(i=a,n):i},n.labelThreshold=function(a){return arguments.length?(k=a,n):k},n},a.models.pieChart=function(){function m(f){return f.each(function(h){var n=d3.select(this),o=this,p=(c||parseInt(n.style("width"))||960)-b.left-b.right,q=(d||parseInt(n.style("height"))||400)-b.top-b.bottom,r=n.selectAll("g.wrap.pieChart").data([h]),s=r.enter().append("g").attr("class","wrap nvd3 pieChart").append("g");s.append("g").attr("class","pieWrap"),s.append("g").attr("class","legendWrap");var t=r.select("g");e&&(j.width(p).key(i.x()),r.select(".legendWrap").datum(i.values()(h[0])).call(j),b.top!=j.height()&&(b.top=j.height(),q=(d||parseInt(n.style("height"))||400)-b.top-b.bottom),r.select(".legendWrap").attr("transform","translate(0,"+ -b.top+")")),i.width(p).height(q),t.attr("transform","translate("+b.left+","+b.top+")");var u=t.select(".pieWrap").datum(h);d3.transition(u).call(i),j.dispatch.on("legendClick",function(a,b,c){a.disabled=!a.disabled,i.values()(h[0]).filter(function(a){return!a.disabled}).length||i.values()(h[0]).map(function(a){return a.disabled=!1,r.selectAll(".series").classed("disabled",!1),a}),f.transition().call(m)}),i.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],k.tooltipShow(a)}),g&&k.on("tooltipShow",function(a){l(a)}),i.dispatch.on("elementMouseout.tooltip",function(a){k.tooltipHide(a)}),g&&k.on("tooltipHide",a.tooltip.cleanup),m.update=function(){f.transition().call(m)},m.container=this}),m}var b={top:30,right:20,bottom:20,left:20},c=null,d=null,e=!0,f=d3.scale.category20().range(),g=!0,h=function(a,b,c,d){return"<h3>"+a+"</h3>"+"<p>"+b+"</p>"},i=a.models.pie(),j=a.models.legend().height(30),k=d3.dispatch("tooltipShow","tooltipHide"),l=function(b,c){var d=b.pos[0]+(c&&c.offsetLeft||0),e=b.pos[1]+(c&&c.offsetTop||0),f=i.valueFormat()(i.y()(b.point)),g=h(i.x()(b.point),f,b,m);a.tooltip.show([d,e],g,b.value<0?"n":"s")};return m.dispatch=k,m.pie=i,d3.rebind(m,i,"values","x","y","id","showLabels","donut","labelThreshold"),m.margin=function(a){return arguments.length?(b=a,m):b},m.width=function(a){return arguments.length?(c=a,m):c},m.height=function(a){return arguments.length?(d=a,m):d},m.color=function(a){return arguments.length?(f=a,j.color(a),i.color(a),m):f},m.showLegend=function(a){return arguments.length?(e=a,m):e},m.tooltips=function(a){return arguments.length?(g=a,m):g},m.tooltipContent=function(a){return arguments.length?(h=a,m):h},m},a.models.scatter=function(){function B(C){return C.each(function(B){function L(){if(!p)return!1;var b=d3.merge(B.map(function(a,b){return a.values.filter(q).map(function(a,c){return[f(i(a,c))*(Math.random()/1e12+1),g(j(a,c))*(Math.random()/1e12+1),b,c]})}));if(s){I.append("clipPath").attr("id","points-clip-"+e);var c=G.select("#points-clip-"+e).selectAll("circle").data(b);c.enter().append("circle").attr("r",t),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-"+e+")")}var d=d3.geom.voronoi(b).map(function(a,c){return{data:a,series:b[c][2],point:b[c][3]}}),h=G.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=B[b.series],d=c.values[b.point];dispatch.elementClick({point:d,series:c,pos:[f(i(d,b.point))+a.left,g(j(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];dispatch.elementMouseover({point:d,series:c,pos:[f(i(d,b.point))+a.left,g(j(d,b.point))+a.top],seriesIndex:b.series,pointIndex:b.point})}).on("mouseout",function(a,b){var c=B[a.series],d=c.values[a.point];dispatch.elementMouseout({point:d,series:c,seriesIndex:a.series,pointIndex:a.point})})}var C=b-a.left-a.right,D=c-a.top-a.bottom,E=d3.select(this);B=B.map(function(a,b){return a.values=a.values.map(function(a){return a.series=b,a}),a});var F=u&&v&&w?[]:d3.merge(B.map(function(a){return a.values.map(function(a,b){return{x:i(a,b),y:j(a,b),size:k(a,b)}})}));f.domain(u||d3.extent(F.map(function(a){return a.x}).concat(m))).range([0,C]),g.domain(v||d3.extent(F.map(function(a){return a.y}).concat(n))).range([D,0]),h.domain(w||d3.extent(F.map(function(a){return a.size}).concat(o))).range([16,256]);if(f.domain()[0]===f.domain()[1]||g.domain()[0]===g.domain()[1])singlePoint=!0;f.domain()[0]===f.domain()[1]&&(f.domain()[0]?f.domain([f.domain()[0]-f.domain()[0]*.01,f.domain()[1]+f.domain()[1]*.01]):f.domain([-1,1])),g.domain()[0]===g.domain()[1]&&(g.domain()[0]?g.domain([g.domain()[0]+g.domain()[0]*.01,g.domain()[1]-g.domain()[1]*.01]):g.domain([-1,1])),x=x||f,y=y||g,z=z||h;var G=E.selectAll("g.wrap.scatter").data([B]),H=G.enter().append("g").attr("class","wrap nvd3 scatter chart-"+e+(singlePoint?" single-point":"")),I=H.append("defs"),J=H.append("g"),K=G.select("g");J.append("g").attr("class","groups"),J.append("g").attr("class","point-paths"),G.attr("transform","translate("+a.left+","+a.top+")"),I.append("clipPath").attr("id","edge-clip-"+e).append("rect"),G.select("#edge-clip-"+e+" rect").attr("width",C).attr("height",D),K.attr("clip-path",r?"url(#edge-clip-"+e+")":"");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(i(a,b))+","+y(j(a,b))+")"}).attr("d",d3.svg.symbol().type(l).size(function(a,b){return h(k(a,b))})),d3.transition(M.exit().selectAll("path.point")).attr("transform",function(a,b){return"translate("+f(i(a,b))+","+g(j(a,b))+")"}).remove(),N.attr("class",function(a,b){return"point point-"+b}),d3.transition(N).attr("transform",function(a,b){return"translate("+f(i(a,b))+","+g(j(a,b))+")"}).attr("d",d3.svg.symbol().type(l).size(function(a,b){return h(k(a,b))})),clearTimeout(A),A=setTimeout(L,1e3),x=f.copy(),y=g.copy(),z=h.copy()}),B}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=d3.scale.linear(),g=d3.scale.linear(),h=d3.scale.linear(),i=function(a){return a.x},j=function(a){return a.y},k=function(a){return a.size},l=function(a){return a.shape||"circle"},m=[],n=[],o=[],p=!0,q=function(a){return!a.notActive},r=!1,s=!0,t=function(){return 25},u=null,v=null,w=null;singlePoint=!1,dispatch=d3.dispatch("elementClick","elementMouseover","elementMouseout");var x,y,z,A;return dispatch.on("elementMouseover.point",function(a){p&&d3.select(".chart-"+e+" .series-"+a.seriesIndex+" .point-"+a.pointIndex).classed("hover",!0)}),dispatch.on("elementMouseout.point",function(a){p&&d3.select(".chart-"+e+" .series-"+a.seriesIndex+" .point-"+a.pointIndex).classed("hover",!1)}),B.dispatch=dispatch,B.x=function(a){return arguments.length?(i=d3.functor(a),B):i},B.y=function(a){return arguments.length?(j=d3.functor(a),B):j},B.size=function(a){return arguments.length?(k=d3.functor(a),B):k},B.margin=function(b){return arguments.length?(a=b,B):a},B.width=function(a){return arguments.length?(b=a,B):b},B.height=function(a){return arguments.length?(c=a,B):c},B.xScale=function(a){return arguments.length?(f=a,B):f},B.yScale=function(a){return arguments.length?(g=a,B):g},B.zScale=function(a){return arguments.length?(h=a,B):h},B.xDomain=function(a){return arguments.length?(u=a,B):u},B.yDomain=function(a){return arguments.length?(v=a,B):v},B.sizeDomain=function(a){return arguments.length?(w=a,B):w},B.forceX=function(a){return arguments.length?(m=a,B):m},B.forceY=function(a){return arguments.length?(n=a,B):n},B.forceSize=function(a){return arguments.length?(o=a,B):o},B.interactive=function(a){return arguments.length?(p=a,B):p},B.pointActive=function(a){return arguments.length?(q=a,B):q},B.clipEdge=function(a){return arguments.length?(r=a,B):r},B.clipVoronoi=function(a){return arguments.length?(s=a,B):s},B.clipRadius=function(a){return arguments.length?(t=a,B):t},B.color=function(a){return arguments.length?(d=a,B):d},B.shape=function(a){return arguments.length?(l=a,B):l},B.id=function(a){return arguments.length?(e=a,B):e},B.singlePoint=function(a){return arguments.length?(singlePoint=a,B):singlePoint},B},a.models.scatterChart=function(){function D(a){return a.each(function(h){function I(){if(m)return H.select(".point-paths").style("pointer-events","all"),!1;H.select(".point-paths").style("pointer-events","none");var a=d3.mouse(this);f.distortion(l).focus(a[0]),g.distortion(l).focus(a[1]),H.select(".scatterWrap").datum(h.filter(function(a){return!a.disabled})).call(r),H.select(".x.axis").call(s),H.select(".y.axis").call(t),H.select(".distributionX").datum(h.filter(function(a){return!a.disabled})).call(w),H.select(".distributionY").datum(h.filter(function(a){return!a.disabled})).call(x)}var i=d3.select(this),o=this,p=(c||parseInt(i.style("width"))||960)-b.left-b.right,q=(d||parseInt(i.style("height"))||400)-b.top-b.bottom;f=r.xScale(),g=r.yScale(),z=z||f,A=A||g;var E=i.selectAll("g.wrap.scatterChart").data([h]),F=E.enter().append("g").attr("class","wrap nvd3 scatterChart chart-"+r.id()),G=F.append("g"),H=E.select("g");G.append("rect").attr("class","nvd3 background"),G.append("g").attr("class","x axis"),G.append("g").attr("class","y axis"),G.append("g").attr("class","scatterWrap"),G.append("g").attr("class","distWrap"),G.append("g").attr("class","legendWrap"),G.append("g").attr("class","controlsWrap"),E.attr("transform","translate("+b.left+","+b.top+")"),j&&(u.width(p/2),E.select(".legendWrap").datum(h).call(u),b.top!=u.height()&&(b.top=u.height(),q=(d||parseInt(i.style("height"))||400)-b.top-b.bottom),E.select(".legendWrap").attr("transform","translate("+p/2+","+ -b.top+")")),k&&(v.width(180).color(["#444"
|
|
]),H.select(".controlsWrap").datum(C).attr("transform","translate(0,"+ -b.top+")").call(v)),H.select(".background").attr("width",p).attr("height",q),r.width(p).height(q).color(h.map(function(a,b){return a.color||e[b%e.length]}).filter(function(a,b){return!h[b].disabled})),E.select(".scatterWrap").datum(h.filter(function(a){return!a.disabled})).call(r),s.scale(f).ticks(p/100).tickSize(-q,0),H.select(".x.axis").attr("transform","translate(0,"+g.range()[0]+")").call(s),t.scale(g).ticks(q/36).tickSize(-p,0),H.select(".y.axis").call(t),w.scale(f).width(p).color(h.map(function(a,b){return a.color||e[b%e.length]}).filter(function(a,b){return!h[b].disabled})),G.select(".distWrap").append("g").attr("class","distributionX").attr("transform","translate(0,"+g.range()[0]+")"),H.select(".distributionX").datum(h.filter(function(a){return!a.disabled})).call(w),x.scale(g).width(q).color(h.map(function(a,b){return a.color||e[b%e.length]}).filter(function(a,b){return!h[b].disabled})),G.select(".distWrap").append("g").attr("class","distributionY").attr("transform","translate(-"+x.size()+",0)"),H.select(".distributionY").datum(h.filter(function(a){return!a.disabled})).call(x),H.select(".background").on("mousemove",I),H.select(".background").on("click",function(){m=!m}),r.dispatch.on("elementClick.freezeFisheye",function(){m=!m}),v.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,l=b.disabled?0:2.5,H.select(".background").style("pointer-events",b.disabled?"none":"all"),H.select(".point-paths").style("pointer-events",b.disabled?"all":"none"),b.disabled?(f.distortion(l).focus(0),g.distortion(l).focus(0),H.select(".scatterWrap").call(r),H.select(".x.axis").call(s),H.select(".y.axis").call(t)):m=!1,D(a)}),u.dispatch.on("legendClick",function(b,c,d){b.disabled=!b.disabled,h.filter(function(a){return!a.disabled}).length||h.map(function(a){return a.disabled=!1,E.selectAll(".series").classed("disabled",!1),a}),D(a)}),r.dispatch.on("elementMouseover.tooltip",function(a){d3.select(".chart-"+r.id()+" .series-"+a.seriesIndex+" .distx-"+a.pointIndex).attr("y1",a.pos[1]-q),d3.select(".chart-"+r.id()+" .series-"+a.seriesIndex+" .disty-"+a.pointIndex).attr("x2",a.pos[0]+w.size()),a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],y.tooltipShow(a)}),y.on("tooltipShow",function(a){n&&B(a,o.parentNode)}),z=f.copy(),A=g.copy(),D.update=function(){D(a)},D.container=this}),D}var b={top:30,right:20,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=d3.fisheye.scale(d3.scale.linear).distortion(0),g=d3.fisheye.scale(d3.scale.linear).distortion(0),h=!1,i=!1,j=!0,k=!0,l=0,m=!1,n=!0,o=function(a,b,c){return"<strong>"+b+"</strong>"},p=function(a,b,c){return"<strong>"+c+"</strong>"},q=null,r=a.models.scatter().xScale(f).yScale(g),s=a.models.axis().orient("bottom").tickPadding(10),t=a.models.axis().orient("left").tickPadding(10),u=a.models.legend().height(30),v=a.models.legend().height(30),w=a.models.distribution().axis("x"),x=a.models.distribution().axis("y"),y=d3.dispatch("tooltipShow","tooltipHide"),z,A,B=function(c,d){var e=c.pos[0]+(d.offsetLeft||0),h=c.pos[1]+(d.offsetTop||0),i=c.pos[0]+(d.offsetLeft||0),j=g.range()[0]+b.top+(d.offsetTop||0),k=f.range()[0]+b.left+(d.offsetLeft||0),l=c.pos[1]+(d.offsetTop||0),m=s.tickFormat()(r.x()(c.point,c.pointIndex)),n=t.tickFormat()(r.y()(c.point,c.pointIndex));o!=null&&a.tooltip.show([i,j],o(c.series.key,m,n,c,D),"n",1,null,"x-nvtooltip"),p!=null&&a.tooltip.show([k,l],p(c.series.key,m,n,c,D),"e",1,null,"y-nvtooltip"),q!=null&&a.tooltip.show([e,h],q(c.series.key,m,n,c,D),c.value<0?"n":"s")},C=[{key:"Magnify",disabled:!0}];return r.dispatch.on("elementMouseout.tooltip",function(a){y.tooltipHide(a),d3.select(".chart-"+r.id()+" .series-"+a.seriesIndex+" .distx-"+a.pointIndex).attr("y1",0),d3.select(".chart-"+r.id()+" .series-"+a.seriesIndex+" .disty-"+a.pointIndex).attr("x2",x.size())}),y.on("tooltipHide",function(){n&&a.tooltip.cleanup()}),D.dispatch=y,D.legend=u,D.controls=u,D.xAxis=s,D.yAxis=t,D.distX=w,D.distY=x,d3.rebind(D,r,"id","interactive","pointActive","shape","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius"),D.margin=function(a){return arguments.length?(b=a,D):b},D.width=function(a){return arguments.length?(c=a,D):c},D.height=function(a){return arguments.length?(d=a,D):d},D.color=function(a){return arguments.length?(e=a,u.color(a),w.color(a),x.color(a),D):e},D.showDistX=function(a){return arguments.length?(h=a,D):h},D.showDistY=function(a){return arguments.length?(i=a,D):i},D.showControls=function(a){return arguments.length?(k=a,D):k},D.showLegend=function(a){return arguments.length?(j=a,D):j},D.fisheye=function(a){return arguments.length?(l=a,D):l},D.tooltips=function(a){return arguments.length?(n=a,D):n},D.tooltipContent=function(a){return arguments.length?(q=a,D):q},D.tooltipXContent=function(a){return arguments.length?(o=a,D):o},D.tooltipYContent=function(a){return arguments.length?(p=a,D):p},D},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","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"})}),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","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)}),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 r(a){return a.each(function(a){var i=c-b.left-b.right,o=d-b.top-b.bottom;m=p.xScale(),n=p.yScale(),a=a.map(function(a,b){return a.values=a.values.map(function(b,c){return b.index=c,b.stackedY=a.disabled?0:h(b,c),b}),a}),a=d3.layout.stack().order(k).offset(j).values(function(a){return a.values}).x(g).y(function(a){return a.stackedY}).out(function(a,b,c){a.display={y:c,y0:b}})(a);var r=d3.select(this).selectAll("g.wrap.stackedarea").data([a]),s=r.enter().append("g").attr("class","wrap nvd3 stackedarea"),t=s.append("defs"),u=s.append("g"),v=r.select("g");u.append("g").attr("class","areaWrap"),p.width(i).height(o).x(g).y(function(a){return a.display.y+a.display.y0}).forceY([0]).color(a.map(function(a,b){return a.color||e[b%e.length]}).filter(function(b,c){return!a[c].disabled})),u.append("g").attr("class","scatterWrap");var w=v.select(".scatterWrap").datum(a.filter(function(a){return!a.disabled}));d3.transition(w).call(p),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",o),v.attr("clip-path",l?"url(#edge-clip-"+f+")":"");var z=d3.svg.area().x(function(a,b){return m(g(a,b))}).y0(function(a){return n(a.display.y0)}).y1(function(a){return n(a.display.y+a.display.y0)}),A=d3.svg.area().x(function(a,b){return m(g(a,b))}).y0(function(a){return n(a.display.y0)}).y1(function(a){return n(a.display.y0)}),B=v.select(".areaWrap").selectAll("path.area").data(function(a){return a});B.enter().append("path").attr("class",function(a,b){return"area area-"+b}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),q.areaMouseover({point:a,series:a.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:b})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),q.areaMouseout({point:a,series:a.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:b})}).on("click",function(a,b){d3.select(this).classed("hover",!1),q.areaClick({point:a,series:a.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:b})}),d3.transition(B.exit()).attr("d",function(a,b){return A(a.values,b)}).remove(),B.style("fill",function(a,b){return a.color||e[b%e.length]}).style("stroke",function(a,b){return a.color||e[b%e.length]}),d3.transition(B).attr("d",function(a,b){return z(a.values,b)}),p.dispatch.on("elementMouseover.area",function(a){v.select(".chart-"+f+" .area-"+a.seriesIndex).classed("hover",!0)}),p.dispatch.on("elementMouseout.area",function(a){v.select(".chart-"+f+" .area-"+a.seriesIndex).classed("hover",!1)})}),r}var b={top:0,right:0,bottom:0,left:0},c=960,d=500,e=d3.scale.category20().range(),f=Math.floor(Math.random()*1e5),g=function(a){return a.x},h=function(a){return a.y},i="stack",j="zero",k="default",l=!1,m,n,o=d3.layout.stack().values(function(a){return a.values}).x(g).y(function(a){return a.stackedY}).out(function(a,b,c){a.display={y:c,y0:b}}),p=a.models.scatter().size(2.2).sizeDomain([2.5]),q=d3.dispatch("tooltipShow","tooltipHide","areaClick","areaMouseover","areaMouseout");return p.dispatch.on("elementClick.area",function(a){q.areaClick(a)}),p.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],q.tooltipShow(a)}),p.dispatch.on("elementMouseout.tooltip",function(a){q.tooltipHide(a)}),r.dispatch=q,r.scatter=p,d3.rebind(r,p,"interactive","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius"),r.x=function(a){return arguments.length?(g=d3.functor(a),r):g},r.y=function(a){return arguments.length?(h=d3.functor(a),r):h},r.margin=function(a){return arguments.length?(b=a,r):b},r.width=function(a){return arguments.length?(c=a,r):c},r.height=function(a){return arguments.length?(d=a,r):d},r.clipEdge=function(a){return arguments.length?(l=a,r):l},r.color=function(a){return arguments.length?(e=a,r):e},r.offset=function(a){return arguments.length?(j=a,r):j},r.order=function(a){return arguments.length?(k=a,r):k},r.style=function(a){if(!arguments.length)return i;i=a;switch(i){case"stack":r.offset("zero"),r.order("default");break;case"stream":r.offset("wiggle"),r.order("inside-out");break;case"expand":r.offset("expand"),r.order("default")}return r},r},a.models.stackedAreaChart=function(){function t(a){return a.each(function(e){var i=d3.select(this),u=this,v=(c||parseInt(i.style("width"))||960)-b.left-b.right,w=(d||parseInt(i.style("height"))||400)-b.top-b.bottom;j=l.xScale(),k=l.yScale();var z=i.selectAll("g.wrap.stackedAreaChart").data([e]),A=z.enter().append("g").attr("class","wrap nvd3 stackedAreaChart").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");var B=z.select("g");g&&(o.width(v/2),B.select(".legendWrap").datum(e).call(o),b.top!=o.height()&&(b.top=o.height(),w=(d||parseInt(i.style("height"))||400)-b.top-b.bottom),B.select(".legendWrap").attr("transform","translate("+v/2+","+ -b.top+")")),l.width(v).height(w),f&&(p.width(280).color(["#444","#444","#444"]),B.select(".controlsWrap").datum(r).attr("transform","translate(0,"+ -b.top+")").call(p)),B.attr("transform","translate("+b.left+","+b.top+")");var C=B.select(".stackedWrap").datum(e);d3.transition(C).call(l),m.scale(j).ticks(v/100).tickSize(-w,0),B.select(".x.axis").attr("transform","translate(0,"+w+")"),d3.transition(B.select(".x.axis")).call(m),n.scale(k).ticks(l.offset()=="wiggle"?0:w/36).tickSize(-v,0).tickFormat(l.offset()=="expand"?d3.format("%"):d3.format(",.2f")),d3.transition(B.select(".y.axis")).call(n),l.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}):e=e.map(function(a,c){return a.disabled=c!=b.seriesIndex,a}),a.transition().call(t)}),o.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}),a.transition().call(t)}),p.dispatch.on("legendClick",function(b,c){if(!b.disabled)return;r=r.map(function(a){return a.disabled=!0,a}),b.disabled=!1;switch(b.key){case"Stacked":l.style("stack");break;case"Stream":l.style("stream");break;case"Expanded":l.style("expand")}a.transition().call(t)}),q.on("tooltipShow",function(a){h&&s(a,u.parentNode)})}),t.update=function(){a.transition().call(t)},t.container=this,t}var b={top:30,right:25,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!0,g=!0,h=!0,i=function(a,b,c,d,e){return"<h3>"+a+"</h3>"+"<p>"+c+" on "+b+"</p>"},j,k,l=a.models.stackedArea(),m=a.models.axis().orient("bottom").tickPadding(5),n=a.models.axis().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()(l.x()(b.point,b.pointIndex)),g=n.tickFormat()(l.y()(b.point,b.pointIndex)),h=i(b.series.key,f,g,b,t);a.tooltip.show([d,e],h,b.value<0?"n":"s")};return l.dispatch.on("tooltipShow",function(a){if(!Math.round(l.y()(a.point)*100))return setTimeout(function(){d3.selectAll(".point.hover").classed("hover",!1)},0),!1;a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],q.tooltipShow(a)}),l.dispatch.on("tooltipHide",function(a){q.tooltipHide(a)}),q.on("tooltipHide",function(){h&&a.tooltip.cleanup()}),t.dispatch=q,t.stacked=l,t.xAxis=m,t.yAxis=n,d3.rebind(t,l,"x","y","size","xScale","yScale","xDomain","yDomain","sizeDomain","interactive","offset","order","style","clipEdge","forceX","forceY","forceSize"),t.margin=function(a){return arguments.length?(b=a,t):b},t.width=function(a){return arguments.length?(c=a,t):getWidth},t.height=function(a){return arguments.length?(d=a,t):getHeight},t.color=function(a){return arguments.length?(e=a,o.color(a),t):e},t.showControls=function(a){return arguments.length?(f=a,t):f},t.showLegend=function(a){return arguments.length?(g=a,t):g},t.tooltips=function(a){return arguments.length?(h=a,t):h},t.tooltipContent=function(a){return arguments.length?(i=a,t):i},t}})(); |