From b4ca744451c88a1d38b678c3b55b33a13836aa96 Mon Sep 17 00:00:00 2001 From: Bob Monteverde Date: Thu, 14 Jun 2012 01:18:12 -0400 Subject: [PATCH] Lots of little bug and consistency fixes that are appearing as I create more examples --- nv.d3.js | 158 ++++++++++++++++++++++------ nv.d3.min.js | 8 +- src/d3.css | 4 +- src/models/lineChart.js | 30 ++++-- src/models/stackedArea.js | 3 +- src/models/stackedAreaWithLegend.js | 68 ++++++++---- 6 files changed, 199 insertions(+), 72 deletions(-) diff --git a/nv.d3.js b/nv.d3.js index b8ff781..1509d0c 100644 --- a/nv.d3.js +++ b/nv.d3.js @@ -1540,7 +1540,6 @@ nv.models.discreteBar = function() { var wrap = d3.select(this).selectAll('g.wrap.discretebar').data([data]); var wrapEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 discretebar'); - var defsEnter = wrapEnter.append('defs'); var gEnter = wrapEnter.append('g'); gEnter.append('g').attr('class', 'groups'); @@ -1830,6 +1829,7 @@ nv.models.discreteBarChart = function() { var wrap = container.selectAll('g.wrap.discreteBarWithAxes').data([data]); var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 discreteBarWithAxes').append('g'); + var defsEnter = gEnter.append('defs'); gEnter.append('g').attr('class', 'x axis'); gEnter.append('g').attr('class', 'y axis'); @@ -1849,6 +1849,41 @@ nv.models.discreteBarChart = function() { d3.transition(barsWrap).call(discretebar); + defsEnter.append('clipPath') + .attr('id', 'x-label-clip-' + discretebar.id()) + .append('rect') + + g.select('#x-label-clip-' + discretebar.id() + ' rect') + .attr('width', x.rangeBand() * (staggerLabels ? 2 : 1)) + .attr('height', 16) + .attr('x', -x.rangeBand() / (staggerLabels ? 1 : 2 )); + + /* + var evenLabelClips = defsEnter.append('clipPath') + .attr('id', 'x-label-clip-even-' + discretebar.id()) + .selectAll('rect') + .data(function(d) { return d[0].values.filter(function(d,i) { return i % 2 === 0 }) }); + + evenLabelClips.enter().append('rect') + .attr('width', x.rangeBand()) + .attr('height', 32) + .attr('y', y.range()[0]) + .attr('x', function(d,i) { return x(discretebar.x()(d,i)) }); + + var oddLabelClips = defsEnter.append('clipPath') + .attr('id', 'x-label-clip-odd-' + discretebar.id()) + .selectAll('rect') + .data(function(d) { return d[0].values.filter(function(d,i) { return i % 2 === 1 }) }); + + oddLabelClips.enter().append('rect') + .attr('width', x.rangeBand()) + .attr('height', 16) + .attr('y', y.range()[0] + 16 + (staggerLabels ? 12: 0)) + .attr('x', function(d,i) { return x(discretebar.x()(d,i)) }); + */ + + + xAxis .scale(x) .ticks( availableWidth / 100 ) @@ -1867,6 +1902,10 @@ nv.models.discreteBarChart = function() { .selectAll('text') .attr('transform', function(d,i,j) { return 'translate(0,' + (j % 2 == 0 ? '0' : '12') + ')' }) + xTicks + .selectAll('text') + .attr('clip-path', function(d,i,j) { return 'url(#x-label-clip-' + discretebar.id() + ')' }); + yAxis .scale(y) @@ -1888,6 +1927,12 @@ nv.models.discreteBarChart = function() { }); if (tooltips) dispatch.on('tooltipHide', nv.tooltip.cleanup); + + //TODO: decide if this makes sense to add into all the models for ease of updating (updating without needing the selection) + chart.update = function() { + selection.transition().call(chart); + } + }); return chart; @@ -1895,6 +1940,7 @@ nv.models.discreteBarChart = function() { chart.dispatch = dispatch; + chart.discretebar = discretebar; // really just makign the accessible for discretebar.dispatch, may rethink slightly chart.xAxis = xAxis; chart.yAxis = yAxis; @@ -2388,6 +2434,7 @@ nv.models.lineChart = function() { color = d3.scale.category20().range(), width = null, height = null, + showLegend = true, tooltip = function(key, x, y, e, graph) { return '

' + key + '

' + '

' + y + ' at ' + x + '

' @@ -2445,24 +2492,29 @@ nv.models.lineChart = function() { gEnter.append('g').attr('class', 'legendWrap'); + var g = wrap.select('g'); - //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend - margin.top = legend.height(); - var g = wrap.select('g') - .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + if (showLegend) { + //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend + margin.top = legend.height(); - legend.width(availableWidth / 2); + legend.width(availableWidth); + //legend.width(availableWidth / 2); - g.select('.legendWrap') - .datum(data) - .attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')') - .call(legend); + g.select('.legendWrap') + .datum(data) + .attr('transform', 'translate(0,' + (-margin.top) +')') + .call(legend); + } + g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + var linesWrap = g.select('.linesWrap') .datum(data.filter(function(d) { return !d.disabled })) @@ -2576,6 +2628,12 @@ nv.models.lineChart = function() { return chart; }; + chart.showLegend = function(_) { + if (!arguments.length) return showLegend; + showLegend = _; + return chart; + }; + return chart; } @@ -3886,7 +3944,7 @@ nv.models.multiBarWithLegend = function() { chart.xAxis = xAxis; chart.yAxis = yAxis; - d3.rebind(chart, multibar, 'x', 'y', 'xDomain', 'yDomain', 'forceX', 'forceY', 'clipEdge', 'id'); + d3.rebind(chart, multibar, 'x', 'y', 'xDomain', 'yDomain', 'forceX', 'forceY', 'clipEdge', 'id', 'stacked'); chart.margin = function(_) { @@ -4476,6 +4534,12 @@ nv.models.multiBarHorizontalChart = function() { }); if (tooltips) dispatch.on('tooltipHide', nv.tooltip.cleanup); + + //TODO: decide if this makes sense to add into all the models for ease of updating (updating without needing the selection) + chart.update = function() { + selection.transition().call(chart); + } + }); return chart; @@ -4483,6 +4547,7 @@ nv.models.multiBarHorizontalChart = function() { chart.dispatch = dispatch; + chart.multibar = multibar; // really just makign the accessible for multibar.dispatch, may rethink slightly chart.legend = legend; chart.xAxis = xAxis; chart.yAxis = yAxis; @@ -6035,7 +6100,8 @@ nv.models.stackedArea = function() { var path = g.select('.areaWrap').selectAll('path.area') - .data(function(d) { return d }); + //.data(function(d) { return d }); + .data(function(d) { return d }, function(d) { return d.key }); path.enter().append('path').attr('class', function(d,i) { return 'area area-' + i }) .on('mouseover', function(d,i) { d3.select(this).classed('hover', true); @@ -6202,7 +6268,9 @@ nv.models.stackedAreaWithLegend = function() { var margin = {top: 30, right: 20, bottom: 50, left: 60}, getWidth = function() { return 960 }, getHeight = function() { return 500 }, - color = d3.scale.category20().range(); + color = d3.scale.category20().range(), + showControls = true, + showLegend = true; var x = d3.scale.linear(), y = d3.scale.linear(), @@ -6252,7 +6320,10 @@ nv.models.stackedAreaWithLegend = function() { stacked .width(availableWidth) .height(availableHeight) - .color(color) + //.color(color) + .color(data.map(function(d,i) { + return d.color || color[i % 20]; + }).filter(function(d,i) { return !data[i].disabled })) var wrap = d3.select(this).selectAll('g.wrap.stackedAreaWithLegend').data([data]); @@ -6265,28 +6336,34 @@ nv.models.stackedAreaWithLegend = function() { gEnter.append('g').attr('class', 'controlsWrap'); + var g = wrap.select('g'); - //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend - margin.top = legend.height(); - var g = wrap.select('g') - .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + if (showLegend) { + //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend + margin.top = legend.height(); + legend + .width(width/2 - margin.right) + .color(color); - legend - .width(width/2 - margin.right) - .color(color); + g.select('.legendWrap') + .datum(data) + .attr('transform', 'translate(' + (width/2 - margin.left) + ',' + (-margin.top) +')') + .call(legend); + } + + + if (showControls) { + controls.width(280).color(['#444', '#444', '#444']); + g.select('.controlsWrap') + .datum(controlsData) + .attr('transform', 'translate(0,' + (-margin.top) +')') + .call(controls); + } - g.select('.legendWrap') - .datum(data) - .attr('transform', 'translate(' + (width/2 - margin.left) + ',' + (-margin.top) +')') - .call(legend); - controls.width(280).color(['#444', '#444', '#444']); - g.select('.controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); + g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); var stackedWrap = g.select('.stackedWrap') @@ -6428,9 +6505,13 @@ nv.models.stackedAreaWithLegend = function() { return chart; } + chart.dispatch = dispatch; + chart.stacked = stacked; + chart.xAxis = xAxis; + chart.yAxis = yAxis; - d3.rebind(chart, stacked, 'interactive', 'clipEdge', 'size'); + d3.rebind(chart, stacked, 'interactive', 'offset', 'order', 'style', 'clipEdge', 'size', 'forceX', 'forceY', 'forceSize'); chart.x = function(_) { if (!arguments.length) return getX; @@ -6464,9 +6545,18 @@ nv.models.stackedAreaWithLegend = function() { return chart; }; - chart.stacked = stacked; - chart.xAxis = xAxis; - chart.yAxis = yAxis; + chart.showControls = function(_) { + if (!arguments.length) return showControls; + showControls = _; + return chart; + }; + + chart.showLegend = function(_) { + if (!arguments.length) return showLegend; + showLegend = _; + return chart; + }; + return chart; } diff --git a/nv.d3.min.js b/nv.d3.min.js index 7683c83..a32b561 100644 --- a/nv.d3.min.js +++ b/nv.d3.min.js @@ -1,4 +1,4 @@ -(function(){function c(a,b,c){return function(d,e,f){var g=a(d),h=[];g1)while(gl+k&&(o=l-h-5);break;case"w":n=b[0]+e,o=b[1]-h/2,n+i>j&&(n=b[0]-i-e),ol+k&&(o=l-h-5);break;case"n":n=b[0]-i/2,o=b[1]+e,nj&&(n=j-i-5),o+h>l+k&&(o=b[1]-h-e);break;case"s":n=b[0]-i/2,o=b[1]-h-e,nj&&(n=j-i-5),l>o&&(o=b[1]+20)}f.style.left=n+"px",f.style.top=o+"px",f.style.opacity=1;return f},b.cleanup=function(){var a=document.getElementsByClassName("nvtooltip"),b=[];while(a.length)b.push(a[0]),a[0].style.transitionDelay="0 !important",a[0].style.opacity=0,a[0].className="nvtooltip-pending-removal";setTimeout(function(){while(b.length){var a=b.pop();a.parentNode.removeChild(a)}},500)}}(),a.utils.windowSize=function(){var a={width:640,height:480};document.body&&document.body.offsetWidth&&(a.width=document.body.offsetWidth,a.height=document.body.offsetHeight),document.compatMode=="CSS1Compat"&&document.documentElement&&document.documentElement.offsetWidth&&(a.width=document.documentElement.offsetWidth,a.height=document.documentElement.offsetHeight),window.innerWidth&&window.innerHeight&&(a.width=window.innerWidth,a.height=window.innerHeight);return a},a.utils.windowResize=function(a){var b=window.onresize;window.onresize=function(c){typeof b=="function"&&b(c),a(c)}},a.models.axis=function(){function e(f){f.each(function(e){(d.orient()=="top"||d.orient()=="bottom")&&d.ticks(Math.abs(a.range()[1]-a.range()[0])/100);var f=d3.select(this).selectAll("text.axislabel").data([b||null]);f.exit().remove();switch(d.orient()){case"top":f.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",0),f.attr("x",a.range()[1]/2);break;case"right":f.enter().append("text").attr("class","axislabel").attr("transform","rotate(90)").attr("y",-40),f.attr("x",-a.range()[0]/2);break;case"bottom":f.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",25),f.attr("x",a.range()[1]/2);break;case"left":f.enter().append("text").attr("class","axislabel").attr("transform","rotate(-90)").attr("y",-40),f.attr("x",-a.range()[0]/2)}f.text(function(a){return a}),d3.transition(d3.select(this)).call(d),c&&d3.select(this).selectAll("line.tick").filter(function(a){return!parseFloat(Math.round(a*1e5)/1e6)}).classed("zero",!0)});return e}var a=d3.scale.linear(),b=null,c=!0,d=d3.svg.axis().scale(a).orient("bottom").tickFormat(function(a){return a});d3.rebind(e,d,"orient","ticks","tickValues","tickSubdivide","tickSize","tickPadding","tickFormat"),d3.rebind(e,a,"domain","range","rangeBand","rangeBands"),e.axisLabel=function(a){if(!arguments.length)return b;b=a;return e},e.highlightZero=function(a){if(!arguments.length)return c;c=a;return e},e.scale=function(b){if(!arguments.length)return a;a=b,d.scale(a),d3.rebind(e,a,"domain","range","rangeBand","rangeBands");return e};return e},a.models.bar=function(){function q(r){r.each(function(q){l.domain(q.map(function(a,b){return a[e]})).rangeRoundBands([0,b-a.left-a.right],.1);var r=d3.min(q,function(a){return a[j]}),s=d3.max(q,function(a){return a[j]}),t=Math.max(-r,s),u=-t;r>=0&&(u=0),m.domain([u,t]).range([c-a.top-a.bottom,0]).nice(),n.ticks(b/100),o.ticks(c/36).tickSize(-(b-a.right-a.left),0);var v=d3.select(this).on("click",function(a,b){p.chartClick({data:a,index:b,pos:d3.event,id:h})}),w=v.selectAll("g.wrap").data([q]),z=w.enter();z.append("text").attr("class","title").attr("dy",".91em").attr("text-anchor","start").text(k),z=z.append("g").attr("class","nvd3 wrap").attr("id","wrap-"+h).append("g"),z.append("g").attr("class","x axis"),z.append("g").attr("class","y axis"),z.append("g").attr("class","bars"),w.attr("width",b).attr("height",c);var A=w.select("g").attr("transform","translate("+a.left+","+a.top+")"),B=w.select(".bars").selectAll(".bar").data(function(a){return a});B.exit().remove();var C=B.enter().append("svg:rect").attr("class",function(a){return a[j]<0?"bar negative":"bar positive"}).attr("fill",function(a,b){return i(b)}).attr("x",0).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),p.tooltipShow({label:a[e],value:a[j],data:a,index:b,pos:[d3.event.pageX,d3.event.pageY],id:h})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),p.tooltipHide({label:a[e],value:a[j],data:a,index:b,id:h})}).on("click",function(a,b){p.elementClick({label:a[e],value:a[j],data:a,index:b,pos:d3.event,id:h}),d3.event.stopPropagation()}).on("dblclick",function(a,b){p.elementDblClick({label:a[e],value:a[j],data:a,index:b,pos:d3.event,id:h}),d3.event.stopPropagation()});B.attr("class",function(a){return a[j]<0?"bar negative":"bar positive"}).attr("transform",function(a,b){return"translate("+l(a[e])+",0)"}).attr("width",l.rangeBand).order().transition().duration(d).attr("y",function(a){return m(Math.max(0,a[j]))}).attr("height",function(a){return Math.abs(m(a[j])-m(0))}),A.select(".x.axis").attr("transform","translate(0,"+m.range()[0]+")").call(n),f&&A.select(".x.axis").selectAll("text").attr("text-anchor","start").attr("transform",function(a){return"rotate(35)translate("+this.getBBox().height/2+","+"0"+")"}),g||(A.select(".x.axis").selectAll("text").attr("fill","rgba(0,0,0,0)"),A.select(".x.axis").selectAll("line").attr("style","opacity: 0")),A.select(".y.axis").call(o)});return q}var a={top:20,right:10,bottom:80,left:60},b=960,c=500,d=500,e="label",f=!0,g=!0,h=Math.floor(Math.random()*1e4),i=d3.scale.category20(),j="y",k="",l=d3.scale.ordinal(),m=d3.scale.linear(),n=d3.svg.axis().scale(l).orient("bottom"),o=d3.svg.axis().scale(m).orient("left"),p=d3.dispatch("chartClick","elementClick","elementDblClick","tooltipShow","tooltipHide");q.margin=function(b){if(!arguments.length)return a;a=b;return q},q.width=function(c){if(!arguments.length)return b;a.left+a.right+20>c?b=a.left+a.right+20:b=c;return q},q.height=function(b){if(!arguments.length)return c;a.top+a.bottom+20>b?c=a.top+a.bottom+20:c=b;return q},q.animate=function(a){if(!arguments.length)return d;d=a;return q},q.labelField=function(a){if(!arguments.length)return e;e=a;return q},q.dataField=function(a){if(!arguments.length)return j;j=a;return q},q.id=function(a){if(!arguments.length)return h;h=a;return q},q.rotatedLabel=function(a){if(!arguments.length)return f;f=a;return q},q.showLabels=function(a){if(!arguments.length)return g;g=a;return q},q.title=function(a){if(!arguments.length)return k;k=a;return q},q.xaxis={},d3.rebind(q.xaxis,n,"tickFormat"),q.yaxis={},d3.rebind(q.yaxis,o,"tickFormat"),q.dispatch=p;return q},a.models.historicalBar=function(){function r(g){g.each(function(g){var h=b-a.left-a.right,o=c-a.top-a.bottom;m.domain(k||d3.extent(g[0].values,e)).range([0,h]),n.domain(l||d3.extent(g[0].values,f)).range([o,0]);var p=d3.select(this).on("click",function(a,b){q.chartClick({data:a,index:b,pos:d3.event,id:d})}),r=d3.select(this).selectAll("g.wrap.bar").data([g[0].values]),s=r.enter().append("g").attr("class","wrap nvd3 bar"),t=s.append("g");t.append("g").attr("class","bars"),r.attr("width",b).attr("height",c);var u=r.select("g").attr("transform","translate("+a.left+","+a.top+")");s.append("defs").append("clipPath").attr("id","chart-clip-path-"+d).append("rect"),r.select("#chart-clip-path-"+d+" rect").attr("width",h).attr("height",o),t.attr("clip-path",i?"url(#chart-clip-path-"+d+")":"");var v=t.append("g").attr("class","shiftWrap"),w=r.select(".bars").selectAll(".bar").data(function(a){return a});w.exit().remove();var z=w.enter().append("svg:rect").attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("fill",function(a,b){return j[0]}).attr("x",0).attr("y",function(a,b){return n(Math.max(0,f(a,b)))}).attr("height",function(a,b){return Math.abs(n(f(a,b))-n(0))}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),q.elementMouseover({point:a,series:g[0],pos:[m(e(a,b)),n(f(a,b))],pointIndex:b,seriesIndex:0,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),q.elementMouseout({point:a,series:g[0],pointIndex:b,seriesIndex:0,e:d3.event})}).on("click",function(a,b){q.elementClick({value:f(a,b),data:a,index:b,pos:[m(e(a,b)),n(f(a,b))],e:d3.event,id:d}),d3.event.stopPropagation()}).on("dblclick",function(a,b){q.elementDblClick({value:f(a,b),data:a,index:b,pos:[m(e(a,b)),n(f(a,b))],e:d3.event,id:d}),d3.event.stopPropagation()});w.attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("transform",function(a,b){return"translate("+(m(e(a,b))-m(.5))+",0)"}).attr("width",m(.9)),d3.transition(w).attr("y",function(a,b){return n(Math.max(0,f(a,b)))}).attr("height",function(a,b){return Math.abs(n(f(a,b))-n(0))})});return r}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=Math.floor(Math.random()*1e4),e=function(a){return a.x},f=function(a){return a.y},g=[],h=[],i=!0,j=d3.scale.category20().range(),k,l,m=d3.scale.linear(),n=d3.scale.linear(),o=d3.svg.axis().scale(m).orient("bottom"),p=d3.svg.axis().scale(n).orient("left"),q=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");r.dispatch=q,r.x=function(a){if(!arguments.length)return e;e=a;return r},r.y=function(a){if(!arguments.length)return f;f=a;return r},r.margin=function(b){if(!arguments.length)return a;a=b;return r},r.width=function(c){if(!arguments.length)return b;a.left+a.right+20>c?b=a.left+a.right+20:b=c;return r},r.height=function(b){if(!arguments.length)return c;a.top+a.bottom+20>b?c=a.top+a.bottom+20:c=b;return r},r.xDomain=function(a){if(!arguments.length)return k;k=a;return r},r.yDomain=function(a){if(!arguments.length)return l;l=a;return r},r.forceX=function(a){if(!arguments.length)return g;g=a;return r},r.forceY=function(a){if(!arguments.length)return h;h=a;return r},r.clipEdge=function(a){if(!arguments.length)return i;i=a;return r},r.color=function(a){if(!arguments.length)return j;j=a;return r},r.id=function(a){if(!arguments.length)return d;d=a;return r};return r},a.models.bullet=function(){function k(a){a.each(function(a,k){var l=d.call(this,a,k).slice().sort(d3.descending),m=e.call(this,a,k).slice().sort(d3.descending),n=f.call(this,a,k).slice().sort(d3.descending),o=d3.select(this),p=d3.scale.linear().domain([0,Math.max(l[0],m[0],n[0])]).range(b?[g,0]:[0,g]),q=this.__chart__||d3.scale.linear().domain([0,Infinity]).range(p.range());this.__chart__=p;var r=function(a){return Math.abs(q(a)-q(0))},s=function(a){return Math.abs(p(a)-p(0))},t=o.selectAll("rect.range").data(l);t.enter().append("rect").attr("class",function(a,b){return"range s"+b}).attr("width",r).attr("height",h).attr("x",b?q:0).on("mouseover",function(a,b){j.elementMouseover({value:a,label:b<=0?"Maximum":b>1?"Minimum":"Mean",pos:[p(a),h/2]})}).on("mouseout",function(a,b){j.elementMouseout({value:a,label:b<=0?"Minimum":b>=1?"Maximum":"Mean"})}).transition().duration(c).attr("width",s).attr("x",b?p:0),t.transition().duration(c).attr("x",b?p:0).attr("width",s).attr("height",h);var u=o.selectAll("rect.measure").data(n);u.enter().append("rect").attr("class",function(a,b){return"measure s"+b}).attr("width",r).attr("height",h/3).attr("x",b?q:0).attr("y",h/3).on("mouseover",function(a){j.elementMouseover({value:a,label:"Current",pos:[p(a),h/2]})}).on("mouseout",function(a){j.elementMouseout({value:a,label:"Current"})}).transition().duration(c).attr("width",s).attr("x",b?p:0),u.transition().duration(c).attr("width",s).attr("height",h/3).attr("x",b?p:0).attr("y",h/3);var v=o.selectAll("path.markerTriangle").data(m),w=h/6;v.enter().append("path").attr("class","markerTriangle").attr("transform",function(a){return"translate("+q(a)+","+h/2+")"}).attr("d","M0,"+w+"L"+w+","+ -w+" "+ -w+","+ -w+"Z").on("mouseover",function(a,b){j.elementMouseover({value:a,label:"Previous",pos:[p(a),h/2]})}).on("mouseout",function(a,b){j.elementMouseout({value:a,label:"Previous"})}),v.transition().duration(c).attr("transform",function(a){return"translate("+p(a)+","+h/2+")"}),v.exit().remove();var x=i||p.tickFormat(8),y=o.selectAll("g.tick").data(p.ticks(8),function(a){return this.textContent||x(a)}),z=y.enter().append("g").attr("class","tick").attr("transform",function(a){return"translate("+q(a)+",0)"}).style("opacity",1e-6);z.append("line").attr("y1",h).attr("y2",h*7/6),z.append("text").attr("text-anchor","middle").attr("dy","1em").attr("y",h*7/6).text(x),z.transition().duration(c).attr("transform",function(a){return"translate("+p(a)+",0)"}).style("opacity",1);var A=y.transition().duration(c).attr("transform",function(a){return"translate("+p(a)+",0)"}).style("opacity",1);A.select("line").attr("y1",h).attr("y2",h*7/6),A.select("text").attr("y",h*7/6),y.exit().transition().duration(c).attr("transform",function(a){return"translate("+p(a)+",0)"}).style("opacity",1e-6).remove()}),d3.timer.flush()}var a="left",b=!1,c=0,d=function(a){return a.ranges},e=function(a){return a.markers},f=function(a){return a.measures},g=380,h=30,i=null,j=d3.dispatch("elementMouseover","elementMouseout");k.dispatch=j,k.orient=function(c){if(!arguments.length)return a;a=c,b=a=="right"||a=="bottom";return k},k.ranges=function(a){if(!arguments.length)return d;d=a;return k},k.markers=function(a){if(!arguments.length)return e;e=a;return k},k.measures=function(a){if(!arguments.length)return f;f=a;return k},k.width=function(a){if(!arguments.length)return g;g=a;return k},k.height=function(a){if(!arguments.length)return h;h=a;return k},k.tickFormat=function(a){if(!arguments.length)return i;i=a;return k},k.duration=function(a){if(!arguments.length)return c;c=a;return k};return k},a.models.cumulativeLine=function(){function B(a,b){return b.map(function(b,c){var d=h(b.values[a],a);return{key:b.key,values:b.values.map(function(a,b){return{x:g(a,b),y:(h(a,b)-d)/(1+d)}}),disabled:b.disabled,hover:b.hover}})}function A(a){a.each(function(f){var g=c(),h=d(),x=g-b.left-b.right,y=h-b.top-b.bottom,z=B(u.i,f),C=z.filter(function(a){return!k||!a.disabled}).map(function(a){return a.values});l.domain(d3.extent(d3.merge(C),function(a){return a.x})).range([0,x]),m.domain([0,f[0].values.length-1]).range([0,x]).clamp(!0),n.domain(d3.extent(d3.merge(C),function(a){return a.y})).range([y,0]),s.width(x).height(y).color(f.map(function(a,b){return a.color||e[b%10]}).filter(function(a,b){return!f[b].disabled}));var D=d3.select(this).classed("chart-"+i,!0).selectAll("g.wrap").data([z]),E=D.enter().append("g").attr("class","wrap nvd3 cumulativeLine").append("g");E.append("g").attr("class","x axis"),E.append("g").attr("class","y axis"),E.append("g").attr("class","linesWrap"),E.append("g").attr("class","legendWrap"),E.append("g").attr("class","controlsWrap"),b.top=q.height();var F=D.select("g").attr("transform","translate("+b.left+","+b.top+")");q.width(g/2-b.right),F.select(".legendWrap").datum(f).attr("transform","translate("+(g/2-b.left)+","+ -b.top+")").call(q),j&&(r.width(140).color(["#444","#444","#444"]),F.select(".controlsWrap").datum(v).attr("transform","translate(0,"+ -b.top+")").call(r));var G=F.select(".linesWrap").datum(z.filter(function(a){return!a.disabled}));d3.transition(G).call(s);var H=G.selectAll(".indexLine").data([u]);H.enter().append("rect").attr("class","indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).call(w),H.attr("transform",function(a){return"translate("+m(a.i)+",0)"}).attr("height",y),o.domain(l.domain()).range(l.range()).ticks(g/100).tickSize(-y,0),F.select(".x.axis").attr("transform","translate(0,"+n.range()[0]+")"),d3.transition(F.select(".x.axis")).call(o),p.domain(n.domain()).range(n.range()).ticks(h/36).tickSize(-x,0),d3.transition(F.select(".y.axis")).call(p),q.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,f.filter(function(a){return!a.disabled}).length||f.map(function(a){a.disabled=!1,D.selectAll(".series").classed("disabled",!1);return a}),a.transition().call(A)}),r.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,k=!b.disabled,a.transition().call(A)}),s.dispatch.on("elementMouseover.tooltip",function(a){t.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),s.dispatch.on("elementMouseout.tooltip",function(a){t.tooltipHide(a)})});return A}function z(a,b){d3.transition(d3.select(".chart-"+i)).call(A)}function y(a,b){a.x+=d3.event.dx,a.i=Math.round(m.invert(a.x)),d3.select(this).attr("transform","translate("+m(a.i)+",0)")}function x(a,b){}var b={top:30,right:20,bottom:30,left:60},c=function(){return 960},d=function(){return 500},e=d3.scale.category20().range(),f=function(){return 2.5},g=function(a){return a.x},h=function(a){return a.y},i=Math.floor(Math.random()*1e4),j=!0,k=!0,l=d3.scale.linear(),m=d3.scale.linear(),n=d3.scale.linear(),o=a.models.axis().scale(l).orient("bottom"),p=a.models.axis().scale(n).orient("left"),q=a.models.legend().height(30),r=a.models.legend().height(30),s=a.models.line(),t=d3.dispatch("tooltipShow","tooltipHide"),u={i:0,x:0},v=[{key:"Re-scale y-axis"}],w=d3.behavior.drag().on("dragstart",x).on("drag",y).on("dragend",z);A.dispatch=t,A.x=function(a){if(!arguments.length)return g;g=a;return A},A.y=function(a){if(!arguments.length)return h;h=a;return A},A.margin=function(a){if(!arguments.length)return b;b=a;return A},A.width=function(a){if(!arguments.length)return c;c=d3.functor(a);return A},A.height=function(a){if(!arguments.length)return d;d=d3.functor(a);return A},A.color=function(a){if(!arguments.length)return e;e=a,q.color(a);return A},A.dotRadius=function(a){if(!arguments.length)return f;f=d3.functor(a),s.dotRadius=a;return A},A.showRescaleToggle=function(a){if(!arguments.length)return j;j=a;return A},A.xAxis=o,A.yAxis=p;return A},a.models.discreteBar=function(){function r(d){d.each(function(s){var t=b-a.left-a.right,u=c-a.top-a.bottom;o=o||e,p=p||f,s=s.map(function(a,b){a.values=a.values.map(function(a){a.series=b;return a});return a});var v=m&&n?[]:s.map(function(a){return a.values.map(function(a,b){return{x:g(a,b),y:h(a,b),y0:a.y0}})});e.domain(m||d3.merge(v).map(function(a){return a.x})).rangeBands([0,t],.1),f.domain(n||d3.extent(d3.merge(v).map(function(a){return a.y}).concat(i))),k?f.range([u-(f.domain()[0]<0?12:0),f.domain()[1]<0?0:12]):f.range([u,0]);var w=d3.select(this).selectAll("g.wrap.discretebar").data([s]),z=w.enter().append("g").attr("class","wrap nvd3 discretebar"),A=z.append("defs"),B=z.append("g");B.append("g").attr("class","groups");var C=w.select("g");w.attr("transform","translate("+a.left+","+a.top+")");var D=w.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});D.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(D.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),D.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}),d3.transition(D).style("stroke-opacity",1).style("fill-opacity",.75);var E=D.selectAll("g.bar").data(function(a){return a.values});E.exit().remove();var F=E.enter().append("g").attr("transform",function(a,b,c){return"translate("+e(g(a,b))+", "+f(0)+")"}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),q.elementMouseover({value:h(a,b),point:a,series:s[a.series],pos:[e(g(a,b))+e.rangeBand()*(a.series+.5)/s.length,f(h(a,b))],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),q.elementMouseout({value:h(a,b),point:a,series:s[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){q.elementClick({value:h(a,b),point:a,series:s[a.series],pos:[e(g(a,b))+e.rangeBand()*(a.series+.5)/s.length,f(h(a,b))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(a,b){q.elementDblClick({value:h(a,b),point:a,series:s[a.series],pos:[e(g(a,b))+e.rangeBand()*(a.series+.5)/s.length,f(h(a,b))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()});F.append("rect").attr("height",0).attr("width",e.rangeBand()/s.length).style("fill",function(a,b){return a.color||j[b%10]}).style("stroke",function(a,b){return a.color||j[b%10]}),k?(F.append("text").attr("text-anchor","middle"),E.selectAll("text").attr("dx",e.rangeBand()/2).attr("dy",function(a,b){return h(a,b)<0?f(h(a,b))-f(0)+12:-4}).text(function(a,b){return l(h(a,b))})):E.selectAll("text").remove(),E.attr("class",function(a,b){return h(a,b)<0?"bar negative":"bar positive"}),d3.transition(E).attr("transform",function(a,b){return"translate("+e(g(a,b))+", "+(h(a,b)<0?f(0):f(h(a,b)))+")"}).selectAll("rect").attr("width",e.rangeBand()/s.length).attr("height",function(a,b){return Math.abs(f(h(a,b))-f(0))}),r.update=function(){d.transition().call(r)},o=e.copy(),p=f.copy()});return r}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=Math.floor(Math.random()*1e4),e=d3.scale.ordinal(),f=d3.scale.linear(),g=function(a){return a.x},h=function(a){return a.y},i=[0],j=d3.scale.category20().range(),k=!1,l=d3.format(",.2f"),m,n,o,p,q=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");r.dispatch=q,r.x=function(a){if(!arguments.length)return g;g=a;return r},r.y=function(a){if(!arguments.length)return h;h=a;return r},r.margin=function(b){if(!arguments.length)return a;a=b;return r},r.width=function(a){if(!arguments.length)return b;b=a;return r},r.height=function(a){if(!arguments.length)return c;c=a;return r},r.xScale=function(a){if(!arguments.length)return e;e=a;return r},r.yScale=function(a){if(!arguments.length)return f;f=a;return r},r.xDomain=function(a){if(!arguments.length)return m;m=a;return r},r.yDomain=function(a){if(!arguments.length)return n;n=a;return r},r.forceY=function(a){if(!arguments.length)return i;i=a;return r},r.color=function(a){if(!arguments.length)return j;j=a;return r},r.id=function(a){if(!arguments.length)return d;d=a;return r},r.showValues=function(a){if(!arguments.length)return k;k=a;return r},r.valuesFormat=function(a){if(!arguments.length)return l;l=a;return r};return r},a.models.discreteBarChart=function(){function q(e){e.each(function(e){var h=d3.select(this),p=(c||parseInt(h.style("width"))||960)-b.left-b.right,q=(d||parseInt(h.style("height"))||400)-b.top-b.bottom;i.width(p).height(q);var r=h.selectAll("g.wrap.discreteBarWithAxes").data([e]),s=r.enter().append("g").attr("class","wrap nvd3 discreteBarWithAxes").append("g");s.append("g").attr("class","x axis"),s.append("g").attr("class","y axis"),s.append("g").attr("class","barsWrap");var t=r.select("g");t.attr("transform","translate("+b.left+","+b.top+")");var u=t.select(".barsWrap").datum(e.filter(function(a){return!a.disabled}));d3.transition(u).call(i),l.scale(j).ticks(p/100).tickSize(-q,0),t.select(".x.axis").attr("transform","translate(0,"+(k.range()[0]+(i.showValues()?16:0))+")"),d3.transition(t.select(".x.axis")).call(l);var v=t.select(".x.axis").selectAll("g");f&&v.selectAll("text").attr("transform",function(a,b,c){return"translate(0,"+(c%2==0?"0":"12")+")"}),m.scale(k).ticks(q/36).tickSize(-p,0),d3.transition(t.select(".y.axis")).call(m),i.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],n.tooltipShow(a)}),g&&n.on("tooltipShow",function(a){o(a,h[0][0])}),i.dispatch.on("elementMouseout.tooltip",function(a){n.tooltipHide(a)}),g&&n.on("tooltipHide",a.tooltip.cleanup)});return q}var b={top:30,right:20,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!1,g=!0,h=function(a,b,c,d,e){return"

"+b+"

"+"

"+c+"

"},i=a.models.discreteBar(),j=i.xScale(),k=i.yScale(),l=a.models.axis().scale(j).orient("bottom").highlightZero(!1),m=a.models.axis().scale(k).orient("left"),n=d3.dispatch("tooltipShow","tooltipHide");l.tickFormat(function(a){return a}),m.tickFormat(d3.format(",.1f"));var o=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=l.tickFormat()(i.x()(b.point)),g=m.tickFormat()(i.y()(b.point)),j=h(b.series.key,f,g,b,q);a.tooltip.show([d,e],j,b.value<0?"n":"s")},p=[{key:"Grouped"},{key:"Stacked",disabled:!0}];q.dispatch=n,q.xAxis=l,q.yAxis=m,d3.rebind(q,i,"x","y","xDomain","yDomain","forceX","forceY","id","showValues","valueFormat"),q.margin=function(a){if(!arguments.length)return b;b=a;return q},q.width=function(a){if(!arguments.length)return c;c=d3.functor(a);return q},q.height=function(a){if(!arguments.length)return d;d=d3.functor(a);return q},q.color=function(a){if(!arguments.length)return e;e=a,i.color(a);return q},q.staggerLabels=function(a){if(!arguments.length)return f;f=a;return q},q.tooltips=function(a){if(!arguments.length)return g;g=a;return q},q.tooltipContent=function(a){if(!arguments.length)return h;h=a;return q};return q},a.models.discreteBarWithAxes=function(){function n(a){a.each(function(a){var e=c()-b.left-b.right,m=d()-b.top-b.bottom,n=a.filter(function(a){return!a.disabled}).map(function(a){return a.values.map(function(a,b){return{x:g.x()(a,b),y:g.y()(a,b)}})});g.width(e).height(m);var o=d3.select(this).selectAll("g.wrap.discreteBarWithAxes").data([a]),p=o.enter().append("g").attr("class","wrap nvd3 discreteBarWithAxes").append("g");p.append("g").attr("class","x axis"),p.append("g").attr("class","y axis"),p.append("g").attr("class","barsWrap");var q=o.select("g");q.attr("transform","translate("+b.left+","+b.top+")");var r=q.select(".barsWrap").datum(a.filter(function(a){return!a.disabled}));d3.transition(r).call(g),j.scale(h).ticks(e/100).tickSize(-m,0),q.select(".x.axis").attr("transform","translate(0,"+i.range()[0]+")"),d3.transition(q.select(".x.axis")).call(j);var s=q.select(".x.axis").selectAll("g");f&&s.selectAll("text").attr("transform",function(a,b,c){return"translate(0,"+(c%2==0?"0":"12")+")"}),k.scale(i).ticks(m/36).tickSize(-e,0),d3.transition(q.select(".y.axis")).call(k),g.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],l.tooltipShow(a)}),g.dispatch.on("elementMouseout.tooltip",function(a){l.tooltipHide(a)})});return n}var b={top:30,right:20,bottom:50,left:60},c=function(){return 960},d=function(){return 500},e=d3.scale.category20().range(),f=!1,g=a.models.discreteBar(),h=g.xScale(),i=g.yScale(),j=a.models.axis().scale(h).orient("bottom").highlightZero(!1),k=a.models.axis().scale(i).orient("left"),l=d3.dispatch("tooltipShow","tooltipHide"),m=[{key:"Grouped"},{key:"Stacked",disabled:!0}];n.dispatch=l,n.xAxis=j,n.yAxis=k,d3.rebind(n,g,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id"),n.margin=function(a){if(!arguments.length)return b;b=a;return n},n.width=function(a){if(!arguments.length)return c;c=d3.functor(a);return n},n.height=function(a){if(!arguments.length)return d;d=d3.functor(a);return n},n.color=function(a){if(!arguments.length)return e;e=a,g.color(a);return n},n.staggerLabels=function(a){if(!arguments.length)return f;f=a;return n};return n},a.models.legend=function(){function f(g){g.each(function(f){var g=d3.select(this).selectAll("g.legend").data([f]),h=g.enter().append("g").attr("class","nvd3 legend").append("g"),i=g.select("g").attr("transform","translate("+a.left+","+a.top+")"),j=i.selectAll(".series").data(function(a){return a}),k=j.enter().append("g").attr("class","series").on("mouseover",function(a,b){e.legendMouseover(a,b)}).on("mouseout",function(a,b){e.legendMouseout(a,b)}).on("click",function(a,b){e.legendClick(a,b)});k.append("circle").style("fill",function(a,b){return a.color||d[b%20]}).style("stroke",function(a,b){return a.color||d[b%20]}).style("stroke-width",2).attr("r",5),k.append("text").text(function(a){return a.key}).attr("text-anchor","start").attr("dy",".32em").attr("dx","8"),j.classed("disabled",function(a){return a.disabled}),j.exit().remove();var l=5,m=5,n=0,o;j.attr("transform",function(c,d){var e=d3.select(this).select("text").node().getComputedTextLength()+28;o=m,bn&&(n=m);return"translate("+o+","+l+")"}),i.attr("transform","translate("+(b-a.right-n)+","+a.top+")"),c=a.top+a.bottom+l+15});return f}var a={top:5,right:0,bottom:5,left:10},b=400,c=20,d=d3.scale.category20().range(),e=d3.dispatch("legendClick","legendMouseover","legendMouseout");f.dispatch=e,f.margin=function(b){if(!arguments.length)return a;a=b;return f},f.width=function(a){if(!arguments.length)return b;b=a;return f},f.height=function(a){if(!arguments.length)return c;c=a;return f},f.color=function(a){if(!arguments.length)return d;d=a;return f};return f},a.models.line=function(){function p(a){a.each(function(a){var o=c-b.left-b.right,p=d-b.top-b.bottom,q=d3.select(this).selectAll("g.wrap.line").data([a]),r=q.enter().append("g").attr("class","wrap nvd3 line"),s=r.append("defs"),t=r.append("g"),u=q.select("g");r.append("g").attr("class","scatterWrap");var v=q.select(".scatterWrap").datum(a);t.append("g").attr("class","groups"),j.width(o).height(p),d3.transition(v).call(j),q.attr("transform","translate("+b.left+","+b.top+")"),s.append("clipPath").attr("id","edge-clip-"+f).append("rect"),q.select("#edge-clip-"+f+" rect").attr("width",o).attr("height",p),u.attr("clip-path",i?"url(#edge-clip-"+f+")":""),v.attr("clip-path",i?"url(#edge-clip-"+f+")":"");var w=q.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});w.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(w.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),w.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return e[b%20]}).style("stroke",function(a,b){return e[b%20]}),d3.transition(w).style("stroke-opacity",1).style("fill-opacity",.5);var z=w.selectAll("path").data(function(a,b){return[a.values]});z.enter().append("path").attr("d",d3.svg.line().x(function(a,b){return m(g(a,b))}).y(function(a,b){return n(h(a,b))})),d3.transition(w.exit().selectAll("path")).attr("d",d3.svg.line().x(function(a,b){return k(g(a,b))}).y(function(a,b){return l(h(a,b))})).remove(),d3.transition(z).attr("d",d3.svg.line().x(function(a,b){return k(g(a,b))}).y(function(a,b){return l(h(a,b))})),m=k.copy(),n=l.copy()});return p}var b={top:0,right:0,bottom:0,left:0},c=960,d=500,e=d3.scale.category20().range(),f=Math.floor(Math.random()*1e4),g=function(a){return a.x},h=function(a){return a.y},i=!1,j=a.models.scatter().id(f).size(2.5).sizeDomain([2.5]),k=j.xScale(),l=j.yScale(),m=k,n=l,o;p.dispatch=j.dispatch,d3.rebind(p,j,"interactive","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius"),p.margin=function(a){if(!arguments.length)return b;b=a;return p},p.width=function(a){if(!arguments.length)return c;c=a;return p},p.height=function(a){if(!arguments.length)return d;d=a;return p},p.x=function(a){if(!arguments.length)return g;g=a,j.x(a);return p},p.y=function(a){if(!arguments.length)return h;h=a,j.y(a);return p -},p.clipEdge=function(a){if(!arguments.length)return i;i=a;return p},p.color=function(a){if(!arguments.length)return e;e=a,j.color(a);return p},p.id=function(a){if(!arguments.length)return f;f=a;return p};return p},a.models.lineChart=function(){function o(f){f.each(function(p){var q=d3.select(this),r=(d||parseInt(q.style("width"))||960)-b.left-b.right,s=(e||parseInt(q.style("height"))||400)-b.top-b.bottom;g.width(r).height(s).color(p.map(function(a,b){return a.color||c[b%10]}).filter(function(a,b){return!p[b].disabled}));var t=q.selectAll("g.wrap.lineWithLegend").data([p]),u=t.enter().append("g").attr("class","wrap nvd3 lineWithLegend").append("g");u.append("g").attr("class","x axis"),u.append("g").attr("class","y axis"),u.append("g").attr("class","linesWrap"),u.append("g").attr("class","legendWrap"),b.top=l.height();var v=t.select("g").attr("transform","translate("+b.left+","+b.top+")");l.width(r/2),v.select(".legendWrap").datum(p).attr("transform","translate("+r/2+","+ -b.top+")").call(l);var w=v.select(".linesWrap").datum(p.filter(function(a){return!a.disabled}));d3.transition(w).call(g),j.scale(h).ticks(r/100).tickSize(-s,0),v.select(".x.axis").attr("transform","translate(0,"+i.range()[0]+")"),d3.transition(v.select(".x.axis")).call(j),k.scale(i).ticks(s/36).tickSize(-r,0),d3.transition(v.select(".y.axis")).call(k),l.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,p.filter(function(a){return!a.disabled}).length||p.map(function(a){a.disabled=!1,t.selectAll(".series").classed("disabled",!1);return a}),f.transition().call(o)}),g.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],m.tooltipShow(a)}),m.on("tooltipShow",function(a){n(a,q[0][0])}),g.dispatch.on("elementMouseout.tooltip",function(a){m.tooltipHide(a)}),m.on("tooltipHide",a.tooltip.cleanup)}),o.update=function(){o(f)};return o}var b={top:30,right:20,bottom:50,left:60},c=d3.scale.category20().range(),d=null,e=null,f=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" at "+b+"

"},g=a.models.line(),h=g.xScale(),i=g.yScale(),j=a.models.axis().scale(h).orient("bottom"),k=a.models.axis().scale(i).orient("left"),l=a.models.legend().height(30),m=d3.dispatch("tooltipShow","tooltipHide"),n=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),h=j.tickFormat()(g.x()(b.point)),i=k.tickFormat()(g.y()(b.point)),l=f(b.series.key,h,i,b,o);a.tooltip.show([d,e],l)};o.dispatch=m,o.legend=l,o.xAxis=j,o.yAxis=k,d3.rebind(o,g,"x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),o.margin=function(a){if(!arguments.length)return b;b=a;return o},o.width=function(a){if(!arguments.length)return d;d=a;return o},o.height=function(a){if(!arguments.length)return e;e=a;return o};return o},a.models.linePlusBar=function(){function s(a){a.each(function(e){var t=c(),u=d(),v=t-b.left-b.right,w=u-b.top-b.bottom,y=e.filter(function(a){return!a.disabled&&a.bar}).map(function(a){return a.values.map(function(a,b){return{x:f(a,b),y:g(a,b)}})}),z=e.filter(function(a){return!a.disabled&&!a.bar}).map(function(a){return a.values.map(function(a,b){return{x:f(a,b),y:g(a,b)}})});j.domain(d3.extent(d3.merge(y.concat(z)),function(a){return a.x})).range([0,v]),k.domain(d3.extent(d3.merge(y),function(a){return a.y})).range([w,0]),l.domain(d3.extent(d3.merge(z),function(a){return a.y})).range([w,0]),q.width(v).height(w).color(e.map(function(a,b){return a.color||h[b%10]}).filter(function(a,b){return!e[b].disabled&&!e[b].bar})),r.width(v).height(w).color(e.map(function(a,b){return a.color||h[b%10]}).filter(function(a,b){return!e[b].disabled&&e[b].bar}));var A=d3.select(this).selectAll("g.wrap.linePlusBar").data([e]),B=A.enter().append("g").attr("class","wrap nvd3 linePlusBar").append("g");B.append("g").attr("class","x axis"),B.append("g").attr("class","y1 axis"),B.append("g").attr("class","y2 axis"),B.append("g").attr("class","barsWrap"),B.append("g").attr("class","linesWrap"),B.append("g").attr("class","legendWrap"),p.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,e.filter(function(a){return!a.disabled}).length||e.map(function(a){a.disabled=!1,A.selectAll(".series").classed("disabled",!1);return a}),a.transition().call(s)}),q.dispatch.on("elementMouseover.tooltip",function(a){i.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),q.dispatch.on("elementMouseout.tooltip",function(a){i.tooltipHide(a)}),r.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],i.tooltipShow(a)}),r.dispatch.on("elementMouseout.tooltip",function(a){i.tooltipHide(a)}),b.top=p.height();var C=A.select("g").attr("transform","translate("+b.left+","+b.top+")");p.width(t/2-b.right),C.select(".legendWrap").datum(e.map(function(a){a.key=a.key+(a.bar?" (left axis)":" (right axis)");return a})).attr("transform","translate("+(t/2-b.left)+","+ -b.top+")").call(p);var D=e.filter(function(a){return!a.disabled&&a.bar}),E=C.select(".barsWrap").datum(D.length?D:[{values:[]}]),F=C.select(".linesWrap").datum(e.filter(function(a){return!a.disabled&&!a.bar}));d3.transition(E).call(r),d3.transition(F).call(q),m.domain(j.domain()).range(j.range()).ticks(t/100).tickSize(-w,0),C.select(".x.axis").attr("transform","translate(0,"+k.range()[0]+")"),d3.transition(C.select(".x.axis")).call(m),n.domain(k.domain()).range(k.range()).ticks(u/36).tickSize(-v,0),d3.transition(C.select(".y1.axis")).call(n),o.domain(l.domain()).range(l.range()).ticks(u/36).tickSize(y.length?0:-v,0),C.select(".y2.axis").attr("transform","translate("+j.range()[1]+",0)"),d3.transition(C.select(".y2.axis")).call(o)});return s}var b={top:30,right:60,bottom:50,left:60},c=function(){return 960},d=function(){return 500},e=function(){return 2.5},f=function(a){return a.x},g=function(a){return a.y},h=d3.scale.category20().range(),i=d3.dispatch("tooltipShow","tooltipHide"),j=d3.scale.linear(),k=d3.scale.linear(),l=d3.scale.linear(),m=a.models.axis().scale(j).orient("bottom"),n=a.models.axis().scale(k).orient("left"),o=a.models.axis().scale(l).orient("right"),p=a.models.legend().height(30),q=a.models.line(),r=a.models.historicalBar();s.dispatch=i,s.legend=p,s.lines=q,s.bars=r,s.xAxis=m,s.yAxis1=n,s.yAxis2=o,s.x=function(a){if(!arguments.length)return f;f=a,q.x(a),r.x(a);return s},s.y=function(a){if(!arguments.length)return g;g=a,q.y(a),r.y(a);return s},s.margin=function(a){if(!arguments.length)return b;b=a;return s},s.width=function(a){if(!arguments.length)return c;c=d3.functor(a);return s},s.height=function(a){if(!arguments.length)return d;d=d3.functor(a);return s},s.dotRadius=function(a){if(!arguments.length)return e;e=d3.functor(a),q.dotRadius=a;return s},s.color=function(a){if(!arguments.length)return h;h=a,p.color(a);return s};return s},a.models.lineWithFocus=function(){function y(a){a.each(function(k){function L(){var a=x.empty()?o.domain():d3.extent(d3.merge(z).filter(function(a){return i(a)>=x.extent()[0]&&i(a)<=x.extent()[1]}),j);typeof a[0]=="undefined"&&(a=o.domain()),l.domain(x.empty()?n.domain():x.extent()),m.domain(a),u.xDomain(l.domain()),u.yDomain(m.domain())}function K(){L(),H.call(u),D.select(".x.axis").call(p),D.select(".y.axis").call(q)}var z=k.filter(function(a){return!a.disabled}).map(function(a){return a.values}),A=d-b.left-b.right,B=f-b.top-b.bottom,C=g-c.top-c.bottom;n.domain(d3.extent(d3.merge(z),i)).range([0,A]),o.domain(d3.extent(d3.merge(z),j)).range([C,0]),l.domain(x.empty()?n.domain():x.extent()).range([0,A]),m.domain(o.domain()).range([B,0]),x.on("brush",K),u.width(A).height(B).color(k.map(function(a,b){return a.color||h[b%10]}).filter(function(a,b){return!k[b].disabled})),v.width(A).height(C).color(k.map(function(a,b){return a.color||h[b%10]}).filter(function(a,b){return!k[b].disabled})),L();var D=d3.select(this).selectAll("g.wrap").data([k]),E=D.enter().append("g").attr("class","wrap nvd3 lineWithFocus").append("g");E.append("g").attr("class","focus"),E.append("g").attr("class","context"),E.append("g").attr("class","legendWrap");var F=D.select("g");t.width(d/2-b.right),F.select(".legendWrap").datum(k).attr("transform","translate("+A/2+",0)").call(t),b.top=t.height();var G=F.select(".focus").attr("transform","translate("+b.left+","+b.top+")");E.select(".focus").append("g").attr("class","x axis"),E.select(".focus").append("g").attr("class","y axis"),E.select(".focus").append("g").attr("class","focusLines");var H=G.select(".focusLines").datum(k.filter(function(a){return!a.disabled}));d3.transition(H).call(u),p.domain(l.domain()).range(l.range()).ticks(d/100).tickSize(-B,0),G.select(".x.axis").attr("transform","translate(0,"+m.range()[0]+")"),d3.transition(F.select(".x.axis")).call(p),q.domain(m.domain()).range(m.range()).ticks(e/36).tickSize(-A,0),d3.transition(F.select(".y.axis")).call(q);var I=F.select(".context").attr("transform","translate("+c.left+","+f+")");E.select(".context").append("g").attr("class","x2 axis"),E.select(".context").append("g").attr("class","y2 axis"),E.select(".context").append("g").attr("class","contextLines"),E.select(".context").append("g").attr("class","x brush").attr("class","x brush").call(x).selectAll("rect").attr("y",-5).attr("height",g+4);var J=I.select(".contextLines").datum(k.filter(function(a){return!a.disabled}));d3.transition(J).call(v),r.domain(n.domain()).range(n.range()).ticks(d/100).tickSize(-C,0),I.select(".x2.axis").attr("transform","translate(0,"+o.range()[0]+")"),d3.transition(I.select(".x2.axis")).call(r),s.domain(o.domain()).range(o.range()).ticks(C/24).tickSize(-A,0),I.select(".y2.axis"),d3.transition(I.select(".y2.axis")).call(s),t.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,k.filter(function(a){return!a.disabled}).length||k.map(function(a){a.disabled=!1,D.selectAll(".series").classed("disabled",!1);return a}),a.transition().call(y)}),u.dispatch.on("elementMouseover.tooltip",function(a){w.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),u.dispatch.on("elementMouseout.tooltip",function(a){w.tooltipHide(a)})});return y}var b={top:30,right:20,bottom:30,left:60},c={top:0,right:20,bottom:20,left:60},d=960,e=500,f=400,g=100,h=d3.scale.category20().range(),i=function(a){return a.x},j=function(a){return a.y},k=Math.floor(Math.random()*1e4),l=d3.scale.linear(),m=d3.scale.linear(),n=d3.scale.linear(),o=d3.scale.linear(),p=a.models.axis().scale(l).orient("bottom"),q=a.models.axis().scale(m).orient("left"),r=a.models.axis().scale(n).orient("bottom"),s=a.models.axis().scale(o).orient("left"),t=a.models.legend().height(30),u=a.models.line().clipEdge(!0),v=a.models.line().interactive(!1),w=d3.dispatch("tooltipShow","tooltipHide"),x=d3.svg.brush().x(n);y.dispatch=w,y.x=function(a){if(!arguments.length)return i;i=a,u.x(a),v.x(a);return y},y.y=function(a){if(!arguments.length)return j;j=a,u.y(a),v.y(a);return y},y.margin=function(a){if(!arguments.length)return b;b=a;return y},y.width=function(a){if(!arguments.length)return d;d=a;return y},y.height=function(a){if(!arguments.length)return e;e=a,f=a-g;return y},y.contextHeight=function(a){if(!arguments.length)return g;g=a,f=e-a;return y},y.id=function(a){if(!arguments.length)return k;k=a;return y},y.xTickFormat=function(a){if(!arguments.length)return l.tickFormat();p.tickFormat(a),r.tickFormat(a);return y},y.yTickFormat=function(a){if(!arguments.length)return m.tickFormat();q.tickFormat(a),s.tickFormat(a);return y},y.xAxis=p,y.yAxis=q;return y},a.models.lineWithLegend=function(){function m(a){a.each(function(n){var o=(d||parseInt(d3.select(this).style("width"))||960)-b.left-b.right,p=(e||parseInt(d3.select(this).style("height"))||400)-b.top-b.bottom;f.width(o).height(p).color(n.map(function(a,b){return a.color||c[b%10]}).filter(function(a,b){return!n[b].disabled}));var q=d3.select(this).selectAll("g.wrap.lineWithLegend").data([n]),r=q.enter().append("g").attr("class","wrap nvd3 lineWithLegend").append("g");r.append("g").attr("class","x axis"),r.append("g").attr("class","y axis"),r.append("g").attr("class","linesWrap"),r.append("g").attr("class","legendWrap"),b.top=k.height();var s=q.select("g").attr("transform","translate("+b.left+","+b.top+")");k.width(o/2),s.select(".legendWrap").datum(n).attr("transform","translate("+o/2+","+ -b.top+")").call(k);var t=s.select(".linesWrap").datum(n.filter(function(a){return!a.disabled}));d3.transition(t).call(f),i.domain(g.domain()).range(g.range()).ticks(o/100).tickSize(-p,0),s.select(".x.axis").attr("transform","translate(0,"+h.range()[0]+")"),d3.transition(s.select(".x.axis")).call(i),j.domain(h.domain()).range(h.range()).ticks(p/36).tickSize(-o,0),d3.transition(s.select(".y.axis")).call(j),k.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,n.filter(function(a){return!a.disabled}).length||n.map(function(a){a.disabled=!1,q.selectAll(".series").classed("disabled",!1);return a}),a.transition().call(m)}),f.dispatch.on("elementMouseover.tooltip",function(a){l.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),f.dispatch.on("elementMouseout.tooltip",function(a){l.tooltipHide(a)})}),b.top!=k.height()&&m(a);return m}var b={top:30,right:20,bottom:50,left:60},c=d3.scale.category20().range(),d,e,f=a.models.line(),g=f.xScale(),h=f.yScale(),i=a.models.axis().scale(g).orient("bottom"),j=a.models.axis().scale(h).orient("left"),k=a.models.legend().height(30),l=d3.dispatch("tooltipShow","tooltipHide");m.dispatch=l,m.legend=k,m.xAxis=i,m.yAxis=j,d3.rebind(m,f,"x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),m.margin=function(a){if(!arguments.length)return b;b=a;return m},m.width=function(a){if(!arguments.length)return d;d=a;return m},m.height=function(a){if(!arguments.length)return e;e=a;return m};return m},a.models.multiBar=function(){function r(s){s.each(function(t){var u=b-a.left-a.right,v=c-a.top-a.bottom;m=m||o,n=n||p,i&&(t=d3.layout.stack().offset("zero").values(function(a){return a.values}).y(f)(t)),t=t.map(function(a,b){a.values=a.values.map(function(a){a.series=b;return a});return a});var w=k&&l?[]:t.map(function(a){return a.values.map(function(a,b){return{x:e(a,b),y:f(a,b),y0:a.y0}})});o.domain(d3.merge(w).map(function(a){return a.x})).rangeBands([0,u],.1),p.domain(l||d3.extent(d3.merge(w).map(function(a){return a.y+(i?a.y0:0)}).concat(g))).range([v,0]);var z=d3.select(this).selectAll("g.wrap.multibar").data([t]),A=z.enter().append("g").attr("class","wrap nvd3 multibar"),B=A.append("defs"),C=A.append("g");C.append("g").attr("class","groups");var D=z.select("g");z.attr("transform","translate("+a.left+","+a.top+")"),B.append("clipPath").attr("id","edge-clip-"+d).append("rect"),z.select("#edge-clip-"+d+" rect").attr("width",u).attr("height",v),D.attr("clip-path",h?"url(#edge-clip-"+d+")":"");var E=z.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});E.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(E.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),E.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return j[b%10]}).style("stroke",function(a,b){return j[b%10]}),d3.transition(E).style("stroke-opacity",1).style("fill-opacity",.75);var F=E.selectAll("rect.bar").data(function(a){return a.values});F.exit().remove();var G=F.enter().append("rect").attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("x",function(a,b,c){return i?0:c*o.rangeBand()/t.length}).attr("y",function(a){return n(i?a.y0:0)}).attr("height",0).attr("width",o.rangeBand()/(i?1:t.length)).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),q.elementMouseover({value:f(a,b),point:a,series:t[a.series],pos:[o(e(a,b))+o.rangeBand()*(i?t.length/2:a.series+.5)/t.length,p(f(a,b)+(i?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),q.elementMouseout({value:f(a,b),point:a,series:t[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){q.elementClick({value:f(a,b),point:a,series:t[a.series],pos:[o(e(a,b))+o.rangeBand()*(i?t.length/2:a.series+.5)/t.length,p(f(a,b)+(i?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(a,b){q.elementDblClick({value:f(a,b),point:a,series:t[a.series],pos:[o(e(a,b))+o.rangeBand()*(i?t.length/2:a.series+.5)/t.length,p(f(a,b)+(i?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()});F.attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("transform",function(a,b){return"translate("+o(e(a,b))+",0)"}),i?d3.transition(F).delay(function(a,b){return b*1e3/t[0].values.length}).attr("y",function(a,b){return p(f(a,b)+(i?a.y0:0))}).attr("height",function(a,b){return Math.abs(p(a.y+(i?a.y0:0))-p(i?a.y0:0))}).each("end",function(){d3.transition(d3.select(this)).attr("x",function(a,b){return i?0:a.series*o.rangeBand()/t.length}).attr("width",o.rangeBand()/(i?1:t.length))}):d3.transition(F).delay(function(a,b){return b*1200/t[0].values.length}).attr("x",function(a,b){return a.series*o.rangeBand()/t.length}).attr("width",o.rangeBand()/t.length).each("end",function(){d3.transition(d3.select(this)).attr("y",function(a,b){return f(a,b)<0?p(0):p(f(a,b))}).attr("height",function(a,b){return Math.abs(p(f(a,b))-p(0))})}),r.update=function(){s.transition().call(r)},m=o.copy(),n=p.copy()});return r}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=Math.floor(Math.random()*1e4),e=function(a){return a.x},f=function(a){return a.y},g=[0],h=!0,i=!1,j=d3.scale.category20().range(),k,l,m,n,o=d3.scale.ordinal(),p=d3.scale.linear(),q=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");r.dispatch=q,r.x=function(a){if(!arguments.length)return e;e=a;return r},r.y=function(a){if(!arguments.length)return f;f=a;return r},r.margin=function(b){if(!arguments.length)return a;a=b;return r},r.width=function(a){if(!arguments.length)return b;b=a;return r},r.height=function(a){if(!arguments.length)return c;c=a;return r},r.xDomain=function(a){if(!arguments.length)return k;k=a;return r},r.yDomain=function(a){if(!arguments.length)return l;l=a;return r},r.forceY=function(a){if(!arguments.length)return g;g=a;return r},r.stacked=function(a){if(!arguments.length)return i;i=a;return r},r.clipEdge=function(a){if(!arguments.length)return h;h=a;return r},r.color=function(a){if(!arguments.length)return j;j=a;return r},r.id=function(a){if(!arguments.length)return d;d=a;return r};return r},a.models.multiBarWithLegend=function(){function q(a){a.each(function(r){var s=c()-b.left-b.right,t=d()-b.top-b.bottom,u;n.stacked()?u=r.filter(function(a){return!a.disabled}).reduce(function(a,b,c){b.values.forEach(function(b,d){c||(a[d]={x:n.x()(b,d),y:0}),a[d].y+=n.y()(b,d)});return a},[]):u=r.filter(function(a){return!a.disabled}).map(function(a){return a.values.map(function(a,b){return{x:n.x()(a,b),y:n.y()(a,b)}})}),h.domain(d3.merge(u).map(function(a){return a.x})).rangeBands([0,s],.1),i.domain(d3.extent(d3.merge(u).map(function(a){return a.y}).concat(n.forceY))).range([t,0]),n.width(s).height(t).color(r.map(function(a,b){return a.color||e[b%20]}).filter(function(a,b){return!r[b].disabled}));var v=d3.select(this).selectAll("g.wrap.multiBarWithLegend").data([r]),w=v.enter().append("g").attr("class","wrap nvd3 multiBarWithLegend").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"),w.append("g").attr("class","controlsWrap");var z=v.select("g");g&&(b.top=l.height(),l.width(s/2),z.select(".legendWrap").datum(r).attr("transform","translate("+s/2+","+ -b.top+")").call(l)),f&&(m.width(180).color(["#444","#444","#444"]),z.select(".controlsWrap").datum(p).attr("transform","translate(0,"+ -b.top+")").call(m)),z.attr("transform","translate("+b.left+","+b.top+")");var A=z.select(".linesWrap").datum(r.filter(function(a){return!a.disabled}));d3.transition(A).call(n),j.scale(h).ticks(s/100).tickSize(-t,0),z.select(".x.axis").attr("transform","translate(0,"+i.range()[0]+")"),d3.transition(z.select(".x.axis")).call(j);var B=z.select(".x.axis").selectAll("g");B.selectAll("line, text").style("opacity",1),B.filter(function(a,b){return b%Math.ceil(r[0].values.length/(s/100))!==0}).selectAll("line, text").style("opacity",0),k.domain(i.domain()).range(i.range()).ticks(t/36).tickSize(-s,0),d3.transition(z.select(".y.axis")).call(k),l.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,r.filter(function(a){return!a.disabled}).length||r.map(function(a){a.disabled=!1,v.selectAll(".series").classed("disabled",!1);return a}),a.transition().call(q)}),m.dispatch.on("legendClick",function(b,c){if(!!b.disabled){p=p.map(function(a){a.disabled=!0;return a}),b.disabled=!1;switch(b.key){case"Grouped":n.stacked(!1);break;case"Stacked":n.stacked(!0)}a.transition().call(q)}}),n.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],o.tooltipShow(a)}),n.dispatch.on("elementMouseout.tooltip",function(a){o.tooltipHide(a)})});return q}var b={top:30,right:20,bottom:50,left:60},c=function(){return 960},d=function(){return 500},e=d3.scale.category20().range(),f=!0,g=!0,h=d3.scale.ordinal(),i=d3.scale.linear(),j=a.models.axis().scale(h).orient("bottom").highlightZero(!1),k=a.models.axis().scale(i).orient("left"),l=a.models.legend().height(30),m=a.models.legend().height(30),n=a.models.multiBar().stacked(!1),o=d3.dispatch("tooltipShow","tooltipHide"),p=[{key:"Grouped"},{key:"Stacked",disabled:!0}];q.dispatch=o,q.legend=l,q.xAxis=j,q.yAxis=k,d3.rebind(q,n,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id"),q.margin=function(a){if(!arguments.length)return b;b=a;return q},q.width=function(a){if(!arguments.length)return c;c=d3.functor(a);return q},q.height=function(a){if(!arguments.length)return d;d=d3.functor(a);return q},q.showControls=function(a){if(!arguments.length)return f;f=a;return q},q.showLegend=function(a){if(!arguments.length)return g;g=a;return q};return q},a.models.multiBarHorizontal=function(){function u(d){d.each(function(v){var w=b-a.left-a.right,z=c-a.top-a.bottom;r=r||e,s=s||f,l&&(v=d3.layout.stack().offset("zero").values(function(a){return a.values}).y(h)(v)),v=v.map(function(a,b){a.values=a.values.map(function(a){a.series=b;return a});return a});var A=p&&q?[]:v.map(function(a){return a.values.map(function(a,b){return{x:g(a,b),y:h(a,b),y0:a.y0}})});e.domain(p||d3.merge(A).map(function(a){return a.x})).rangeBands([0,z],.1),f.domain(q||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]);var B=d3.select(this).selectAll("g.wrap.multibarHorizontal").data([v]),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%10]}).style("stroke",function(a,b){return k[b%10]}),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("+s(l?a.y0:0)+","+(l?0:c*e.rangeBand()/v.length+e(g(a,b)))+")"}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),t.elementMouseover({value:h(a,b),point:a,series:v[a.series],pos:[f(h(a,b)+(l?a.y0:0)),e(g(a,b))+e.rangeBand()*(l?v.length/2:a.series+.5)/v.length],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),t.elementMouseout({value:h(a,b),point:a,series:v[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){t.elementClick({value:h(a,b),point:a,series:v[a.series],pos:[e(g(a,b))+e.rangeBand()*(l?v.length/2:a.series+.5)/v.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){t.elementDblClick({value:h(a,b),point:a,series:v[a.series],pos:[e(g(a,b))+e.rangeBand()*(l?v.length/2:a.series+.5)/v.length,f(h(a,b)+(l?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()});I.append("rect").attr("width",0).attr("height",e.rangeBand()/(l?1:v.length)),m&&!l?(I.append("text").attr("text-anchor",function(a,b){return h(a,b)<0?"end":"start"}),H.selectAll("text").attr("y",e.rangeBand()/2).attr("dy","-.5em").text(function(a,b){return o(h(a,b))}),d3.transition(H).delay(function(a,b){return b*1e3/v[0].values.length}).selectAll("text").attr("dx",function(a,b){return h(a,b)<0?-4:f(h(a,b))-f(0)+4})):H.selectAll("text").remove(),H.attr("class",function(a,b){return h(a,b)<0?"bar negative":"bar positive"}),l?d3.transition(H).delay(function(a,b){return b*1e3/v[0].values.length}).attr("transform",function(a,b){return"translate("+f(a.y0)+","+(l?0:j*e.rangeBand()/v.length)+")"}).selectAll("rect").attr("width",function(a,b){return Math.abs(f(h(a,b)+a.y0)-f(a.y0))}).attr("height",e.rangeBand()):d3.transition(H).delay(function(a,b){return b*1200/v[0].values.length}).attr("transform",function(a,b){return"translate("+(h(a,b)<0?f(h(a,b)):f(0))+","+(a.series*e.rangeBand()/v.length+e(g(a,b)))+")"}).selectAll("rect").attr("height",e.rangeBand()/v.length).attr("width",function(a,b){return Math.abs(f(h(a,b))-f(0))}),u.update=function(){d.transition().call(u)},r=e.copy(),s=f.copy()});return u}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,q,r,s,t=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");u.dispatch=t,u.x=function(a){if(!arguments.length)return g;g=a;return u},u.y=function(a){if(!arguments.length)return h;h=a;return u},u.margin=function(b){if(!arguments.length)return a;a=b;return u},u.width=function(a){if(!arguments.length)return b;b=a;return u},u.height=function(a){if(!arguments.length)return c;c=a;return u},u.xScale=function(a){if(!arguments.length)return e;e=a;return u},u.yScale=function(a){if(!arguments.length)return f;f=a;return u},u.xDomain=function(a){if(!arguments.length)return p;p=a;return u},u.yDomain=function(a){if(!arguments.length)return q;q=a;return u},u.forceY=function(a){if(!arguments.length)return i;i=a;return u},u.stacked=function(a){if(!arguments.length)return l;l=a;return u},u.color=function(a){if(!arguments.length)return k;k=a;return u},u.id=function(a){if(!arguments.length)return d;d=a;return u},u.showValues=function(a){if(!arguments.length)return m;m=a;return u},u.valueFormat=function(a){if(!arguments.length)return o;o=a;return u},u.valuePadding=function(a){if(!arguments.length)return n;n=a;return u};return u},a.models.multiBarHorizontalChart=function(){function s(h){h.each(function(t){var u=d3.select(this),v=(c||parseInt(u.style("width"))||960)-b.left-b.right,w=(d||parseInt(u.style("height"))||400)-b.top-b.bottom;i.width(v).height(w).color(t.map(function(a,b){return a.color||e[b%10]}).filter(function(a,b){return!t[b].disabled}));var z=u.selectAll("g.wrap.multiBarHorizontalChart").data([t]),A=z.enter().append("g").attr("class","wrap nvd3 multiBarHorizontalChart").append("g");A.append("g").attr("class","x axis"),A.append("g").attr("class","y axis"),A.append("g").attr("class","linesWrap"),A.append("g").attr("class","legendWrap"),A.append("g").attr("class","controlsWrap"),b.top=n.height();var B=z.select("g").attr("transform","translate("+b.left+","+b.top+")");n.width(v/2),B.select(".legendWrap").datum(t).attr("transform","translate("+v/2+","+ -b.top+")").call(n),f&&(o.width(180).color(["#444","#444","#444"]),B.select(".controlsWrap").datum(r).attr("transform","translate(0,"+ -b.top+")").call(o));var C=B.select(".linesWrap").datum(t.filter(function(a){return!a.disabled}));d3.transition(C).call(i),l.scale(j).ticks(w/24).tickSize(-v,0),d3.transition(B.select(".x.axis")).call(l);var D=B.select(".x.axis").selectAll("g");D.selectAll("line, text").style("opacity",1),D.filter(function(a,b){return b%Math.ceil(t[0].values.length/(v/100))!==0}).selectAll("line, text").style("opacity",0),m.domain(k.domain()).range(k.range()).ticks(v/100).tickSize(-w,0),B.select(".y.axis").attr("transform","translate(0,"+w+")"),d3.transition(B.select(".y.axis")).call(m),n.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,t.filter(function(a){return!a.disabled}).length||t.map(function(a){a.disabled=!1,z.selectAll(".series").classed("disabled",!1);return a}),h.transition().call(s)}),o.dispatch.on("legendClick",function(a,b){if(!!a.disabled){r=r.map(function(a){a.disabled=!0;return a}),a.disabled=!1;switch(a.key){case"Grouped":i.stacked(!1);break;case"Stacked":i.stacked(!0)}h.transition().call(s)}}),i.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],p.tooltipShow(a)}),g&&p.on("tooltipShow",function(a){q(a,u[0][0])}),i.dispatch.on("elementMouseout.tooltip",function(a){p.tooltipHide(a)}),g&&p.on("tooltipHide",a.tooltip.cleanup)});return s}var b={top:30,right:20,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!0,g=!0,h=function(a,b,c,d,e){return"

"+b+"

"+"

"+c+"

"},i=a.models.multiBarHorizontal().stacked(!1),j=i.xScale(),k=i.yScale(),l=a.models.axis().scale(j).orient("left").highlightZero(!1),m=a.models.axis().scale(k).orient("bottom"),n=a.models.legend().height(30),o=a.models.legend().height(30),p=d3.dispatch("tooltipShow","tooltipHide");l.tickFormat(function(a){return a}),m.tickFormat(d3.format(",.1f"));var q=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=l.tickFormat()(i.x()(b.point)),g=m.tickFormat()(i.y()(b.point)),j=h(b.series.key,f,g,b,s);a.tooltip.show([d,e],j,b.value<0?"e":"w")},r=[{key:"Grouped"},{key:"Stacked",disabled:!0}];s.dispatch=p,s.legend=n,s.xAxis=l,s.yAxis=m,d3.rebind(s,i,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id","showValues","valueFormat"),s.margin=function(a){if(!arguments.length)return b;b=a;return s},s.width=function(a){if(!arguments.length)return c;c=d3.functor(a);return s},s.height=function(a){if(!arguments.length)return d;d=d3.functor(a);return s},s.showControls=function(a){if(!arguments.length)return f;f=a;return s},s.tooltips=function(a){if(!arguments.length)return g;g=a;return s},s.tooltipContent=function(a){if(!arguments.length)return h;h=a;return s};return s},a.models.multiBarHorizontalWithLegend=function(){function p(a){a.each(function(q){var r=c()-b.left-b.right,s=d()-b.top-b.bottom,t;m.stacked()?t=q.filter(function(a){return!a.disabled}).reduce(function(a,b,c){b.values.forEach(function(b,d){c||(a[d]={x:m.x()(b,d),y:0}),a[d].y+=m.y()(b,d)});return a},[]):t=q.filter(function(a){return!a.disabled}).map(function(a){return a.values.map(function(a,b){return{x:m.x()(a,b),y:m.y()(a,b)}})}),g.domain(d3.merge(t).map(function(a){return a.x})).rangeBands([0,s],.1),h.domain(d3.extent(d3.merge(t).map(function(a){return a.y}).concat(m.forceY))).range([0,r]),m.width(r).height(s).color(q.map(function(a,b){return a.color||e[b%10]}).filter(function(a,b){return!q[b].disabled}));var u=d3.select(this).selectAll("g.wrap").data([q]),v=u.enter().append("g").attr("class","wrap nvd3 multiBarHorizontalWithLegend").append("g");v.append("g").attr("class","x axis"),v.append("g").attr("class","y axis"),v.append("g").attr("class","linesWrap"),v.append("g").attr("class","legendWrap"),v.append("g").attr("class","controlsWrap"),b.top=k.height();var w=u.select("g").attr("transform","translate("+b.left+","+b.top+")");k.width(r/2),w.select(".legendWrap").datum(q).attr("transform","translate("+r/2+","+ -b.top+")").call(k),f&&(l.width(180).color(["#444","#444","#444"]),w.select(".controlsWrap").datum(o).attr("transform","translate(0,"+ -b.top+")").call(l));var z=w.select(".linesWrap").datum(q.filter(function(a){return!a.disabled}));d3.transition(z).call(m),i.scale(g).ticks(s/24).tickSize(-r,0),d3.transition -(w.select(".x.axis")).call(i);var A=w.select(".x.axis").selectAll("g");A.selectAll("line, text").style("opacity",1),A.filter(function(a,b){return b%Math.ceil(q[0].values.length/(r/100))!==0}).selectAll("line, text").style("opacity",0),j.domain(h.domain()).range(h.range()).ticks(r/100).tickSize(-s,0),w.select(".y.axis").attr("transform","translate(0,"+s+")"),d3.transition(w.select(".y.axis")).call(j),k.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,q.filter(function(a){return!a.disabled}).length||q.map(function(a){a.disabled=!1,u.selectAll(".series").classed("disabled",!1);return a}),a.transition().call(p)}),l.dispatch.on("legendClick",function(b,c){if(!!b.disabled){o=o.map(function(a){a.disabled=!0;return a}),b.disabled=!1;switch(b.key){case"Grouped":m.stacked(!1);break;case"Stacked":m.stacked(!0)}a.transition().call(p)}}),m.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],n.tooltipShow(a)}),m.dispatch.on("elementMouseout.tooltip",function(a){n.tooltipHide(a)})});return p}var b={top:30,right:20,bottom:50,left:60},c=function(){return 960},d=function(){return 500},e=d3.scale.category20().range(),f=!0,g=d3.scale.ordinal(),h=d3.scale.linear(),i=a.models.axis().scale(g).orient("left").highlightZero(!1),j=a.models.axis().scale(h).orient("bottom"),k=a.models.legend().height(30),l=a.models.legend().height(30),m=a.models.multiBarHorizontal().stacked(!1),n=d3.dispatch("tooltipShow","tooltipHide"),o=[{key:"Grouped"},{key:"Stacked",disabled:!0}];p.dispatch=n,p.legend=k,p.xAxis=i,p.yAxis=j,d3.rebind(p,m,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id"),p.margin=function(a){if(!arguments.length)return b;b=a;return p},p.width=function(a){if(!arguments.length)return c;c=d3.functor(a);return p},p.height=function(a){if(!arguments.length)return d;d=d3.functor(a);return p},p.showControls=function(a){if(!arguments.length)return f;f=a;return p};return p},a.models.pie=function(){function p(m){m.each(function(m){function z(a){a.innerRadius=0;var b=d3.interpolate({startAngle:0,endAngle:0},a);return function(a){return t(b(a))}}function y(a){var b=(a.startAngle+a.endAngle)*90/Math.PI-90;return b>90?b-180:b}var n=d3.select(this).on("click",function(a,b){o.chartClick({data:a,index:b,pos:d3.event,id:h})}),p=n.selectAll("svg.margin").data([m]),q=p.enter();q.append("text").attr("class","title").attr("dy",".91em").attr("text-anchor","start").text(l),q.append("svg").attr("class","margin").attr("x",a.left).attr("y",a.top).style("overflow","visible");var r=p.selectAll("g.wrap").data([m]);r.exit().remove();var s=r.enter();s.append("g").attr("class","wrap").attr("id","wrap-"+h).append("g").attr("class","pie"),r.attr("width",b).attr("height",c).attr("transform","translate("+e+","+e+")");var t=d3.svg.arc().outerRadius(e-e/5);k&&t.innerRadius(e/2);var u=d3.layout.pie().value(function(a){return a[g]}),v=p.select(".pie").selectAll(".slice").data(u);v.exit().remove();var w=v.enter().append("svg:g").attr("class","slice").on("mouseover",function(a,b){d3.select(this).classed("hover",!0),o.tooltipShow({label:a.data[f],value:a.data[g],data:a.data,index:b,pos:[d3.event.pageX,d3.event.pageY],id:h})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),o.tooltipHide({label:a.data[f],value:a.data[g],data:a.data,index:b,id:h})}).on("click",function(a,b){o.elementClick({label:a.data[f],value:a.data[g],data:a.data,index:b,pos:d3.event,id:h}),d3.event.stopPropagation()}).on("dblclick",function(a,b){o.elementDblClick({label:a.data[f],value:a.data[g],data:a.data,index:b,pos:d3.event,id:h}),d3.event.stopPropagation()}),x=w.append("svg:path").attr("class","path").attr("fill",function(a,b){return i(b)});v.select(".path").attr("d",t).transition().ease("bounce").duration(d).attrTween("d",z),j&&(w.append("text"),v.select("text").transition().duration(d).ease("bounce").attr("transform",function(a){a.outerRadius=e+10,a.innerRadius=e+15;return"translate("+t.centroid(a)+")"}).attr("text-anchor","middle").style("font","bold 12px Arial").text(function(a,b){return a.data[f]}))});return p}var a={top:20,right:20,bottom:20,left:20},b=500,c=500,d=2e3,e=Math.min(b-(a.right+a.left),c-(a.top+a.bottom))/2,f="label",g="y",h=Math.floor(Math.random()*1e4),i=d3.scale.category20(),j=!0,k=!1,l="",m=0,n=0,o=d3.dispatch("chartClick","elementClick","elementDblClick","tooltipShow","tooltipHide");p.margin=function(b){if(!arguments.length)return a;a=b;return p},p.width=function(d){if(!arguments.length)return b;a.left+a.right+20>d?b=a.left+a.right+20:b=d,e=Math.min(b-(a.left+a.right),c-(a.top+a.bottom))/2;return p},p.height=function(d){if(!arguments.length)return c;a.top+a.bottom+20>d?c=a.top+a.bottom+20:c=d,e=Math.min(b-(a.left+a.right),c-(a.top+a.bottom))/2;return p},p.animate=function(a){if(!arguments.length)return d;d=a;return p},p.labelField=function(a){if(!arguments.length)return f;f=a;return p},p.dataField=function(a){if(!arguments.length)return g;g=a;return p},p.showLabels=function(a){if(!arguments.length)return j;j=a;return p},p.donut=function(a){if(!arguments.length)return k;k=a;return p},p.title=function(a){if(!arguments.length)return l;l=a;return p},p.id=function(a){if(!arguments.length)return h;h=a;return p},p.dispatch=o;return p},a.models.scatter=function(){function A(B){B.each(function(A){function J(){if(!o){E.select("#points-clip-"+e).remove(),E.select(".point-paths").remove();return!1}H.append("g").attr("class","point-paths");var b=d3.merge(A.map(function(a,b){return a.values.map(function(a,c){return[f(i(a,c))*(Math.random()/1e12+1),g(j(a,c))*(Math.random()/1e12+1),b,c]})}));if(q){G.append("clipPath").attr("id","points-clip-"+e);var c=E.select("#points-clip-"+e).selectAll("circle").data(b);c.enter().append("circle").attr("r",r),c.exit().remove(),c.attr("cx",function(a){return a[0]}).attr("cy",function(a){return a[1]}),E.select(".point-paths").attr("clip-path","url(#points-clip-"+e+")")}var d=d3.geom.voronoi(b).map(function(a,c){return{data:a,series:b[c][2],point:b[c][3]}}),h=E.select(".point-paths").selectAll("path").data(d);h.enter().append("path").attr("class",function(a,b){return"path-"+b}),h.exit().remove(),h.attr("d",function(a){return"M"+a.data.join(",")+"Z"}).on("click",function(b){var c=A[b.series],d=c.values[b.point];v.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=A[b.series],d=c.values[b.point];v.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){v.elementMouseout({point:A[a.series].values[a.point],series:A[a.series],seriesIndex:a.series,pointIndex:a.point})}),v.on("elementMouseover.point",function(a){E.select(".series-"+a.seriesIndex+" .point-"+a.pointIndex).classed("hover",!0)}),v.on("elementMouseout.point",function(a){E.select(".series-"+a.seriesIndex+" circle.point-"+a.pointIndex).classed("hover",!1)})}var B=b-a.left-a.right,C=c-a.top-a.bottom;w=w||f,x=x||g,y=y||h,A=A.map(function(a,b){a.values=a.values.map(function(a){a.series=b;return a});return a});var D=s&&t&&u?[]:A.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(s||d3.extent(d3.merge(D).map(function(a){return a.x}).concat(l))).range([0,B]),g.domain(t||d3.extent(d3.merge(D).map(function(a){return a.y}).concat(m))).range([C,0]),h.domain(u||d3.extent(d3.merge(D).map(function(a){return a.size}).concat(n))).range([2,10]);var E=d3.select(this).selectAll("g.wrap.scatter").data([A]),F=E.enter().append("g").attr("class","wrap nvd3 scatter"),G=F.append("defs"),H=F.append("g"),I=E.select("g");H.append("g").attr("class","groups"),E.attr("transform","translate("+a.left+","+a.top+")"),G.append("clipPath").attr("id","edge-clip-"+e).append("rect"),E.select("#edge-clip-"+e+" rect").attr("width",B).attr("height",C),I.attr("clip-path",p?"url(#edge-clip-"+e+")":"");var K=E.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});K.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(K.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),K.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}),d3.transition(K).style("fill",function(a,b){return d[b%20]}).style("stroke",function(a,b){return d[b%20]}).style("stroke-opacity",1).style("fill-opacity",.5);var L=K.selectAll("circle.point").data(function(a){return a.values});L.enter().append("circle").attr("cx",function(a,b){return w(i(a,b))}).attr("cy",function(a,b){return x(j(a,b))}).attr("r",function(a,b){return y(k(a,b))}),d3.transition(K.exit().selectAll("circle.point")).attr("cx",function(a,b){return f(i(a,b))}).attr("cy",function(a,b){return g(j(a,b))}).attr("r",function(a,b){return h(k(a,b))}).remove(),L.attr("class",function(a,b){return"point point-"+b}),d3.transition(L).attr("cx",function(a,b){return f(i(a,b))}).attr("cy",function(a,b){return g(j(a,b))}).attr("r",function(a,b){return h(k(a,b))}),clearTimeout(z),z=setTimeout(J,750),w=f.copy(),x=g.copy(),y=h.copy()});return A}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=d3.scale.category20().range(),e=Math.floor(Math.random()*1e5),f=d3.scale.linear(),g=d3.scale.linear(),h=d3.scale.sqrt(),i=function(a){return a.x},j=function(a){return a.y},k=function(a){return a.size},l=[],m=[],n=[],o=!0,p=!1,q=!0,r=function(){return 25},s,t,u,v=d3.dispatch("elementClick","elementMouseover","elementMouseout"),w,x,y,z;A.dispatch=v,A.x=function(a){if(!arguments.length)return i;i=d3.functor(a);return A},A.y=function(a){if(!arguments.length)return j;j=d3.functor(a);return A},A.size=function(a){if(!arguments.length)return k;k=d3.functor(a);return A},A.margin=function(b){if(!arguments.length)return a;a=b;return A},A.width=function(a){if(!arguments.length)return b;b=a;return A},A.height=function(a){if(!arguments.length)return c;c=a;return A},A.xScale=function(a){if(!arguments.length)return f;f=a;return A},A.yScale=function(a){if(!arguments.length)return g;g=a;return A},A.zScale=function(a){if(!arguments.length)return h;h=a;return A},A.xDomain=function(a){if(!arguments.length)return s;s=a;return A},A.yDomain=function(a){if(!arguments.length)return t;t=a;return A},A.sizeDomain=function(a){if(!arguments.length)return u;u=a;return A},A.forceX=function(a){if(!arguments.length)return l;l=a;return A},A.forceY=function(a){if(!arguments.length)return m;m=a;return A},A.forceSize=function(a){if(!arguments.length)return n;n=a;return A},A.interactive=function(a){if(!arguments.length)return o;o=a;return A},A.clipEdge=function(a){if(!arguments.length)return p;p=a;return A},A.clipVoronoi=function(a){if(!arguments.length)return q;q=a;return A},A.clipRadius=function(a){if(!arguments.length)return r;r=a;return A},A.color=function(a){if(!arguments.length)return d;d=a;return A},A.id=function(a){if(!arguments.length)return e;e=a;return A};return A},a.models.scatterWithLegend=function(){function s(a){a.each(function(e){var f=c()-b.left-b.right,t=d()-b.top-b.bottom;q=q||m.xScale(),r=r||m.yScale();var u=d3.select(this).selectAll("g.wrap.scatterWithLegend").data([e]),v=u.enter().append("g").attr("class","wrap nvd3 scatterWithLegend").append("g");v.append("g").attr("class","legendWrap"),v.append("g").attr("class","x axis"),v.append("g").attr("class","y axis"),v.append("g").attr("class","scatterWrap"),m.width(f).height(t).color(e.map(function(a,b){return a.color||i[b%20]}).filter(function(a,b){return!e[b].disabled}));var w=u.select(".scatterWrap").datum(e.filter(function(a){return!a.disabled}));d3.transition(w).call(m),o=m.xScale(),p=m.yScale(),j.scale(o),k.scale(p),b.top=l.height();var z=u.select("g").attr("transform","translate("+b.left+","+b.top+")");l.width(f/2),u.select(".legendWrap").datum(e).attr("transform","translate("+f/2+","+ -b.top+")").call(l);if(g||h){var A=w.selectAll("g.distribution").data(function(a){return a},function(a){return a.key});A.enter().append("g").attr("class",function(a,b){return"distribution series-"+b}),A.style("stroke",function(a,b){return i.filter(function(a,b){return e[b]&&!e[b].disabled})[b%10]})}if(g){var B=A.selectAll("line.distX").data(function(a){return a.values});B.enter().append("line").attr("x1",function(a,b){return q(m.x()(a,b))}).attr("x2",function(a,b){return q(m.x()(a,b))}),d3.transition(A.exit().selectAll("line.distX")).attr("x1",function(a,b){return o(m.x()(a,b))}).attr("x2",function(a,b){return o(m.x()(a,b))}).remove(),B.attr("class",function(a,b){return"distX distX-"+b}).attr("y1",p.range()[0]).attr("y2",p.range()[0]+8),d3.transition(B).attr("x1",function(a,b){return o(m.x()(a,b))}).attr("x2",function(a,b){return o(m.x()(a,b))})}if(h){var C=A.selectAll("line.distY").data(function(a){return a.values});C.enter().append("line").attr("y1",function(a,b){return r(m.y()(a,b))}).attr("y2",function(a,b){return r(m.y()(a,b))}),d3.transition(A.exit().selectAll("line.distY")).attr("y1",function(a,b){return p(m.y()(a,b))}).attr("y2",function(a,b){return p(m.y()(a,b))}).remove(),C.attr("class",function(a,b){return"distY distY-"+b}).attr("x1",o.range()[0]).attr("x2",o.range()[0]-8),d3.transition(C).attr("y1",function(a,b){return p(m.y()(a,b))}).attr("y2",function(a,b){return p(m.y()(a,b))})}j.ticks(f/100).tickSize(-t,0),z.select(".x.axis").attr("transform","translate(0,"+p.range()[0]+")"),d3.transition(z.select(".x.axis")).call(j),k.ticks(t/36).tickSize(-f,0),d3.transition(z.select(".y.axis")).call(k),l.dispatch.on("legendClick",function(b,c,d){b.disabled=!b.disabled,e.filter(function(a){return!a.disabled}).length||e.map(function(a){a.disabled=!1,u.selectAll(".series").classed("disabled",!1);return a}),a.transition().call(s)}),m.dispatch.on("elementMouseover.tooltip",function(a){n.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex}),w.select(".series-"+a.seriesIndex+" .distX-"+a.pointIndex).attr("y1",a.pos[1]),w.select(".series-"+a.seriesIndex+" .distY-"+a.pointIndex).attr("x1",a.pos[0])}),m.dispatch.on("elementMouseout.tooltip",function(a){n.tooltipHide(a),w.select(".series-"+a.seriesIndex+" .distX-"+a.pointIndex).attr("y1",p.range()[0]),w.select(".series-"+a.seriesIndex+" .distY-"+a.pointIndex).attr("x1",o.range()[0])}),q=o.copy(),r=p.copy()});return s}var b={top:30,right:20,bottom:50,left:60},c=function(){return 960},d=function(){return 500},e=!1,f=!1,g=!1,h=!1,i=d3.scale.category20().range(),j=a.models.axis().orient("bottom").tickPadding(10),k=a.models.axis().orient("left").tickPadding(10),l=a.models.legend().height(30),m=a.models.scatter(),n=d3.dispatch("tooltipShow","tooltipHide"),o,p,q,r;s.dispatch=n,s.legend=l,s.xAxis=j,s.yAxis=k,d3.rebind(s,m,"interactive","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius"),s.margin=function(a){if(!arguments.length)return b;b=a;return s},s.width=function(a){if(!arguments.length)return c;c=d3.functor(a);return s},s.height=function(a){if(!arguments.length)return d;d=d3.functor(a);return s},s.color=function(a){if(!arguments.length)return i;i=a,l.color(a);return s},s.showDistX=function(a){if(!arguments.length)return g;g=a;return s},s.showDistY=function(a){if(!arguments.length)return h;h=a;return s};return s},a.models.sparkline=function(){function l(d){d.each(function(d){var l=b-a.left-a.right,m=c-a.top-a.bottom;j.domain(h||d3.extent(d,e)).range([0,l]),k.domain(i||d3.extent(d,f)).range([m,0]);var n=d3.select(this).selectAll("g.sparkline").data([d]),o=n.enter().append("g").attr("class","nvd3 sparkline");o.attr("transform","translate("+a.left+","+a.top+")").style("stroke",function(a,b){return a.color||g[b*2%20]});var p=o.selectAll("path").data(function(a){return[a]});p.enter().append("path"),p.exit().remove(),p.attr("d",d3.svg.line().x(function(a,b){return j(e(a,b))}).y(function(a,b){return k(f(a,b))}));var q=o.selectAll("circle.point").data(function(a){return a.filter(function(a,b){return k.domain().indexOf(f(a,b))!=-1||e(a,b)==j.domain()[1]})});q.enter().append("circle").attr("class","point"),q.exit().remove(),q.attr("cx",function(a,b){return j(e(a,b))}).attr("cy",function(a,b){return k(f(a,b))}).attr("r",2).style("stroke",function(a,b){return a.x==j.domain()[1]?"#444":a.y==k.domain()[0]?"#d62728":"#2ca02c"}).style("fill",function(a,b){return a.x==j.domain()[1]?"#444":a.y==k.domain()[0]?"#d62728":"#2ca02c"})});return l}var a={top:0,right:0,bottom:0,left:0},b=400,c=32,d=!0,e=function(a){return a.x},f=function(a){return a.y},g=d3.scale.category20().range(),h,i,j=d3.scale.linear(),k=d3.scale.linear();l.margin=function(b){if(!arguments.length)return a;a=b;return l},l.width=function(a){if(!arguments.length)return b;b=a;return l},l.height=function(a){if(!arguments.length)return c;c=a;return l},l.x=function(a){if(!arguments.length)return e;e=d3.functor(a);return l},l.y=function(a){if(!arguments.length)return f;f=d3.functor(a);return l},l.xDomain=function(a){if(!arguments.length)return h;h=a;return l},l.yDomain=function(a){if(!arguments.length)return i;i=a;return l},l.animate=function(a){if(!arguments.length)return d;d=a;return l};return l},a.models.sparklinePlus=function(){function o(a){a.each(function(a){function w(){var c=d3.event.offsetX-b.left;t.attr("x1",c).attr("x2",c),u.attr("transform",function(a){return"translate("+(c-6)+","+ -b.top+")"}).text(j(Math.round(l.invert(c)))),v.attr("transform",function(a){return"translate("+(c+6)+","+ -b.top+")"}).text(k(g(a[Math.round(l.invert(c))])))}var e=c-b.left-b.right,i=d-b.top-b.bottom;l.domain(d3.extent(a,f)).range([0,e]),m.domain(d3.extent(a,g)).range([i,0]);var o=d3.select(this).selectAll("g.sparklineplus").data([a]),p=o.enter().append("g"),q=p.append("g").attr("class","nvd3 sparklineplus").attr("transform","translate("+b.left+","+b.top+")").style("stroke",function(a,b){return a.color||h[b%10]});n.xDomain(l.domain()).yDomain(m.domain()),q.call(n);var r=q.append("g").attr("class","hoverValue"),s=q.append("g").attr("class","hoverArea");r.attr("transform",function(a){return"translate("+l(a)+",0)"});var t=r.append("line").attr("x1",l.range()[1]).attr("y1",-b.top).attr("x2",l.range()[1]).attr("y2",d),u=r.append("text").attr("class","xValue").attr("text-anchor","end").attr("dy",".9em"),v=r.append("text").attr("class","yValue").attr("text-anchor","start").attr("dy",".9em");s.append("rect").attr("width",e).attr("height",i).on("mousemove",w)});return o}var b={top:15,right:40,bottom:3,left:40},c=400,d=50,e=!0,f=function(a){return a.x},g=function(a){return a.y},h=d3.scale.category20().range(),i=Math.floor(Math.random()*1e5),j=d3.format(",r"),k=d3.format(",.2f"),l=d3.scale.linear(),m=d3.scale.linear(),n=a.models.sparkline();o.margin=function(a){if(!arguments.length)return b;b=a;return o},o.width=function(a){if(!arguments.length)return c;c=a,n.width(a-b.left-b.right);return o},o.height=function(a){if(!arguments.length)return d;d=a,n.height(a-b.top-b.bottom);return o},o.x=function(a){if(!arguments.length)return f;f=d3.functor(a),n.x(a);return o},o.y=function(a){if(!arguments.length)return g;g=d3.functor(a),n.y(a);return o},o.id=function(a){if(!arguments.length)return i;i=a;return o},o.animate=function(a){if(!arguments.length)return e;e=a;return o};return o},a.models.stackedArea=function(){function q(a){a.each(function(a){var i=JSON.parse(JSON.stringify(a)),q=c-b.left-b.right,r=d-b.top-b.bottom;i=d3.layout.stack().offset(j).order(k).values(function(a){return a.values}).y(h)(i);var s=d3.select(this).selectAll("g.wrap.stackedarea").data([i]),t=s.enter().append("g").attr("class","wrap nvd3 stackedarea"),u=t.append("defs"),v=t.append("g"),w=s.select("g");v.append("g").attr("class","areaWrap"),m.width(q).height(r).y(function(a){return a.y+a.y0}).forceY([0]).color(i.map(function(a,b){return a.color||e[b%20]}).filter(function(a,b){return!i[b].disabled})),v.append("g").attr("class","scatterWrap");var z=w.select(".scatterWrap").datum(i.filter(function(a){return!a.disabled}));d3.transition(z).call(m),s.attr("transform","translate("+b.left+","+b.top+")"),u.append("clipPath").attr("id","edge-clip-"+f).append("rect"),s.select("#edge-clip-"+f+" rect").attr("width",q).attr("height",r),w.attr("clip-path",l?"url(#edge-clip-"+f+")":"");var A=d3.svg.area().x(function(a,b){return n(g(a,b))}).y0(function(a){return o(a.y0)}).y1(function(a){return o(a.y+a.y0)}),B=d3.svg.area().x(function(a,b){return n(g(a,b))}).y0(function(a){return o(a.y0)}).y1(function(a){return o(a.y0)}),C=w.select(".areaWrap").selectAll("path.area").data(function(a){return a});C.enter().append("path").attr("class",function(a,b){return"area area-"+b}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),p.areaMouseover({point:a,series:a.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:b})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),p.areaMouseout({point:a,series:a.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:b})}).on("click",function(a,b){d3.select(this).classed("hover",!1),p.areaClick({point:a,series:a.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:b})}),d3.transition(C.exit()).attr("d",function(a,b){return B(a.values,b)}).remove(),C.style("fill",function(a,b){return e[b%20]}).style("stroke",function(a,b){return e[b%20]}),d3.transition(C).attr("d",function(a,b){return A(a.values,b)}),m.dispatch.on("elementClick.area",function(a){p.areaClick(a)}),m.dispatch.on("elementMouseover.area",function(a){w.select(".area-"+a.seriesIndex).classed("hover",!0)}),m.dispatch.on("elementMouseout.area",function(a){w.select(".area-"+a.seriesIndex).classed("hover",!1)})});return q}var b={top:0,right:0,bottom:0,left:0},c=960,d=500,e=d3.scale.category20().range(),f=Math.floor(Math.random()*1e5),g=function(a){return a.x},h=function(a){return a.y},i="stack",j="zero",k="default",l=!1,m=a.models.scatter().size(2.2).sizeDomain([2.5]),n=m.xScale(),o=m.yScale(),p=d3.dispatch("tooltipShow","tooltipHide","areaClick","areaMouseover","areaMouseout");q.dispatch=p,q.scatter=m,d3.rebind(q,m,"interactive","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius"),q.x=function(a){if(!arguments.length)return g;g=d3.functor(a),m.x(a);return q},q.y=function(a){if(!arguments.length)return h;h=d3.functor(a);return q},q.margin=function(a){if(!arguments.length)return b;b=a;return q},q.width=function(a){if(!arguments.length)return c;c=a;return q},q.height=function(a){if(!arguments.length)return d;d=a;return q},q.clipEdge=function(a){if(!arguments.length)return l;l=a;return q},q.color=function(a){if(!arguments.length)return e;e=a;return q},q.offset=function(a){if(!arguments.length)return j;j=a;return q},q.order=function(a){if(!arguments.length)return k;k=a;return q},q.style=function(a){if(!arguments.length)return i;i=a;switch(i){case"stack":j="zero",k="default";break;case"stream":j="wiggle",k="inside-out";break;case"expand":j="expand",k="default"}return q},m.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],p.tooltipShow(a)}),m.dispatch.on("elementMouseout.tooltip",function(a){p.tooltipHide(a)});return q},a.models.stackedAreaWithLegend=function(){function q(a){a.each(function(r){var s=c(),t=d(),u=s-b.left-b.right,v=t-b.top-b.bottom,w=r.filter(function(a){return!a.disabled}).reduce(function(a,b,c){b.values.forEach(function(b,d){c||(a[d]={x:h(b,d),y:0}),a[d].y+=i(b,d)});return a},[]);f.domain(d3.extent(d3.merge(w),function(a){return a.x})).range([0,u]),g.domain(n.offset()=="zero"?[0,d3.max(w,function(a){return a.y})]:[0,1]).range([v,0]),n.width(u).height(v).color(e);var z=d3.select(this).selectAll("g.wrap.stackedAreaWithLegend").data([r]),A=z.enter().append("g").attr("class","wrap nvd3 stackedAreaWithLegend").append("g");A.append("g").attr("class","x axis"),A.append("g").attr("class","y axis"),A.append("g").attr("class","stackedWrap"),A.append("g").attr("class","legendWrap"),A.append("g").attr("class","controlsWrap"),b.top=l.height();var B=z.select("g").attr("transform","translate("+b.left+","+b.top+")");l.width(s/2-b.right).color(e),B.select(".legendWrap").datum(r).attr("transform","translate("+(s/2-b.left)+","+ -b.top+")").call(l),m.width(280).color(["#444","#444","#444"]),B.select(".controlsWrap").datum(p).attr("transform","translate(0,"+ -b.top+")").call(m);var C=B.select(".stackedWrap").datum(r);d3.transition(C).call(n),j.domain(f.domain()).range(f.range()).ticks(s/100).tickSize(-v,0),B.select(".x.axis").attr("transform","translate(0,"+v+")"),d3.transition(B.select(".x.axis")).call(j),k.domain(g.domain()).range(g.range()).ticks(n.offset()=="wiggle"?0:t/36).tickSize(-u,0).tickFormat(n.offset()=="zero"?d3.format(",.2f"):d3.format("%")),d3.transition(B.select(".y.axis")).call(k),n.dispatch.on("areaClick.toggle",function(b){r.filter(function(a){return!a.disabled}).length===1?r=r.map(function(a){a.disabled&&a.values.map(function(a){a.y=a._y||a.y;return a}),a.disabled=!1;return a}):r=r.map(function(a,c){!a.disabled&&c!==b.seriesIndex&&a.values.map(function(a){a._y=a.y,a.y=0;return a}),a.disabled&&c===b.seriesIndex&&a.values.map(function(a){a.y=a._y||a.y;return a}),a.disabled=c!=b.seriesIndex;return a}),a.transition().call(q)}),l.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,b.disabled?b.values.map(function(a){a._y=a.y,a.y=0;return a}):b.values.map(function(a){a.y=a._y;return a}),r.filter(function(a){return!a.disabled}).length||r.map(function(a){a.disabled=!1,a.values.map(function(a){a.y=a._y;return a});return a}),a.transition().call(q)}),m.dispatch.on("legendClick",function(b,c){if(!!b.disabled){p=p.map(function(a){a.disabled=!0;return a}),b.disabled=!1;switch(b.key){case"Stacked":n.style("stack");break;case"Stream":n.style("stream");break;case"Expanded":n.style("expand")}a.transition().call(q)}}),n.dispatch.on("tooltipShow",function(a){if(!Math.round(i(a.point)*100)){setTimeout(function(){d3.selectAll(".point.hover").classed("hover",!1)},0);return!1}a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],o.tooltipShow(a)}),n.dispatch.on("tooltipHide",function(a){o.tooltipHide(a)})});return q}var b={top:30,right:20,bottom:50,left:60},c=function(){return 960},d=function(){return 500},e=d3.scale.category20().range(),f=d3.scale.linear(),g=d3.scale.linear(),h=function(a){return a.x},i=function(a){return a.y},j=a.models.axis().scale(f).orient("bottom"),k=a.models.axis().scale(g).orient("left"),l=a.models.legend().height(30),m=a.models.legend().height(30),n=a.models.stackedArea(),o=d3.dispatch("tooltipShow","tooltipHide"),p=[{key:"Stacked"},{key:"Stream",disabled:!0},{key:"Expanded",disabled:!0}];q.dispatch=o,d3.rebind(q,n,"interactive","clipEdge","size"),q.x=function(a){if(!arguments.length)return h;h=d3.functor(a),n.x(h);return q},q.y=function(a){if(!arguments.length)return i;i=d3.functor(a),n.y(i);return q},q.margin=function(a){if(!arguments.length)return b;b=a;return q},q.width=function(a){if(!arguments.length)return c;c=d3.functor(a);return q},q.height=function(a){if(!arguments.length)return d;d=d3.functor(a);return q},q.stacked=n,q.xAxis=j,q.yAxis=k;return q},a.charts.cumulativeLineChartDaily=function(){function h(){if(!b||!c.length)return h;d3.select(b).select("svg").datum(c).transition().duration(d).call(f);return h}var b=null,c=[],d=500,e=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" at "+b+"

"},f=a.models.cumulativeLine().x(function(a,b){return b}).color(d3.scale.category10().range()),g=function(c){var d=document.getElementById(b.substr(1)),g=c.pos[0]+d.offsetLeft,h=c.pos[1]+d.offsetTop,i=f.xAxis.tickFormat(),j=f.yAxis.tickFormat(),k=i(f.x()(c,c.pointIndex)),l=j(f.y()(c.point)),m=e(c.series.key,k,l,c,f);a.tooltip.show([g,h],m)};f.xAxis.tickFormat(function(a){return d3.time.format("%x")(new Date(c[0].values[a].x))}),f.yAxis.tickFormat(d3.format(",.2%")),h.build=function(){if(!b||!c.length)return h;a.addGraph({generate:function(){var a=d3.select(b),e=function(){return parseInt(a.style("width"))},g=function(){return parseInt(a.style("height"))},h=a.append("svg");f.width(e).height(g),h.attr("width",e()).attr("height",g()).datum(c).transition().duration(d).call(f);return f},callback:function(c){c.dispatch.on("tooltipShow",g),c.dispatch.on("tooltipHide",a.tooltip.cleanup),window.onresize=function(){d3.select(b+" svg").attr("width",c.width()()).attr("height",c.height()()).call(c)}}});return h},h.data=function(a){if(!arguments.length)return c;c=a;return h},h.selector=function(a){if(!arguments.length)return b;b=a;return h},h.duration=function(a){if(!arguments.length)return d;d=a;return h},h.tooltip=function(a){if(!arguments.length)return e;e=a;return h},h.xTickFormat=function(a){if(!arguments.length)return f.xAxis.tickFormat();f.xAxis.tickFormat(typeof a=="function"?a:d3.format(a));return h},h.yTickFormat=function(a){if(!arguments.length)return f.yAxis.tickFormat();f.yAxis.tickFormat(typeof a=="function"?a:d3.format(a));return h},h.xAxisLabel=function(a){if(!arguments.length)return f.xAxis.axisLabel();f.xAxis.axisLabel(a);return h},h.yAxisLabel=function(a){if(!arguments.length)return f.yAxis.axisLabel();f.yAxis.axisLabel(a);return h},d3.rebind(h,f,"x","y"),h.graph=f;return h},a.charts.line=function(){function h(){if(!b||!c.length)return h;d3.select(b).select("svg").datum(c).transition().duration(d).call(f);return h}var b=null,c=[],d=500,e=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" at "+b+"

"},f=a.models.lineWithLegend(),g=function(c){var d=document.getElementById(b.substr(1)),g=c.pos[0]+d.offsetLeft,h=c.pos[1]+d.offsetTop,i=f.xAxis.tickFormat(),j=f.yAxis.tickFormat(),k=i(f.x()(c.point)),l=j(f.y()(c.point)),m=e(c.series.key,k,l,c,f);a.tooltip.show([g,h],m)};f.xAxis.tickFormat(d3.format(",r")),f.yAxis.tickFormat(d3.format(",.2f")),h.build=function(){if(!b||!c.length)return h;a.addGraph({generate:function(){var a=d3.select(b),e=function(){return parseInt(a.style("width"))},g=function(){return parseInt(a.style("height"))},h=a.append("svg");f.width(e).height(g),h.attr("width",e()).attr("height",g()).datum(c).transition().duration(d).call(f);return f},callback:function(c){c.dispatch.on("tooltipShow",g),c.dispatch.on("tooltipHide",a.tooltip.cleanup),window.onresize=function(){d3.select(b+" svg").attr("width",c.width()()).attr("height",c.height()()).call(c)}}});return h},h.data=function(a){if(!arguments.length)return c;c=a;return h},h.selector=function(a){if(!arguments.length)return b;b=a;return h},h.duration=function(a){if(!arguments.length)return d;d=a;return h},h.tooltip=function(a){if(!arguments.length)return e;e=a;return h},h.xTickFormat=function(a){if(!arguments.length)return f.xAxis.tickFormat();f.xAxis.tickFormat(typeof a=="function"?a:d3.format(a));return h},h.yTickFormat=function(a){if(!arguments.length)return f.yAxis.tickFormat();f.yAxis.tickFormat(typeof a=="function"?a:d3.format(a));return h},h.xAxisLabel=function(a){if(!arguments.length)return f.xAxis.axisLabel();f.xAxis.axisLabel(a);return h},h.yAxisLabel=function(a){if(!arguments.length)return f.yAxis.axisLabel();f.yAxis.axisLabel(a);return h},d3.rebind(h,f,"x","y"),h.graph=f;return h},a.charts.lineChartDaily=function(){function h(){if(!b||!c.length)return h;d3.select(b).select("svg").datum(c).transition().duration(d).call(f);return h}var b=null,c=[],d=500,e=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" at "+b+"

"},f=a.models.lineWithLegend().x(function(a,b){return b}),g=function(c){var d=document.getElementById(b.substr(1)),g=c.pos[0]+d.offsetLeft,h=c.pos[1]+d.offsetTop,i=f.xAxis.tickFormat(),j=f.yAxis.tickFormat(),k=i(f.x()(c,c.pointIndex)),l=j(f.y()(c.point)),m=e(c.series.key,k,l,c,f);a.tooltip.show([g,h],m)};f.xAxis.tickFormat(function(a){return d3.time.format("%x")(new Date(c[0].values[a].x))}),f.yAxis.tickFormat(d3.format(",.2%")),h.build=function(){if(!b||!c.length)return h;a.addGraph({generate:function(){var a=d3.select(b),e=function(){return parseInt(a.style("width"))},g=function(){return parseInt(a.style("height"))},h=a.append("svg");f.width(e).height(g),h.attr("width",e()).attr("height",g()).datum(c).transition().duration(d).call(f);return f},callback:function(c){c.dispatch.on("tooltipShow",g),c.dispatch.on("tooltipHide",a.tooltip.cleanup),window.onresize=function(){d3.select(b+" svg").attr("width",c.width()()).attr("height",c.height()()).call(c)}}});return h},h.data=function(a){if(!arguments.length)return c;c=a;return h},h.selector=function(a){if(!arguments.length)return b;b=a;return h},h.duration=function(a){if(!arguments.length)return d;d=a;return h},h.tooltip=function(a){if(!arguments.length)return e;e=a;return h},h.xTickFormat=function(a){if(!arguments.length)return f.xAxis.tickFormat();f.xAxis.tickFormat(typeof a=="function"?a:d3.format(a));return h},h.yTickFormat=function(a){if(!arguments.length)return f.yAxis.tickFormat( -);f.yAxis.tickFormat(typeof a=="function"?a:d3.format(a));return h},h.xAxisLabel=function(a){if(!arguments.length)return f.xAxis.axisLabel();f.xAxis.axisLabel(a);return h},h.yAxisLabel=function(a){if(!arguments.length)return f.yAxis.axisLabel();f.yAxis.axisLabel(a);return h},d3.rebind(h,f,"x","y"),h.graph=f;return h},a.charts.stackedAreaChart=function(){function h(){if(!b||!c.length)return h;d3.select(b).select("svg").datum(c).transition().duration(d).call(f);return h}var b=null,c=[],d=500,e=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" at "+b+"

"},f=a.models.stackedAreaWithLegend().x(function(a,b){return b}),g=function(c){var d=document.getElementById(b.substr(1)),g=c.pos[0]+d.offsetLeft,h=c.pos[1]+d.offsetTop,i=f.xAxis.tickFormat(),j=f.yAxis.tickFormat(),k=i(f.x()(c,c.pointIndex)),l=j(f.y()(c.point)),m=e(c.series.key,k,l,c,f);a.tooltip.show([g,h],m)};f.xAxis.tickFormat(function(a){return d3.time.format("%x")(new Date(c[0].values[a].x))}),f.yAxis.tickFormat(d3.format(",.2%")),h.build=function(){if(!b||!c.length)return h;a.addGraph({generate:function(){var a=d3.select(b),e=function(){return parseInt(a.style("width"))},g=function(){return parseInt(a.style("height"))},h=a.append("svg");f.width(e).height(g),h.attr("width",e()).attr("height",g()).datum(c).transition().duration(d).call(f);return f},callback:function(c){c.dispatch.on("tooltipShow",g),c.dispatch.on("tooltipHide",a.tooltip.cleanup),window.onresize=function(){d3.select(b+" svg").attr("width",c.width()()).attr("height",c.height()()).call(c)}}});return h},h.data=function(a){if(!arguments.length)return c;c=a;return h},h.selector=function(a){if(!arguments.length)return b;b=a;return h},h.duration=function(a){if(!arguments.length)return d;d=a;return h},h.tooltip=function(a){if(!arguments.length)return e;e=a;return h},h.xTickFormat=function(a){if(!arguments.length)return f.xAxis.tickFormat();f.xAxis.tickFormat(typeof a=="function"?a:d3.format(a));return h},h.yTickFormat=function(a){if(!arguments.length)return f.yAxis.tickFormat();f.yAxis.tickFormat(typeof a=="function"?a:d3.format(a));return h},h.xAxisLabel=function(a){if(!arguments.length)return f.xAxis.axisLabel();f.xAxis.axisLabel(a);return h},h.yAxisLabel=function(a){if(!arguments.length)return f.yAxis.axisLabel();f.yAxis.axisLabel(a);return h},d3.rebind(h,f,"x","y"),h.graph=f;return h}})() \ No newline at end of file +(function(){function b(a,b){var c=[31,28,31,30,31,30,31,31,30,31,30,31];return a!=2?c[a-1]:b%4!=0?c[1]:b%100==0&&b%400!=0?c[1]:c[1]+1}function c(a,b,c){return function(d,e,f){var g=a(d),h=[];g1)while(gl+k&&(o=l-h-5);break;case"w":n=b[0]+e,o=b[1]-h/2,n+i>j&&(n=b[0]-i-e),ol+k&&(o=l-h-5);break;case"n":n=b[0]-i/2,o=b[1]+e,nj&&(n=j-i-5),o+h>l+k&&(o=b[1]-h-e);break;case"s":n=b[0]-i/2,o=b[1]-h-e,nj&&(n=j-i-5),l>o&&(o=b[1]+20)}return f.style.left=n+"px",f.style.top=o+"px",f.style.opacity=1,f},b.cleanup=function(){var a=document.getElementsByClassName("nvtooltip"),b=[];while(a.length)b.push(a[0]),a[0].style.transitionDelay="0 !important",a[0].style.opacity=0,a[0].className="nvtooltip-pending-removal";setTimeout(function(){while(b.length){var a=b.pop();a.parentNode.removeChild(a)}},500)}}(),a.utils.windowSize=function(){var a={width:640,height:480};return document.body&&document.body.offsetWidth&&(a.width=document.body.offsetWidth,a.height=document.body.offsetHeight),document.compatMode=="CSS1Compat"&&document.documentElement&&document.documentElement.offsetWidth&&(a.width=document.documentElement.offsetWidth,a.height=document.documentElement.offsetHeight),window.innerWidth&&window.innerHeight&&(a.width=window.innerWidth,a.height=window.innerHeight),a},a.utils.windowResize=function(a){var b=window.onresize;window.onresize=function(c){typeof b=="function"&&b(c),a(c)}},a.models.axis=function(){function e(f){return f.each(function(e){(d.orient()=="top"||d.orient()=="bottom")&&d.ticks(Math.abs(a.range()[1]-a.range()[0])/100);var f=d3.select(this).selectAll("text.axislabel").data([b||null]);f.exit().remove();switch(d.orient()){case"top":f.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",0),f.attr("x",a.range()[1]/2);break;case"right":f.enter().append("text").attr("class","axislabel").attr("transform","rotate(90)").attr("y",-40),f.attr("x",-a.range()[0]/2);break;case"bottom":f.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",25),f.attr("x",a.range()[1]/2);break;case"left":f.enter().append("text").attr("class","axislabel").attr("transform","rotate(-90)").attr("y",-40),f.attr("x",-a.range()[0]/2)}f.text(function(a){return a}),d3.transition(d3.select(this)).call(d),c&&d3.select(this).selectAll("line.tick").filter(function(a){return!parseFloat(Math.round(a*1e5)/1e6)}).classed("zero",!0)}),e}var a=d3.scale.linear(),b=null,c=!0,d=d3.svg.axis().scale(a).orient("bottom").tickFormat(function(a){return a});return d3.rebind(e,d,"orient","ticks","tickValues","tickSubdivide","tickSize","tickPadding","tickFormat"),d3.rebind(e,a,"domain","range","rangeBand","rangeBands"),e.axisLabel=function(a){return arguments.length?(b=a,e):b},e.highlightZero=function(a){return arguments.length?(c=a,e):c},e.scale=function(b){return arguments.length?(a=b,d.scale(a),d3.rebind(e,a,"domain","range","rangeBand","rangeBands"),e):a},e},a.models.bar=function(){function q(r){return r.each(function(q){l.domain(q.map(function(a,b){return a[e]})).rangeRoundBands([0,b-a.left-a.right],.1);var r=d3.min(q,function(a){return a[j]}),s=d3.max(q,function(a){return a[j]}),t=Math.max(-r,s),u=-t;r>=0&&(u=0),m.domain([u,t]).range([c-a.top-a.bottom,0]).nice(),n.ticks(b/100),o.ticks(c/36).tickSize(-(b-a.right-a.left),0);var v=d3.select(this).on("click",function(a,b){p.chartClick({data:a,index:b,pos:d3.event,id:h})}),w=v.selectAll("g.wrap").data([q]),z=w.enter();z.append("text").attr("class","title").attr("dy",".91em").attr("text-anchor","start").text(k),z=z.append("g").attr("class","nvd3 wrap").attr("id","wrap-"+h).append("g"),z.append("g").attr("class","x axis"),z.append("g").attr("class","y axis"),z.append("g").attr("class","bars"),w.attr("width",b).attr("height",c);var A=w.select("g").attr("transform","translate("+a.left+","+a.top+")"),B=w.select(".bars").selectAll(".bar").data(function(a){return a});B.exit().remove();var C=B.enter().append("svg:rect").attr("class",function(a){return a[j]<0?"bar negative":"bar positive"}).attr("fill",function(a,b){return i(b)}).attr("x",0).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),p.tooltipShow({label:a[e],value:a[j],data:a,index:b,pos:[d3.event.pageX,d3.event.pageY],id:h})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),p.tooltipHide({label:a[e],value:a[j],data:a,index:b,id:h})}).on("click",function(a,b){p.elementClick({label:a[e],value:a[j],data:a,index:b,pos:d3.event,id:h}),d3.event.stopPropagation()}).on("dblclick",function(a,b){p.elementDblClick({label:a[e],value:a[j],data:a,index:b,pos:d3.event,id:h}),d3.event.stopPropagation()});B.attr("class",function(a){return a[j]<0?"bar negative":"bar positive"}).attr("transform",function(a,b){return"translate("+l(a[e])+",0)"}).attr("width",l.rangeBand).order().transition().duration(d).attr("y",function(a){return m(Math.max(0,a[j]))}).attr("height",function(a){return Math.abs(m(a[j])-m(0))}),A.select(".x.axis").attr("transform","translate(0,"+m.range()[0]+")").call(n),f&&A.select(".x.axis").selectAll("text").attr("text-anchor","start").attr("transform",function(a){return"rotate(35)translate("+this.getBBox().height/2+","+"0"+")"}),g||(A.select(".x.axis").selectAll("text").attr("fill","rgba(0,0,0,0)"),A.select(".x.axis").selectAll("line").attr("style","opacity: 0")),A.select(".y.axis").call(o)}),q}var a={top:20,right:10,bottom:80,left:60},b=960,c=500,d=500,e="label",f=!0,g=!0,h=Math.floor(Math.random()*1e4),i=d3.scale.category20(),j="y",k="",l=d3.scale.ordinal(),m=d3.scale.linear(),n=d3.svg.axis().scale(l).orient("bottom"),o=d3.svg.axis().scale(m).orient("left"),p=d3.dispatch("chartClick","elementClick","elementDblClick","tooltipShow","tooltipHide");return q.margin=function(b){return arguments.length?(a=b,q):a},q.width=function(c){return arguments.length?(a.left+a.right+20>c?b=a.left+a.right+20:b=c,q):b},q.height=function(b){return arguments.length?(a.top+a.bottom+20>b?c=a.top+a.bottom+20:c=b,q):c},q.animate=function(a){return arguments.length?(d=a,q):d},q.labelField=function(a){return arguments.length?(e=a,q):e},q.dataField=function(a){return arguments.length?(j=a,q):j},q.id=function(a){return arguments.length?(h=a,q):h},q.rotatedLabel=function(a){return arguments.length?(f=a,q):f},q.showLabels=function(a){return arguments.length?(g=a,q):g},q.title=function(a){return arguments.length?(k=a,q):k},q.xaxis={},d3.rebind(q.xaxis,n,"tickFormat"),q.yaxis={},d3.rebind(q.yaxis,o,"tickFormat"),q.dispatch=p,q},a.models.historicalBar=function(){function r(g){return g.each(function(g){var h=b-a.left-a.right,o=c-a.top-a.bottom;m.domain(k||d3.extent(g[0].values,e)).range([0,h]),n.domain(l||d3.extent(g[0].values,f)).range([o,0]);var p=d3.select(this).on("click",function(a,b){q.chartClick({data:a,index:b,pos:d3.event,id:d})}),r=d3.select(this).selectAll("g.wrap.bar").data([g[0].values]),s=r.enter().append("g").attr("class","wrap nvd3 bar"),t=s.append("g");t.append("g").attr("class","bars"),r.attr("width",b).attr("height",c);var u=r.select("g").attr("transform","translate("+a.left+","+a.top+")");s.append("defs").append("clipPath").attr("id","chart-clip-path-"+d).append("rect"),r.select("#chart-clip-path-"+d+" rect").attr("width",h).attr("height",o),t.attr("clip-path",i?"url(#chart-clip-path-"+d+")":"");var v=t.append("g").attr("class","shiftWrap"),w=r.select(".bars").selectAll(".bar").data(function(a){return a});w.exit().remove();var z=w.enter().append("svg:rect").attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("fill",function(a,b){return j[0]}).attr("x",0).attr("y",function(a,b){return n(Math.max(0,f(a,b)))}).attr("height",function(a,b){return Math.abs(n(f(a,b))-n(0))}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),q.elementMouseover({point:a,series:g[0],pos:[m(e(a,b)),n(f(a,b))],pointIndex:b,seriesIndex:0,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),q.elementMouseout({point:a,series:g[0],pointIndex:b,seriesIndex:0,e:d3.event})}).on("click",function(a,b){q.elementClick({value:f(a,b),data:a,index:b,pos:[m(e(a,b)),n(f(a,b))],e:d3.event,id:d}),d3.event.stopPropagation()}).on("dblclick",function(a,b){q.elementDblClick({value:f(a,b),data:a,index:b,pos:[m(e(a,b)),n(f(a,b))],e:d3.event,id:d}),d3.event.stopPropagation()});w.attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("transform",function(a,b){return"translate("+(m(e(a,b))-m(.5))+",0)"}).attr("width",m(.9)),d3.transition(w).attr("y",function(a,b){return n(Math.max(0,f(a,b)))}).attr("height",function(a,b){return Math.abs(n(f(a,b))-n(0))})}),r}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=Math.floor(Math.random()*1e4),e=function(a){return a.x},f=function(a){return a.y},g=[],h=[],i=!0,j=d3.scale.category20().range(),k,l,m=d3.scale.linear(),n=d3.scale.linear(),o=d3.svg.axis().scale(m).orient("bottom"),p=d3.svg.axis().scale(n).orient("left"),q=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return r.dispatch=q,r.x=function(a){return arguments.length?(e=a,r):e},r.y=function(a){return arguments.length?(f=a,r):f},r.margin=function(b){return arguments.length?(a=b,r):a},r.width=function(c){return arguments.length?(a.left+a.right+20>c?b=a.left+a.right+20:b=c,r):b},r.height=function(b){return arguments.length?(a.top+a.bottom+20>b?c=a.top+a.bottom+20:c=b,r):c},r.xDomain=function(a){return arguments.length?(k=a,r):k},r.yDomain=function(a){return arguments.length?(l=a,r):l},r.forceX=function(a){return arguments.length?(g=a,r):g},r.forceY=function(a){return arguments.length?(h=a,r):h},r.clipEdge=function(a){return arguments.length?(i=a,r):i},r.color=function(a){return arguments.length?(j=a,r):j},r.id=function(a){return arguments.length?(d=a,r):d},r},a.models.bullet=function(){function k(a){a.each(function(a,k){var l=d.call(this,a,k).slice().sort(d3.descending),m=e.call(this,a,k).slice().sort(d3.descending),n=f.call(this,a,k).slice().sort(d3.descending),o=d3.select(this),p=d3.scale.linear().domain([0,Math.max(l[0],m[0],n[0])]).range(b?[g,0]:[0,g]),q=this.__chart__||d3.scale.linear().domain([0,Infinity]).range(p.range());this.__chart__=p;var r=function(a){return Math.abs(q(a)-q(0))},s=function(a){return Math.abs(p(a)-p(0))},t=o.selectAll("rect.range").data(l);t.enter().append("rect").attr("class",function(a,b){return"range s"+b}).attr("width",r).attr("height",h).attr("x",b?q:0).on("mouseover",function(a,b){j.elementMouseover({value:a,label:b<=0?"Maximum":b>1?"Minimum":"Mean",pos:[p(a),h/2]})}).on("mouseout",function(a,b){j.elementMouseout({value:a,label:b<=0?"Minimum":b>=1?"Maximum":"Mean"})}).transition().duration(c).attr("width",s).attr("x",b?p:0),t.transition().duration(c).attr("x",b?p:0).attr("width",s).attr("height",h);var u=o.selectAll("rect.measure").data(n);u.enter().append("rect").attr("class",function(a,b){return"measure s"+b}).attr("width",r).attr("height",h/3).attr("x",b?q:0).attr("y",h/3).on("mouseover",function(a){j.elementMouseover({value:a,label:"Current",pos:[p(a),h/2]})}).on("mouseout",function(a){j.elementMouseout({value:a,label:"Current"})}).transition().duration(c).attr("width",s).attr("x",b?p:0),u.transition().duration(c).attr("width",s).attr("height",h/3).attr("x",b?p:0).attr("y",h/3);var v=o.selectAll("path.markerTriangle").data(m),w=h/6;v.enter().append("path").attr("class","markerTriangle").attr("transform",function(a){return"translate("+q(a)+","+h/2+")"}).attr("d","M0,"+w+"L"+w+","+ -w+" "+ -w+","+ -w+"Z").on("mouseover",function(a,b){j.elementMouseover({value:a,label:"Previous",pos:[p(a),h/2]})}).on("mouseout",function(a,b){j.elementMouseout({value:a,label:"Previous"})}),v.transition().duration(c).attr("transform",function(a){return"translate("+p(a)+","+h/2+")"}),v.exit().remove();var x=i||p.tickFormat(8),y=o.selectAll("g.tick").data(p.ticks(8),function(a){return this.textContent||x(a)}),z=y.enter().append("g").attr("class","tick").attr("transform",function(a){return"translate("+q(a)+",0)"}).style("opacity",1e-6);z.append("line").attr("y1",h).attr("y2",h*7/6),z.append("text").attr("text-anchor","middle").attr("dy","1em").attr("y",h*7/6).text(x),z.transition().duration(c).attr("transform",function(a){return"translate("+p(a)+",0)"}).style("opacity",1);var A=y.transition().duration(c).attr("transform",function(a){return"translate("+p(a)+",0)"}).style("opacity",1);A.select("line").attr("y1",h).attr("y2",h*7/6),A.select("text").attr("y",h*7/6),y.exit().transition().duration(c).attr("transform",function(a){return"translate("+p(a)+",0)"}).style("opacity",1e-6).remove()}),d3.timer.flush()}var a="left",b=!1,c=0,d=function(a){return a.ranges},e=function(a){return a.markers},f=function(a){return a.measures},g=380,h=30,i=null,j=d3.dispatch("elementMouseover","elementMouseout");return k.dispatch=j,k.orient=function(c){return arguments.length?(a=c,b=a=="right"||a=="bottom",k):a},k.ranges=function(a){return arguments.length?(d=a,k):d},k.markers=function(a){return arguments.length?(e=a,k):e},k.measures=function(a){return arguments.length?(f=a,k):f},k.width=function(a){return arguments.length?(g=a,k):g},k.height=function(a){return arguments.length?(h=a,k):h},k.tickFormat=function(a){return arguments.length?(i=a,k):i},k.duration=function(a){return arguments.length?(c=a,k):c},k},a.models.cumulativeLine=function(){function x(a,b){}function y(a,b){a.x+=d3.event.dx,a.i=Math.round(m.invert(a.x)),d3.select(this).attr("transform","translate("+m(a.i)+",0)")}function z(a,b){d3.transition(d3.select(".chart-"+i)).call(A)}function A(a){return a.each(function(f){var g=c(),h=d(),x=g-b.left-b.right,y=h-b.top-b.bottom,z=B(u.i,f),C=z.filter(function(a){return!k||!a.disabled}).map(function(a){return a.values});l.domain(d3.extent(d3.merge(C),function(a){return a.x})).range([0,x]),m.domain([0,f[0].values.length-1]).range([0,x]).clamp(!0),n.domain(d3.extent(d3.merge(C),function(a){return a.y})).range([y,0]),s.width(x).height(y).color(f.map(function(a,b){return a.color||e[b%10]}).filter(function(a,b){return!f[b].disabled}));var D=d3.select(this).classed("chart-"+i,!0).selectAll("g.wrap").data([z]),E=D.enter().append("g").attr("class","wrap nvd3 cumulativeLine").append("g");E.append("g").attr("class","x axis"),E.append("g").attr("class","y axis"),E.append("g").attr("class","linesWrap"),E.append("g").attr("class","legendWrap"),E.append("g").attr("class","controlsWrap"),b.top=q.height();var F=D.select("g").attr("transform","translate("+b.left+","+b.top+")");q.width(g/2-b.right),F.select(".legendWrap").datum(f).attr("transform","translate("+(g/2-b.left)+","+ -b.top+")").call(q),j&&(r.width(140).color(["#444","#444","#444"]),F.select(".controlsWrap").datum(v).attr("transform","translate(0,"+ -b.top+")").call(r));var G=F.select(".linesWrap").datum(z.filter(function(a){return!a.disabled}));d3.transition(G).call(s);var H=G.selectAll(".indexLine").data([u]);H.enter().append("rect").attr("class","indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).call(w),H.attr("transform",function(a){return"translate("+m(a.i)+",0)"}).attr("height",y),o.domain(l.domain()).range(l.range()).ticks(g/100).tickSize(-y,0),F.select(".x.axis").attr("transform","translate(0,"+n.range()[0]+")"),d3.transition(F.select(".x.axis")).call(o),p.domain(n.domain()).range(n.range()).ticks(h/36).tickSize(-x,0),d3.transition(F.select(".y.axis")).call(p),q.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,f.filter(function(a){return!a.disabled}).length||f.map(function(a){return a.disabled=!1,D.selectAll(".series").classed("disabled",!1),a}),a.transition().call(A)}),r.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,k=!b.disabled,a.transition().call(A)}),s.dispatch.on("elementMouseover.tooltip",function(a){t.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),s.dispatch.on("elementMouseout.tooltip",function(a){t.tooltipHide(a)})}),A}function B(a,b){return b.map(function(b,c){var d=h(b.values[a],a);return{key:b.key,values:b.values.map(function(a,b){return{x:g(a,b),y:(h(a,b)-d)/(1+d)}}),disabled:b.disabled,hover:b.hover}})}var b={top:30,right:20,bottom:30,left:60},c=function(){return 960},d=function(){return 500},e=d3.scale.category20().range(),f=function(){return 2.5},g=function(a){return a.x},h=function(a){return a.y},i=Math.floor(Math.random()*1e4),j=!0,k=!0,l=d3.scale.linear(),m=d3.scale.linear(),n=d3.scale.linear(),o=a.models.axis().scale(l).orient("bottom"),p=a.models.axis().scale(n).orient("left"),q=a.models.legend().height(30),r=a.models.legend().height(30),s=a.models.line(),t=d3.dispatch("tooltipShow","tooltipHide"),u={i:0,x:0},v=[{key:"Re-scale y-axis"}],w=d3.behavior.drag().on("dragstart",x).on("drag",y).on("dragend",z);return A.dispatch=t,A.x=function(a){return arguments.length?(g=a,A):g},A.y=function(a){return arguments.length?(h=a,A):h},A.margin=function(a){return arguments.length?(b=a,A):b},A.width=function(a){return arguments.length?(c=d3.functor(a),A):c},A.height=function(a){return arguments.length?(d=d3.functor(a),A):d},A.color=function(a){return arguments.length?(e=a,q.color(a),A):e},A.dotRadius=function(a){return arguments.length?(f=d3.functor(a),s.dotRadius=a,A):f},A.showRescaleToggle=function(a){return arguments.length?(j=a,A):j},A.xAxis=o,A.yAxis=p,A},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;o=o||e,p=p||f,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?0:12]):f.range([u,0]);var w=d3.select(this).selectAll("g.wrap.discretebar").data([s]),z=w.enter().append("g").attr("class","wrap nvd3 discretebar"),A=z.append("g");A.append("g").attr("class","groups");var B=w.select("g");w.attr("transform","translate("+a.left+","+a.top+")");var C=w.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});C.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(C.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),C.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}),d3.transition(C).style("stroke-opacity",1).style("fill-opacity",.75);var D=C.selectAll("g.bar").data(function(a){return a.values});D.exit().remove();var E=D.enter().append("g").attr("transform",function(a,b,c){return"translate("+e(g(a,b))+", "+f(0)+")"}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),q.elementMouseover({value:h(a,b),point:a,series:s[a.series],pos:[e(g(a,b))+e.rangeBand()*(a.series+.5)/s.length,f(h(a,b))],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),q.elementMouseout({value:h(a,b),point:a,series:s[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){q.elementClick({value:h(a,b),point:a,series:s[a.series],pos:[e(g(a,b))+e.rangeBand()*(a.series+.5)/s.length,f(h(a,b))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(a,b){q.elementDblClick({value:h(a,b),point:a,series:s[a.series],pos:[e(g(a,b))+e.rangeBand()*(a.series+.5)/s.length,f(h(a,b))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()});E.append("rect").attr("height",0).attr("width",e.rangeBand()/s.length).style("fill",function(a,b){return a.color||j[b%10]}).style("stroke",function(a,b){return a.color||j[b%10]}),k?(E.append("text").attr("text-anchor","middle"),D.selectAll("text").attr("dx",e.rangeBand()/2).attr("dy",function(a,b){return h(a,b)<0?f(h(a,b))-f(0)+12:-4}).text(function(a,b){return l(h(a,b))})):D.selectAll("text").remove(),D.attr("class",function(a,b){return h(a,b)<0?"bar negative":"bar positive"}),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("width",e.rangeBand()/s.length).attr("height",function(a,b){return Math.abs(f(h(a,b))-f(0))}),r.update=function(){d.transition().call(r)},o=e.copy(),p=f.copy()}),r}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=Math.floor(Math.random()*1e4),e=d3.scale.ordinal(),f=d3.scale.linear(),g=function(a){return a.x},h=function(a){return a.y},i=[0],j=d3.scale.category20().range(),k=!1,l=d3.format(",.2f"),m,n,o,p,q=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return r.dispatch=q,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.valuesFormat=function(a){return arguments.length?(l=a,r):l},r},a.models.discreteBarChart=function(){function q(e){return e.each(function(h){var p=d3.select(this),r=(c||parseInt(p.style("width"))||960)-b.left-b.right,s=(d||parseInt(p.style("height"))||400)-b.top-b.bottom;i.width(r).height(s);var t=p.selectAll("g.wrap.discreteBarWithAxes").data([h]),u=t.enter().append("g").attr("class","wrap nvd3 discreteBarWithAxes").append("g"),v=u.append("defs");u.append("g").attr("class","x axis"),u.append("g").attr("class","y axis"),u.append("g").attr("class","barsWrap");var w=t.select("g");w.attr("transform","translate("+b.left+","+b.top+")");var z=w.select(".barsWrap").datum(h.filter(function(a){return!a.disabled}));d3.transition(z).call(i),v.append("clipPath").attr("id","x-label-clip-"+i.id()).append("rect"),w.select("#x-label-clip-"+i.id()+" rect").attr("width",j.rangeBand()*(f?2:1)).attr("height",16).attr("x",-j.rangeBand()/(f?1:2)),l.scale(j).ticks(r/100).tickSize(-s,0),w.select(".x.axis").attr("transform","translate(0,"+(k.range()[0]+(i.showValues()?16:0))+")"),d3.transition(w.select(".x.axis")).call(l);var A=w.select(".x.axis").selectAll("g");f&&A.selectAll("text").attr("transform",function(a,b,c){return"translate(0,"+(c%2==0?"0":"12")+")"}),A.selectAll("text").attr("clip-path",function(a,b,c){return"url(#x-label-clip-"+i.id()+")"}),m.scale(k).ticks(s/36).tickSize(-r,0),d3.transition(w.select(".y.axis")).call(m),i.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],n.tooltipShow(a)}),g&&n.on("tooltipShow",function(a){o(a,p[0][0])}),i.dispatch.on("elementMouseout.tooltip",function(a){n.tooltipHide(a)}),g&&n.on("tooltipHide",a.tooltip.cleanup),q.update=function(){e.transition().call(q)}}),q}var b={top:30,right:20,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!1,g=!0,h=function(a,b,c,d,e){return"

"+b+"

"+"

"+c+"

"},i=a.models.discreteBar(),j=i.xScale(),k=i.yScale(),l=a.models.axis().scale(j).orient("bottom").highlightZero(!1),m=a.models.axis().scale(k).orient("left"),n=d3.dispatch("tooltipShow","tooltipHide");l.tickFormat(function(a){return a}),m.tickFormat(d3.format(",.1f"));var o=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=l.tickFormat()(i.x()(b.point)),g=m.tickFormat()(i.y()(b.point)),j=h(b.series.key,f,g,b,q);a.tooltip.show([d,e],j,b.value<0?"n":"s")},p=[{key:"Grouped"},{key:"Stacked",disabled:!0}];return q.dispatch=n,q.discretebar=i,q.xAxis=l,q.yAxis=m,d3.rebind(q,i,"x","y","xDomain","yDomain","forceX","forceY","id","showValues","valueFormat"),q.margin=function(a){return arguments.length?(b=a,q):b},q.width=function(a){return arguments.length?(c=d3.functor(a),q):c},q.height=function(a){return arguments.length?(d=d3.functor(a),q):d},q.color=function(a){return arguments.length?(e=a,i.color(a),q):e},q.staggerLabels=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.discreteBarWithAxes=function(){function n(a){return a.each(function(a){var e=c()-b.left-b.right,m=d()-b.top-b.bottom,n=a.filter(function(a){return!a.disabled}).map(function(a){return a.values.map(function(a,b){return{x:g.x()(a,b),y:g.y()(a,b)}})});g.width(e).height(m);var o=d3.select(this).selectAll("g.wrap.discreteBarWithAxes").data([a]),p=o.enter().append("g").attr("class","wrap nvd3 discreteBarWithAxes").append("g");p.append("g").attr("class","x axis"),p.append("g").attr("class","y axis"),p.append("g").attr("class","barsWrap");var q=o.select("g");q.attr("transform","translate("+b.left+","+b.top+")");var r=q.select(".barsWrap").datum(a.filter(function(a){return!a.disabled}));d3.transition(r).call(g),j.scale(h).ticks(e/100).tickSize(-m,0),q.select(".x.axis").attr("transform","translate(0,"+i.range()[0]+")"),d3.transition(q.select(".x.axis")).call(j);var s=q.select(".x.axis").selectAll("g");f&&s.selectAll("text").attr("transform",function(a,b,c){return"translate(0,"+(c%2==0?"0":"12")+")"}),k.scale(i).ticks(m/36).tickSize(-e,0),d3.transition(q.select(".y.axis")).call(k),g.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],l.tooltipShow(a)}),g.dispatch.on("elementMouseout.tooltip",function(a){l.tooltipHide(a)})}),n}var b={top:30,right:20,bottom:50,left:60},c=function(){return 960},d=function(){return 500},e=d3.scale.category20().range(),f=!1,g=a.models.discreteBar(),h=g.xScale(),i=g.yScale(),j=a.models.axis().scale(h).orient("bottom").highlightZero(!1),k=a.models.axis().scale(i).orient("left"),l=d3.dispatch("tooltipShow","tooltipHide"),m=[{key:"Grouped"},{key:"Stacked",disabled:!0}];return n.dispatch=l,n.xAxis=j,n.yAxis=k,d3.rebind(n,g,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id"),n.margin=function(a){return arguments.length?(b=a,n):b},n.width=function(a){return arguments.length?(c=d3.functor(a),n):c},n.height=function(a){return arguments.length?(d=d3.functor(a),n):d},n.color=function(a){return arguments.length?(e=a,g.color(a),n):e},n.staggerLabels=function(a){return arguments.length?(f=a,n):f},n},a.models.legend=function(){function f(g){return g.each(function(f){var g=d3.select(this).selectAll("g.legend").data([f]),h=g.enter().append("g").attr("class","nvd3 legend").append("g"),i=g.select("g").attr("transform","translate("+a.left+","+a.top+")"),j=i.selectAll(".series").data(function(a){return a}),k=j.enter().append("g").attr("class","series").on("mouseover",function(a,b){e.legendMouseover(a,b)}).on("mouseout",function(a,b){e.legendMouseout(a,b)}).on("click",function(a,b){e.legendClick(a,b)});k.append("circle").style("fill",function(a,b){return a.color||d[b%20]}).style("stroke",function(a,b){return a.color||d[b%20]}).style("stroke-width",2).attr("r",5),k.append("text").text(function(a){return a.key}).attr("text-anchor","start").attr("dy",".32em").attr("dx","8"),j.classed("disabled",function(a){return a.disabled}),j.exit().remove();var l=5,m=5,n=0,o;j.attr("transform",function(c,d){var e=d3.select(this).select("text").node().getComputedTextLength()+28;return o=m,bn&&(n=m),"translate("+o+","+l+")"}),i.attr("transform","translate("+(b-a.right-n)+","+a.top+")"),c=a.top+a.bottom+l+15}),f}var a={top:5,right:0,bottom:5,left:10},b=400,c=20,d=d3.scale.category20().range(),e=d3.dispatch("legendClick","legendMouseover","legendMouseout");return f.dispatch=e,f.margin=function(b){return arguments.length?(a=b,f):a},f.width=function(a){return arguments.length?(b=a,f):b},f.height=function(a){return arguments.length?(c=a,f):c},f.color=function(a){return arguments.length?(d=a,f):d},f},a.models.line=function(){function p(a){return a.each(function(a){var o=c-b.left-b.right,p=d-b.top-b.bottom,q=d3.select(this).selectAll("g.wrap.line").data([a]),r=q.enter().append("g").attr("class","wrap nvd3 line"),s=r.append("defs"),t=r.append("g"),u=q.select("g");r.append("g").attr("class","scatterWrap");var v=q.select(".scatterWrap").datum(a);t.append("g").attr("class","groups"),j.width(o).height(p),d3.transition(v).call(j),q.attr("transform","translate("+b.left+","+b.top+")"),s.append("clipPath").attr("id","edge-clip-"+f).append("rect"),q.select("#edge-clip-"+f+" rect").attr("width",o).attr("height",p),u.attr("clip-path",i?"url(#edge-clip-"+f+")":""),v.attr("clip-path",i?"url(#edge-clip-"+f+")":"");var w=q.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});w.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(w.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),w.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return e[b%20]}).style("stroke",function(a,b){return e[b%20]}),d3.transition(w).style("stroke-opacity",1).style("fill-opacity",.5);var z=w.selectAll("path").data(function(a,b){return[a.values]});z.enter().append("path").attr("d",d3.svg.line().x(function(a,b){return m(g(a,b))}).y(function(a,b){return n(h(a,b))})),d3.transition(w.exit().selectAll("path")).attr("d",d3.svg.line().x(function(a,b){return k(g(a,b))}).y(function(a,b){return l(h(a,b))})).remove(),d3.transition(z).attr("d",d3.svg.line().x(function(a,b){return k(g(a,b))}).y(function(a,b){return l(h(a,b))})),m=k.copy(),n=l.copy()}),p}var b={top:0,right:0,bottom:0,left:0},c=960,d=500,e=d3.scale.category20().range(),f=Math.floor(Math.random()*1e4),g=function(a){return a.x},h=function(a){return a.y},i=!1,j=a.models.scatter().id(f).size(2.5).sizeDomain([2.5]),k=j.xScale(),l=j.yScale(),m=k,n=l,o;return p.dispatch=j.dispatch,d3.rebind(p,j,"interactive","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius"),p.margin=function(a){return arguments.length?(b=a,p):b},p.width=function(a){return arguments.length?(c=a,p):c},p.height=function(a){return arguments.length?(d=a,p):d},p.x=function(a){return arguments.length?(g=a,j.x(a),p):g},p.y=function(a){return arguments.length?(h=a,j.y(a),p):h},p.clipEdge=function(a){return arguments.length?(i=a,p):i},p.color=function(a){return arguments.length?(e=a,j.color(a),p):e},p.id=function(a){return arguments.length?(f=a,p):f},p},a.models.lineChart=function(){function p(g){return g.each(function(q){var r=d3.select(this),s=(d||parseInt(r.style("width"))||960)-b.left-b.right,t=(e||parseInt(r.style("height" +))||400)-b.top-b.bottom;h.width(s).height(t).color(q.map(function(a,b){return a.color||c[b%10]}).filter(function(a,b){return!q[b].disabled}));var u=r.selectAll("g.wrap.lineWithLegend").data([q]),v=u.enter().append("g").attr("class","wrap nvd3 lineWithLegend").append("g");v.append("g").attr("class","x axis"),v.append("g").attr("class","y axis"),v.append("g").attr("class","linesWrap"),v.append("g").attr("class","legendWrap");var w=u.select("g");f&&(b.top=m.height(),m.width(s),w.select(".legendWrap").datum(q).attr("transform","translate(0,"+ -b.top+")").call(m)),w.attr("transform","translate("+b.left+","+b.top+")");var z=w.select(".linesWrap").datum(q.filter(function(a){return!a.disabled}));d3.transition(z).call(h),k.scale(i).ticks(s/100).tickSize(-t,0),w.select(".x.axis").attr("transform","translate(0,"+j.range()[0]+")"),d3.transition(w.select(".x.axis")).call(k),l.scale(j).ticks(t/36).tickSize(-s,0),d3.transition(w.select(".y.axis")).call(l),m.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,q.filter(function(a){return!a.disabled}).length||q.map(function(a){return a.disabled=!1,u.selectAll(".series").classed("disabled",!1),a}),g.transition().call(p)}),h.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],n.tooltipShow(a)}),n.on("tooltipShow",function(a){o(a,r[0][0])}),h.dispatch.on("elementMouseout.tooltip",function(a){n.tooltipHide(a)}),n.on("tooltipHide",a.tooltip.cleanup)}),p.update=function(){p(g)},p}var b={top:30,right:20,bottom:50,left:60},c=d3.scale.category20().range(),d=null,e=null,f=!0,g=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" at "+b+"

"},h=a.models.line(),i=h.xScale(),j=h.yScale(),k=a.models.axis().scale(i).orient("bottom"),l=a.models.axis().scale(j).orient("left"),m=a.models.legend().height(30),n=d3.dispatch("tooltipShow","tooltipHide"),o=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=k.tickFormat()(h.x()(b.point)),i=l.tickFormat()(h.y()(b.point)),j=g(b.series.key,f,i,b,p);a.tooltip.show([d,e],j)};return p.dispatch=n,p.legend=m,p.xAxis=k,p.yAxis=l,d3.rebind(p,h,"x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),p.margin=function(a){return arguments.length?(b=a,p):b},p.width=function(a){return arguments.length?(d=a,p):d},p.height=function(a){return arguments.length?(e=a,p):e},p.showLegend=function(a){return arguments.length?(f=a,p):f},p},a.models.linePlusBar=function(){function s(a){return a.each(function(e){var t=c(),u=d(),v=t-b.left-b.right,w=u-b.top-b.bottom,y=e.filter(function(a){return!a.disabled&&a.bar}).map(function(a){return a.values.map(function(a,b){return{x:f(a,b),y:g(a,b)}})}),z=e.filter(function(a){return!a.disabled&&!a.bar}).map(function(a){return a.values.map(function(a,b){return{x:f(a,b),y:g(a,b)}})});j.domain(d3.extent(d3.merge(y.concat(z)),function(a){return a.x})).range([0,v]),k.domain(d3.extent(d3.merge(y),function(a){return a.y})).range([w,0]),l.domain(d3.extent(d3.merge(z),function(a){return a.y})).range([w,0]),q.width(v).height(w).color(e.map(function(a,b){return a.color||h[b%10]}).filter(function(a,b){return!e[b].disabled&&!e[b].bar})),r.width(v).height(w).color(e.map(function(a,b){return a.color||h[b%10]}).filter(function(a,b){return!e[b].disabled&&e[b].bar}));var A=d3.select(this).selectAll("g.wrap.linePlusBar").data([e]),B=A.enter().append("g").attr("class","wrap nvd3 linePlusBar").append("g");B.append("g").attr("class","x axis"),B.append("g").attr("class","y1 axis"),B.append("g").attr("class","y2 axis"),B.append("g").attr("class","barsWrap"),B.append("g").attr("class","linesWrap"),B.append("g").attr("class","legendWrap"),p.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,e.filter(function(a){return!a.disabled}).length||e.map(function(a){return a.disabled=!1,A.selectAll(".series").classed("disabled",!1),a}),a.transition().call(s)}),q.dispatch.on("elementMouseover.tooltip",function(a){i.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),q.dispatch.on("elementMouseout.tooltip",function(a){i.tooltipHide(a)}),r.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],i.tooltipShow(a)}),r.dispatch.on("elementMouseout.tooltip",function(a){i.tooltipHide(a)}),b.top=p.height();var C=A.select("g").attr("transform","translate("+b.left+","+b.top+")");p.width(t/2-b.right),C.select(".legendWrap").datum(e.map(function(a){return a.key=a.key+(a.bar?" (left axis)":" (right axis)"),a})).attr("transform","translate("+(t/2-b.left)+","+ -b.top+")").call(p);var D=e.filter(function(a){return!a.disabled&&a.bar}),E=C.select(".barsWrap").datum(D.length?D:[{values:[]}]),F=C.select(".linesWrap").datum(e.filter(function(a){return!a.disabled&&!a.bar}));d3.transition(E).call(r),d3.transition(F).call(q),m.domain(j.domain()).range(j.range()).ticks(t/100).tickSize(-w,0),C.select(".x.axis").attr("transform","translate(0,"+k.range()[0]+")"),d3.transition(C.select(".x.axis")).call(m),n.domain(k.domain()).range(k.range()).ticks(u/36).tickSize(-v,0),d3.transition(C.select(".y1.axis")).call(n),o.domain(l.domain()).range(l.range()).ticks(u/36).tickSize(y.length?0:-v,0),C.select(".y2.axis").attr("transform","translate("+j.range()[1]+",0)"),d3.transition(C.select(".y2.axis")).call(o)}),s}var b={top:30,right:60,bottom:50,left:60},c=function(){return 960},d=function(){return 500},e=function(){return 2.5},f=function(a){return a.x},g=function(a){return a.y},h=d3.scale.category20().range(),i=d3.dispatch("tooltipShow","tooltipHide"),j=d3.scale.linear(),k=d3.scale.linear(),l=d3.scale.linear(),m=a.models.axis().scale(j).orient("bottom"),n=a.models.axis().scale(k).orient("left"),o=a.models.axis().scale(l).orient("right"),p=a.models.legend().height(30),q=a.models.line(),r=a.models.historicalBar();return s.dispatch=i,s.legend=p,s.lines=q,s.bars=r,s.xAxis=m,s.yAxis1=n,s.yAxis2=o,s.x=function(a){return arguments.length?(f=a,q.x(a),r.x(a),s):f},s.y=function(a){return arguments.length?(g=a,q.y(a),r.y(a),s):g},s.margin=function(a){return arguments.length?(b=a,s):b},s.width=function(a){return arguments.length?(c=d3.functor(a),s):c},s.height=function(a){return arguments.length?(d=d3.functor(a),s):d},s.dotRadius=function(a){return arguments.length?(e=d3.functor(a),q.dotRadius=a,s):e},s.color=function(a){return arguments.length?(h=a,p.color(a),s):h},s},a.models.lineWithFocus=function(){function y(a){return a.each(function(k){function K(){L(),H.call(u),D.select(".x.axis").call(p),D.select(".y.axis").call(q)}function L(){var a=x.empty()?o.domain():d3.extent(d3.merge(z).filter(function(a){return i(a)>=x.extent()[0]&&i(a)<=x.extent()[1]}),j);typeof a[0]=="undefined"&&(a=o.domain()),l.domain(x.empty()?n.domain():x.extent()),m.domain(a),u.xDomain(l.domain()),u.yDomain(m.domain())}var z=k.filter(function(a){return!a.disabled}).map(function(a){return a.values}),A=d-b.left-b.right,B=f-b.top-b.bottom,C=g-c.top-c.bottom;n.domain(d3.extent(d3.merge(z),i)).range([0,A]),o.domain(d3.extent(d3.merge(z),j)).range([C,0]),l.domain(x.empty()?n.domain():x.extent()).range([0,A]),m.domain(o.domain()).range([B,0]),x.on("brush",K),u.width(A).height(B).color(k.map(function(a,b){return a.color||h[b%10]}).filter(function(a,b){return!k[b].disabled})),v.width(A).height(C).color(k.map(function(a,b){return a.color||h[b%10]}).filter(function(a,b){return!k[b].disabled})),L();var D=d3.select(this).selectAll("g.wrap").data([k]),E=D.enter().append("g").attr("class","wrap nvd3 lineWithFocus").append("g");E.append("g").attr("class","focus"),E.append("g").attr("class","context"),E.append("g").attr("class","legendWrap");var F=D.select("g");t.width(d/2-b.right),F.select(".legendWrap").datum(k).attr("transform","translate("+A/2+",0)").call(t),b.top=t.height();var G=F.select(".focus").attr("transform","translate("+b.left+","+b.top+")");E.select(".focus").append("g").attr("class","x axis"),E.select(".focus").append("g").attr("class","y axis"),E.select(".focus").append("g").attr("class","focusLines");var H=G.select(".focusLines").datum(k.filter(function(a){return!a.disabled}));d3.transition(H).call(u),p.domain(l.domain()).range(l.range()).ticks(d/100).tickSize(-B,0),G.select(".x.axis").attr("transform","translate(0,"+m.range()[0]+")"),d3.transition(F.select(".x.axis")).call(p),q.domain(m.domain()).range(m.range()).ticks(e/36).tickSize(-A,0),d3.transition(F.select(".y.axis")).call(q);var I=F.select(".context").attr("transform","translate("+c.left+","+f+")");E.select(".context").append("g").attr("class","x2 axis"),E.select(".context").append("g").attr("class","y2 axis"),E.select(".context").append("g").attr("class","contextLines"),E.select(".context").append("g").attr("class","x brush").attr("class","x brush").call(x).selectAll("rect").attr("y",-5).attr("height",g+4);var J=I.select(".contextLines").datum(k.filter(function(a){return!a.disabled}));d3.transition(J).call(v),r.domain(n.domain()).range(n.range()).ticks(d/100).tickSize(-C,0),I.select(".x2.axis").attr("transform","translate(0,"+o.range()[0]+")"),d3.transition(I.select(".x2.axis")).call(r),s.domain(o.domain()).range(o.range()).ticks(C/24).tickSize(-A,0),I.select(".y2.axis"),d3.transition(I.select(".y2.axis")).call(s),t.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,k.filter(function(a){return!a.disabled}).length||k.map(function(a){return a.disabled=!1,D.selectAll(".series").classed("disabled",!1),a}),a.transition().call(y)}),u.dispatch.on("elementMouseover.tooltip",function(a){w.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),u.dispatch.on("elementMouseout.tooltip",function(a){w.tooltipHide(a)})}),y}var b={top:30,right:20,bottom:30,left:60},c={top:0,right:20,bottom:20,left:60},d=960,e=500,f=400,g=100,h=d3.scale.category20().range(),i=function(a){return a.x},j=function(a){return a.y},k=Math.floor(Math.random()*1e4),l=d3.scale.linear(),m=d3.scale.linear(),n=d3.scale.linear(),o=d3.scale.linear(),p=a.models.axis().scale(l).orient("bottom"),q=a.models.axis().scale(m).orient("left"),r=a.models.axis().scale(n).orient("bottom"),s=a.models.axis().scale(o).orient("left"),t=a.models.legend().height(30),u=a.models.line().clipEdge(!0),v=a.models.line().interactive(!1),w=d3.dispatch("tooltipShow","tooltipHide"),x=d3.svg.brush().x(n);return y.dispatch=w,y.x=function(a){return arguments.length?(i=a,u.x(a),v.x(a),y):i},y.y=function(a){return arguments.length?(j=a,u.y(a),v.y(a),y):j},y.margin=function(a){return arguments.length?(b=a,y):b},y.width=function(a){return arguments.length?(d=a,y):d},y.height=function(a){return arguments.length?(e=a,f=a-g,y):e},y.contextHeight=function(a){return arguments.length?(g=a,f=e-a,y):g},y.id=function(a){return arguments.length?(k=a,y):k},y.xTickFormat=function(a){return arguments.length?(p.tickFormat(a),r.tickFormat(a),y):l.tickFormat()},y.yTickFormat=function(a){return arguments.length?(q.tickFormat(a),s.tickFormat(a),y):m.tickFormat()},y.xAxis=p,y.yAxis=q,y},a.models.lineWithLegend=function(){function m(a){return a.each(function(n){var o=(d||parseInt(d3.select(this).style("width"))||960)-b.left-b.right,p=(e||parseInt(d3.select(this).style("height"))||400)-b.top-b.bottom;f.width(o).height(p).color(n.map(function(a,b){return a.color||c[b%10]}).filter(function(a,b){return!n[b].disabled}));var q=d3.select(this).selectAll("g.wrap.lineWithLegend").data([n]),r=q.enter().append("g").attr("class","wrap nvd3 lineWithLegend").append("g");r.append("g").attr("class","x axis"),r.append("g").attr("class","y axis"),r.append("g").attr("class","linesWrap"),r.append("g").attr("class","legendWrap"),b.top=k.height();var s=q.select("g").attr("transform","translate("+b.left+","+b.top+")");k.width(o/2),s.select(".legendWrap").datum(n).attr("transform","translate("+o/2+","+ -b.top+")").call(k);var t=s.select(".linesWrap").datum(n.filter(function(a){return!a.disabled}));d3.transition(t).call(f),i.domain(g.domain()).range(g.range()).ticks(o/100).tickSize(-p,0),s.select(".x.axis").attr("transform","translate(0,"+h.range()[0]+")"),d3.transition(s.select(".x.axis")).call(i),j.domain(h.domain()).range(h.range()).ticks(p/36).tickSize(-o,0),d3.transition(s.select(".y.axis")).call(j),k.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,n.filter(function(a){return!a.disabled}).length||n.map(function(a){return a.disabled=!1,q.selectAll(".series").classed("disabled",!1),a}),a.transition().call(m)}),f.dispatch.on("elementMouseover.tooltip",function(a){l.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),f.dispatch.on("elementMouseout.tooltip",function(a){l.tooltipHide(a)})}),b.top!=k.height()&&m(a),m}var b={top:30,right:20,bottom:50,left:60},c=d3.scale.category20().range(),d,e,f=a.models.line(),g=f.xScale(),h=f.yScale(),i=a.models.axis().scale(g).orient("bottom"),j=a.models.axis().scale(h).orient("left"),k=a.models.legend().height(30),l=d3.dispatch("tooltipShow","tooltipHide");return m.dispatch=l,m.legend=k,m.xAxis=i,m.yAxis=j,d3.rebind(m,f,"x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),m.margin=function(a){return arguments.length?(b=a,m):b},m.width=function(a){return arguments.length?(d=a,m):d},m.height=function(a){return arguments.length?(e=a,m):e},m},a.models.multiBar=function(){function r(s){return s.each(function(t){var u=b-a.left-a.right,v=c-a.top-a.bottom;m=m||o,n=n||p,i&&(t=d3.layout.stack().offset("zero").values(function(a){return a.values}).y(f)(t)),t=t.map(function(a,b){return a.values=a.values.map(function(a){return a.series=b,a}),a});var w=k&&l?[]:t.map(function(a){return a.values.map(function(a,b){return{x:e(a,b),y:f(a,b),y0:a.y0}})});o.domain(d3.merge(w).map(function(a){return a.x})).rangeBands([0,u],.1),p.domain(l||d3.extent(d3.merge(w).map(function(a){return a.y+(i?a.y0:0)}).concat(g))).range([v,0]);var z=d3.select(this).selectAll("g.wrap.multibar").data([t]),A=z.enter().append("g").attr("class","wrap nvd3 multibar"),B=A.append("defs"),C=A.append("g");C.append("g").attr("class","groups");var D=z.select("g");z.attr("transform","translate("+a.left+","+a.top+")"),B.append("clipPath").attr("id","edge-clip-"+d).append("rect"),z.select("#edge-clip-"+d+" rect").attr("width",u).attr("height",v),D.attr("clip-path",h?"url(#edge-clip-"+d+")":"");var E=z.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});E.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(E.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),E.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return j[b%10]}).style("stroke",function(a,b){return j[b%10]}),d3.transition(E).style("stroke-opacity",1).style("fill-opacity",.75);var F=E.selectAll("rect.bar").data(function(a){return a.values});F.exit().remove();var G=F.enter().append("rect").attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("x",function(a,b,c){return i?0:c*o.rangeBand()/t.length}).attr("y",function(a){return n(i?a.y0:0)}).attr("height",0).attr("width",o.rangeBand()/(i?1:t.length)).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),q.elementMouseover({value:f(a,b),point:a,series:t[a.series],pos:[o(e(a,b))+o.rangeBand()*(i?t.length/2:a.series+.5)/t.length,p(f(a,b)+(i?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),q.elementMouseout({value:f(a,b),point:a,series:t[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){q.elementClick({value:f(a,b),point:a,series:t[a.series],pos:[o(e(a,b))+o.rangeBand()*(i?t.length/2:a.series+.5)/t.length,p(f(a,b)+(i?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(a,b){q.elementDblClick({value:f(a,b),point:a,series:t[a.series],pos:[o(e(a,b))+o.rangeBand()*(i?t.length/2:a.series+.5)/t.length,p(f(a,b)+(i?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()});F.attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("transform",function(a,b){return"translate("+o(e(a,b))+",0)"}),i?d3.transition(F).delay(function(a,b){return b*1e3/t[0].values.length}).attr("y",function(a,b){return p(f(a,b)+(i?a.y0:0))}).attr("height",function(a,b){return Math.abs(p(a.y+(i?a.y0:0))-p(i?a.y0:0))}).each("end",function(){d3.transition(d3.select(this)).attr("x",function(a,b){return i?0:a.series*o.rangeBand()/t.length}).attr("width",o.rangeBand()/(i?1:t.length))}):d3.transition(F).delay(function(a,b){return b*1200/t[0].values.length}).attr("x",function(a,b){return a.series*o.rangeBand()/t.length}).attr("width",o.rangeBand()/t.length).each("end",function(){d3.transition(d3.select(this)).attr("y",function(a,b){return f(a,b)<0?p(0):p(f(a,b))}).attr("height",function(a,b){return Math.abs(p(f(a,b))-p(0))})}),r.update=function(){s.transition().call(r)},m=o.copy(),n=p.copy()}),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=[0],h=!0,i=!1,j=d3.scale.category20().range(),k,l,m,n,o=d3.scale.ordinal(),p=d3.scale.linear(),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.xDomain=function(a){return arguments.length?(k=a,r):k},r.yDomain=function(a){return arguments.length?(l=a,r):l},r.forceY=function(a){return arguments.length?(g=a,r):g},r.stacked=function(a){return arguments.length?(i=a,r):i},r.clipEdge=function(a){return arguments.length?(h=a,r):h},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.multiBarWithLegend=function(){function q(a){return a.each(function(r){var s=c()-b.left-b.right,t=d()-b.top-b.bottom,u;n.stacked()?u=r.filter(function(a){return!a.disabled}).reduce(function(a,b,c){return b.values.forEach(function(b,d){c||(a[d]={x:n.x()(b,d),y:0}),a[d].y+=n.y()(b,d)}),a},[]):u=r.filter(function(a){return!a.disabled}).map(function(a){return a.values.map(function(a,b){return{x:n.x()(a,b),y:n.y()(a,b)}})}),h.domain(d3.merge(u).map(function(a){return a.x})).rangeBands([0,s],.1),i.domain(d3.extent(d3.merge(u).map(function(a){return a.y}).concat(n.forceY))).range([t,0]),n.width(s).height(t).color(r.map(function(a,b){return a.color||e[b%20]}).filter(function(a,b){return!r[b].disabled}));var v=d3.select(this).selectAll("g.wrap.multiBarWithLegend").data([r]),w=v.enter().append("g").attr("class","wrap nvd3 multiBarWithLegend").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"),w.append("g").attr("class","controlsWrap");var z=v.select("g");g&&(b.top=l.height(),l.width(s/2),z.select(".legendWrap").datum(r).attr("transform","translate("+s/2+","+ -b.top+")").call(l)),f&&(m.width(180).color(["#444","#444","#444"]),z.select(".controlsWrap").datum(p).attr("transform","translate(0,"+ -b.top+")").call(m)),z.attr("transform","translate("+b.left+","+b.top+")");var A=z.select(".linesWrap").datum(r.filter(function(a){return!a.disabled}));d3.transition(A).call(n),j.scale(h).ticks(s/100).tickSize(-t,0),z.select(".x.axis").attr("transform","translate(0,"+i.range()[0]+")"),d3.transition(z.select(".x.axis")).call(j);var B=z.select(".x.axis").selectAll("g");B.selectAll("line, text").style("opacity",1),B.filter(function(a,b){return b%Math.ceil(r[0].values.length/(s/100))!==0}).selectAll("line, text").style("opacity",0),k.domain(i.domain()).range(i.range()).ticks(t/36).tickSize(-s,0),d3.transition(z.select(".y.axis")).call(k),l.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,r.filter(function(a){return!a.disabled}).length||r.map(function(a){return a.disabled=!1,v.selectAll(".series").classed("disabled",!1),a}),a.transition().call(q)}),m.dispatch.on("legendClick",function(b,c){if(!b.disabled)return;p=p.map(function(a){return a.disabled=!0,a}),b.disabled=!1;switch(b.key){case"Grouped":n.stacked(!1);break;case"Stacked":n.stacked(!0)}a.transition().call(q)}),n.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],o.tooltipShow(a)}),n.dispatch.on("elementMouseout.tooltip",function(a){o.tooltipHide(a)})}),q}var b={top:30,right:20,bottom:50,left:60},c=function(){return 960},d=function(){return 500},e=d3.scale.category20().range(),f=!0,g=!0,h=d3.scale.ordinal(),i=d3.scale.linear(),j=a.models.axis().scale(h).orient("bottom").highlightZero(!1),k=a.models.axis().scale(i).orient("left"),l=a.models.legend().height(30),m=a.models.legend().height(30),n=a.models.multiBar().stacked(!1),o=d3.dispatch("tooltipShow","tooltipHide"),p=[{key:"Grouped"},{key:"Stacked",disabled:!0}];return q.dispatch=o,q.legend=l,q.xAxis=j,q.yAxis=k,d3.rebind(q,n,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id","stacked"),q.margin=function(a){return arguments.length?(b=a,q):b},q.width=function(a){return arguments.length?(c=d3.functor(a),q):c},q.height=function(a){return arguments.length?(d=d3.functor(a),q):d},q.showControls=function(a){return arguments.length?(f=a,q):f},q.showLegend=function(a){return arguments.length?(g=a,q):g},q},a.models.multiBarHorizontal=function(){function u(d){return d.each(function(v){var w=b-a.left-a.right,z=c-a.top-a.bottom;r=r||e,s=s||f,l&&(v=d3.layout.stack().offset("zero").values(function(a){return a.values}).y(h)(v)),v=v.map(function(a,b){return a.values=a.values.map(function(a){return a.series=b,a}),a});var A=p&&q?[]:v.map(function(a){return a.values.map(function(a,b){return{x:g(a,b),y:h(a,b),y0:a.y0}})});e.domain(p||d3.merge(A).map(function(a){return a.x})).rangeBands([0,z],.1),f.domain(q||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]);var B=d3.select(this).selectAll("g.wrap.multibarHorizontal").data([v]),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%10]}).style("stroke",function(a,b){return k[b%10]}),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("+s(l?a.y0:0)+","+(l?0:c*e.rangeBand()/v.length+e(g(a,b)))+")"}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),t.elementMouseover({value:h(a,b),point:a,series:v[a.series],pos:[f(h(a,b)+(l?a.y0:0)),e(g(a,b))+e.rangeBand()*(l?v.length/2:a.series+.5)/v.length],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),t.elementMouseout({value:h(a,b),point:a,series:v[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){t.elementClick({value:h(a,b),point:a,series:v[a.series],pos:[e(g(a,b))+e.rangeBand()*(l?v.length/2:a.series+.5)/v.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){t.elementDblClick({value:h(a,b),point:a,series:v[a.series],pos:[e(g(a,b))+e.rangeBand()*(l?v.length/2:a.series+.5)/v.length,f(h(a,b)+(l?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()});I.append("rect").attr("width",0).attr("height",e.rangeBand()/(l?1:v.length)),m&&!l?(I.append("text").attr("text-anchor",function(a,b){return h(a,b)<0?"end":"start"}),H.selectAll("text").attr("y",e.rangeBand()/2).attr("dy","-.5em").text(function(a,b){return o(h(a,b))}),d3.transition(H).delay(function(a,b){return b*1e3/v[0].values.length}).selectAll("text").attr("dx",function(a,b){return h(a,b)<0?-4:f(h(a,b))-f(0)+4})):H.selectAll("text").remove(),H.attr("class",function(a,b){return h(a,b)<0?"bar negative":"bar positive"}),l?d3.transition(H).delay(function(a,b){return b*1e3/v[0].values.length}).attr("transform",function(a,b){return"translate("+f(a.y0)+","+(l?0:j*e.rangeBand()/v.length)+")"}).selectAll("rect").attr("width",function(a,b){return Math.abs(f(h(a,b)+a.y0)-f(a.y0))}).attr("height",e.rangeBand()):d3.transition(H).delay(function(a,b){return b*1200/v[0].values.length}).attr("transform",function(a,b){return"translate("+(h(a,b)<0?f(h(a,b)):f(0))+","+(a.series*e.rangeBand()/v.length+e(g(a,b)))+")"}).selectAll("rect").attr("height",e.rangeBand()/v.length).attr("width",function(a,b){return Math.abs(f(h(a,b))-f(0))}),u.update=function(){d.transition().call(u)},r=e.copy(),s=f.copy()}),u}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,q,r,s,t=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return u.dispatch=t,u.x=function(a){return arguments.length?(g=a,u):g},u.y=function(a){return arguments.length?(h=a,u):h},u.margin=function(b){return arguments.length?(a=b,u):a},u.width=function(a){return arguments.length?(b=a,u):b},u.height=function(a){return arguments.length?(c=a,u):c},u.xScale=function(a){return arguments.length?(e=a,u):e},u.yScale=function(a){return arguments.length?(f=a,u):f},u.xDomain=function(a){return arguments.length?(p=a,u):p},u.yDomain=function(a){return arguments.length?(q=a,u):q},u.forceY=function(a){return arguments.length?(i=a,u):i},u.stacked=function(a){return arguments.length?(l=a,u):l},u.color=function(a){return arguments.length?(k=a,u):k},u.id=function(a){return arguments.length?(d=a,u):d},u.showValues=function(a){return arguments.length?(m=a,u):m},u.valueFormat=function(a){return arguments.length?(o=a,u):o},u.valuePadding=function(a){return arguments.length?(n=a,u):n},u},a.models.multiBarHorizontalChart=function(){function s(h){return h.each(function(t){var u=d3.select(this),v=(c||parseInt(u.style("width"))||960)-b.left-b.right,w=(d||parseInt(u.style("height"))||400)-b.top-b.bottom;i.width(v).height(w).color(t.map(function(a,b){return a.color||e[b%10]}).filter(function(a,b){return!t[b].disabled}));var z=u.selectAll("g.wrap.multiBarHorizontalChart").data([t]),A=z.enter().append("g").attr("class","wrap nvd3 multiBarHorizontalChart").append("g");A.append("g").attr("class","x axis"),A.append("g").attr("class","y axis"),A.append("g").attr("class","linesWrap"),A.append("g").attr("class","legendWrap"),A.append("g").attr("class","controlsWrap"),b.top=n.height();var B=z.select("g").attr("transform","translate("+b.left+","+b.top+")");n.width(v/2),B.select(".legendWrap").datum(t).attr("transform","translate("+v/2+","+ -b.top+")").call(n),f&&(o.width(180).color(["#444","#444","#444"]),B.select(".controlsWrap").datum(r).attr("transform","translate(0,"+ -b.top+")").call(o));var C=B.select(".linesWrap").datum(t.filter(function(a){return!a.disabled}));d3.transition(C).call(i),l.scale(j).ticks(w/24).tickSize(-v,0),d3.transition(B.select(".x.axis")).call(l);var D=B.select(".x.axis").selectAll("g");D.selectAll("line, text").style("opacity",1),D.filter(function(a,b){return b%Math.ceil(t[0].values.length/(v/100))!==0}).selectAll("line, text").style("opacity",0),m.domain(k.domain()).range(k.range()).ticks(v/100).tickSize(-w,0),B.select(".y.axis").attr("transform","translate(0,"+w+")"),d3.transition(B.select(".y.axis")).call(m),n.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,t.filter(function(a){return!a.disabled}).length||t.map(function(a){return a.disabled=!1,z.selectAll(".series").classed("disabled",!1),a}),h.transition().call(s)}),o.dispatch.on("legendClick",function(a,b){if(!a.disabled)return;r=r.map(function(a){return a.disabled=!0,a}),a.disabled=!1;switch(a.key){case"Grouped":i.stacked(!1);break;case"Stacked":i.stacked(!0)}h.transition().call(s)}),i.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],p.tooltipShow(a)}),g&&p.on("tooltipShow",function(a){q(a,u[0][0])}),i.dispatch.on("elementMouseout.tooltip",function(a){p.tooltipHide(a)}),g&&p.on("tooltipHide",a.tooltip.cleanup),s.update=function(){h.transition().call(s)}}),s}var b={top:30,right:20,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!0,g=!0,h=function(a,b,c,d,e){return"

"+b+"

"+"

"+c+"

"},i=a.models.multiBarHorizontal().stacked(!1),j=i.xScale(),k=i.yScale(),l=a.models.axis().scale(j).orient("left").highlightZero(!1),m=a.models.axis().scale(k).orient("bottom"),n=a.models.legend().height(30),o=a.models.legend().height(30),p=d3.dispatch("tooltipShow","tooltipHide");l.tickFormat(function(a){return a}),m.tickFormat(d3.format(",.1f"));var q=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=l.tickFormat()(i.x()(b.point)),g=m.tickFormat()(i.y()(b.point)),j=h(b.series.key,f,g,b,s);a.tooltip.show([d,e],j,b.value<0?"e":"w")},r=[{key:"Grouped"},{key:"Stacked",disabled:!0}];return s.dispatch=p,s.multibar=i,s.legend=n,s.xAxis=l,s.yAxis=m,d3.rebind(s,i,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id","showValues","valueFormat"),s.margin=function(a){return arguments.length?(b=a,s):b},s.width=function(a){return arguments.length?(c=d3.functor(a),s):c},s.height=function(a){return arguments.length?(d=d3.functor(a),s):d},s.showControls=function(a){return arguments.length?(f=a,s):f},s.tooltips=function(a){return arguments.length?(g=a,s):g},s.tooltipContent=function(a){return arguments.length?(h=a,s):h},s},a.models.multiBarHorizontalWithLegend=function(){function p(a){return a.each(function(q){var r=c()-b.left-b.right,s=d()-b.top-b.bottom,t;m.stacked()?t=q.filter(function(a){return!a.disabled}).reduce(function(a,b,c){return b.values.forEach(function(b,d){c||(a[d]={x:m.x()(b,d),y:0}),a[d].y+=m.y()(b,d)}),a},[]):t=q.filter(function(a){return!a.disabled}).map(function(a){return a.values.map(function(a,b){return{x:m.x()(a,b),y:m.y()(a,b)}})}),g.domain(d3.merge(t).map(function(a){return a.x})).rangeBands([0,s],.1),h.domain(d3.extent(d3.merge(t).map(function(a){return a.y}).concat(m.forceY))).range([0,r]),m.width(r).height(s).color(q.map(function(a,b){return a.color||e[b%10]}).filter(function(a,b){return!q[b].disabled}));var u=d3.select(this).selectAll("g.wrap").data([q]),v=u.enter().append("g").attr("class","wrap nvd3 multiBarHorizontalWithLegend").append("g");v.append("g").attr("class","x axis"),v.append("g").attr("class","y axis"),v.append("g").attr("class","linesWrap"),v.append("g").attr("class","legendWrap"),v.append("g").attr("class","controlsWrap"),b.top=k.height();var w=u.select("g").attr("transform","translate("+b.left+","+b.top+")");k.width(r/2),w.select(".legendWrap").datum(q).attr("transform","translate("+r/2+","+ -b.top+")").call(k),f&&(l.width(180).color(["#444","#444","#444"]),w.select(".controlsWrap").datum(o).attr("transform","translate(0,"+ -b.top+")").call(l));var z=w.select(".linesWrap").datum(q.filter(function(a){return!a.disabled}));d3.transition(z).call(m),i.scale(g).ticks(s/24).tickSize(-r,0),d3.transition(w.select(".x.axis")).call(i);var A=w.select(".x.axis").selectAll("g");A.selectAll("line, text").style("opacity",1),A.filter(function(a,b){return b%Math.ceil(q[0].values.length/(r/100))!==0}).selectAll("line, text").style("opacity",0),j.domain(h.domain()).range(h.range()).ticks(r/100).tickSize(-s,0),w.select(".y.axis").attr("transform","translate(0,"+s+")"),d3.transition(w.select(".y.axis")).call(j),k.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,q.filter(function(a){return!a.disabled}).length||q.map(function(a){return a.disabled=!1,u.selectAll(".series").classed("disabled",!1),a}),a.transition().call(p)}),l.dispatch.on("legendClick",function(b,c){if(!b.disabled)return;o=o.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(p)}),m.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],n.tooltipShow(a)}),m.dispatch.on("elementMouseout.tooltip",function(a){n.tooltipHide(a)})}),p}var b={top:30,right:20,bottom:50,left:60},c=function(){return 960},d=function(){return 500},e=d3.scale.category20().range(),f=!0,g=d3.scale.ordinal(),h=d3.scale.linear(),i=a.models.axis().scale(g).orient("left").highlightZero(!1),j=a.models.axis().scale(h).orient("bottom"),k=a.models.legend().height(30),l=a.models.legend().height(30),m=a.models.multiBarHorizontal().stacked(!1),n=d3.dispatch("tooltipShow","tooltipHide"),o=[{key:"Grouped"},{key:"Stacked",disabled:!0}];return p.dispatch=n,p.legend=k,p.xAxis=i,p.yAxis=j,d3.rebind(p,m,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id"),p.margin=function(a){return arguments.length?(b=a,p):b},p.width=function(a){return arguments.length?(c=d3.functor(a),p):c},p.height=function(a){return arguments.length?(d=d3.functor(a),p):d},p.showControls=function(a){return arguments.length?(f=a,p):f},p},a.models.pie=function(){function p(m){return m.each(function(m){function y(a){var b=(a.startAngle+a.endAngle)*90/Math.PI-90;return b>90?b-180:b}function z(a){a.innerRadius=0;var b=d3.interpolate({startAngle:0,endAngle:0},a);return function(a){return t(b(a))}}var n=d3.select(this).on("click",function(a,b){o.chartClick({data:a,index:b,pos:d3.event,id:h})}),p=n.selectAll("svg.margin").data([m]),q=p.enter();q.append("text").attr("class","title").attr("dy",".91em").attr("text-anchor","start").text(l),q.append("svg").attr("class","margin").attr("x",a.left).attr("y",a.top).style("overflow","visible");var r=p.selectAll("g.wrap").data([m]);r.exit().remove();var s=r.enter();s.append("g").attr("class","wrap").attr("id","wrap-"+h).append("g").attr("class","pie"),r.attr("width",b).attr("height",c).attr("transform","translate("+e+","+e+")");var t=d3.svg.arc().outerRadius(e-e/5);k&&t.innerRadius(e/2);var u=d3.layout.pie().value(function(a){return a[g]}),v=p.select(".pie").selectAll(".slice").data(u);v.exit().remove();var w=v.enter().append("svg:g").attr("class","slice").on("mouseover",function(a,b){d3.select(this).classed("hover",!0),o.tooltipShow({label:a.data[f],value:a.data[g],data:a.data,index:b,pos:[d3.event.pageX,d3.event.pageY],id:h})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),o.tooltipHide({label:a.data[f],value:a.data[g],data:a.data,index:b,id:h})}).on("click",function(a,b){o.elementClick({label:a.data[f],value:a.data[g],data:a.data,index:b,pos:d3.event,id:h}),d3.event.stopPropagation()}).on("dblclick",function(a,b){o.elementDblClick({label:a.data[f],value:a.data[g],data:a.data,index:b,pos:d3.event,id:h}),d3.event.stopPropagation()}),x=w.append("svg:path").attr("class","path").attr("fill",function(a,b){return i(b)});v.select(".path").attr("d",t).transition().ease("bounce").duration(d).attrTween("d",z),j&&(w.append("text"),v.select("text").transition().duration(d).ease("bounce").attr("transform",function(a){return a.outerRadius=e+10,a.innerRadius=e+15,"translate("+t.centroid(a)+")"}).attr("text-anchor","middle").style("font","bold 12px Arial").text(function(a,b){return a.data[f]}))}),p}var a={top:20,right:20,bottom:20,left:20},b=500,c=500,d=2e3,e=Math.min(b-(a.right+a.left),c-(a.top+a.bottom))/2,f="label",g="y",h=Math.floor(Math.random()*1e4),i=d3.scale.category20(),j=!0,k=!1,l="",m=0,n=0,o=d3.dispatch("chartClick","elementClick","elementDblClick","tooltipShow","tooltipHide");return p.margin=function(b){return arguments.length?(a=b,p):a},p.width=function(d){return arguments.length?(a.left+a.right+20>d?b=a.left+a.right+20:b=d,e=Math.min(b-(a.left+a.right),c-(a.top+a.bottom))/2,p):b},p.height=function(d){return arguments.length?(a.top+a.bottom+20>d?c=a.top+a.bottom+20:c=d,e=Math.min(b-(a.left+a.right),c-(a.top+a.bottom))/2,p):c},p.animate=function(a){return arguments.length?(d=a,p):d},p.labelField=function(a){return arguments.length?(f=a,p):f},p.dataField=function(a){return arguments.length?(g=a,p):g},p.showLabels=function(a){return arguments.length?(j=a,p):j},p.donut=function(a){return arguments.length?(k=a,p):k},p.title=function(a){return arguments.length?(l=a,p):l},p.id=function(a){return arguments.length?(h=a,p):h},p.dispatch=o,p},a.models.scatter=function(){function A(B){return B.each(function(A){function J(){if(!o)return E.select("#points-clip-"+e).remove(),E.select(".point-paths").remove(),!1;H.append("g").attr("class","point-paths");var b=d3.merge(A.map(function(a,b){return a.values.map(function(a,c){return[f(i(a,c))*(Math.random()/1e12+1),g(j(a,c))*(Math.random()/1e12+1),b,c]})}));if(q){G.append("clipPath").attr("id","points-clip-"+e);var c=E.select("#points-clip-"+e).selectAll("circle").data(b);c.enter().append("circle").attr("r",r),c.exit().remove(),c.attr("cx",function(a){return a[0]}).attr("cy",function(a){return a[1]}),E.select(".point-paths").attr("clip-path","url(#points-clip-"+e+")")}var d=d3.geom.voronoi(b).map(function(a,c){return{data:a,series:b[c][2],point:b[c][3]}}),h=E.select(".point-paths").selectAll("path").data(d);h.enter().append("path").attr("class",function(a,b){return"path-"+b}),h.exit().remove(),h.attr("d",function(a){return"M"+a.data.join(",")+"Z"}).on("click",function(b){var c=A[b.series],d=c.values[b.point];v.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=A[b.series],d=c.values[b.point];v.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){v.elementMouseout({point:A[a.series].values[a.point],series:A[a.series],seriesIndex:a.series,pointIndex:a.point})}),v.on("elementMouseover.point",function(a){E.select(".series-"+a.seriesIndex+" .point-"+a.pointIndex).classed("hover",!0)}),v.on("elementMouseout.point",function(a){E.select(".series-"+a.seriesIndex+" circle.point-"+a.pointIndex).classed("hover",!1)})}var B=b-a.left-a.right,C=c-a.top-a.bottom;w=w||f,x=x||g,y=y||h,A=A.map(function(a,b){return a.values=a.values.map(function(a){return a.series=b,a}),a});var D=s&&t&&u?[]:A.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(s||d3.extent(d3.merge(D).map(function(a){return a.x}).concat(l))).range([0,B]),g.domain(t||d3.extent(d3.merge(D).map(function(a){return a.y}).concat(m))).range([C,0]),h.domain(u||d3.extent(d3.merge(D).map(function(a){return a.size}).concat(n))).range([2,10]);var E=d3.select(this).selectAll("g.wrap.scatter").data([A]),F=E.enter().append("g").attr("class","wrap nvd3 scatter"),G=F.append("defs"),H=F.append("g"),I=E.select("g");H.append("g").attr("class","groups"),E.attr("transform","translate("+a.left+","+a.top+")"),G.append("clipPath").attr("id","edge-clip-"+e).append("rect"),E.select("#edge-clip-"+e+" rect").attr("width",B).attr("height",C),I.attr("clip-path",p?"url(#edge-clip-"+e+")":"");var K=E.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});K.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(K.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),K.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}),d3.transition(K).style("fill",function(a,b){return d[b%20]}).style("stroke",function(a,b){return d[b%20]}).style("stroke-opacity",1).style("fill-opacity",.5);var L=K.selectAll("circle.point").data(function(a){return a.values});L.enter().append("circle").attr("cx",function(a,b){return w(i(a,b))}).attr("cy",function(a,b){return x(j(a,b))}).attr("r",function(a,b){return y(k(a,b))}),d3.transition(K.exit().selectAll("circle.point")).attr("cx",function(a,b){return f(i(a,b))}).attr("cy",function(a,b){return g(j(a,b))}).attr("r",function(a,b){return h(k(a,b))}).remove(),L.attr("class",function(a,b){return"point point-"+b}),d3.transition(L).attr("cx",function(a,b){return f(i(a,b))}).attr("cy",function(a,b){return g(j(a,b))}).attr("r",function(a,b){return h(k(a,b))}),clearTimeout(z),z=setTimeout(J,750),w=f.copy(),x=g.copy(),y=h.copy()}),A}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=d3.scale.category20().range(),e=Math.floor(Math.random()*1e5),f=d3.scale.linear(),g=d3.scale.linear(),h=d3.scale.sqrt(),i=function(a){return a.x},j=function(a){return a.y},k=function(a){return a.size},l=[],m=[],n=[],o=!0,p=!1,q=!0,r=function(){return 25},s,t,u,v=d3.dispatch("elementClick","elementMouseover","elementMouseout"),w,x,y,z;return A.dispatch=v,A.x=function(a){return arguments.length?(i=d3.functor(a),A):i},A.y=function(a){return arguments.length?(j=d3.functor(a),A):j},A.size=function(a){return arguments.length?(k=d3.functor(a),A):k},A.margin=function(b){return arguments.length?(a=b,A):a},A.width=function(a){return arguments.length?(b=a,A):b},A.height=function(a){return arguments.length?(c=a,A):c},A.xScale=function(a){return arguments.length?(f=a,A):f},A.yScale=function(a){return arguments.length?(g=a,A):g},A.zScale=function(a){return arguments.length?(h=a,A):h},A.xDomain=function(a){return arguments.length?(s=a,A):s},A.yDomain=function(a){return arguments.length?(t=a,A):t},A.sizeDomain=function(a){return arguments.length?(u=a,A):u},A.forceX=function(a){return arguments.length?(l=a,A):l},A.forceY=function(a){return arguments.length?(m=a,A):m},A.forceSize=function(a){return arguments.length?(n=a,A):n},A.interactive=function(a){return arguments.length?(o=a,A):o},A.clipEdge=function(a){return arguments.length?(p=a,A):p},A.clipVoronoi=function(a){return arguments.length?(q=a,A):q},A.clipRadius=function(a){return arguments.length?(r=a,A):r},A.color=function(a){return arguments.length?(d=a,A):d},A.id=function(a){return arguments.length?(e=a,A):e},A},a.models.scatterWithLegend=function(){function s(a){return a.each(function(e){var f=c()-b.left-b.right,t=d()-b.top-b.bottom;q=q||m.xScale(),r=r||m.yScale();var u=d3.select(this).selectAll("g.wrap.scatterWithLegend").data([e]),v=u.enter().append("g").attr("class","wrap nvd3 scatterWithLegend").append("g");v.append("g").attr("class","legendWrap"),v.append("g").attr("class","x axis"),v.append("g").attr("class","y axis"),v.append("g").attr("class","scatterWrap"),m.width(f).height(t).color(e.map(function(a,b){return a.color||i[b%20]}).filter(function(a,b){return!e[b].disabled}));var w=u.select(".scatterWrap").datum(e.filter(function(a){return!a.disabled}));d3.transition(w).call(m),o=m.xScale(),p=m.yScale(),j.scale(o),k.scale(p),b.top=l.height();var z=u.select("g").attr("transform","translate("+b.left+","+b.top+")");l.width(f/2),u.select(".legendWrap").datum(e).attr("transform","translate("+f/2+","+ -b.top+")").call(l);if(g||h){var A=w.selectAll("g.distribution").data(function(a){return a},function(a){return a.key});A.enter().append("g").attr("class",function(a,b){return"distribution series-"+b}),A.style("stroke",function(a,b){return i.filter(function(a,b){return e[b]&&!e[b].disabled})[b%10]})}if(g){var B=A.selectAll("line.distX").data(function(a){return a.values});B.enter().append("line").attr("x1",function(a,b){return q(m.x()(a,b))}).attr("x2",function(a,b){return q(m.x()(a,b))}),d3.transition(A.exit().selectAll("line.distX")).attr("x1",function(a,b){return o(m.x()(a,b))}).attr("x2",function(a,b){return o(m.x()(a,b))}).remove(),B.attr("class",function(a,b){return"distX distX-"+b}).attr("y1",p.range()[0]).attr("y2",p.range()[0]+8),d3.transition(B).attr("x1",function(a,b){return o(m.x()(a,b))}).attr("x2",function(a,b){return o(m.x()(a,b))})}if(h){var C=A.selectAll("line.distY").data(function(a){return a.values});C.enter().append("line").attr("y1",function(a,b){return r(m.y()(a,b))}).attr("y2",function(a,b){return r(m.y()(a,b))}),d3.transition(A.exit().selectAll("line.distY")).attr("y1",function(a,b){return p(m.y()(a,b))}).attr("y2",function(a,b){return p(m.y()(a,b))}).remove(),C.attr("class",function(a,b){return"distY distY-"+b}).attr("x1",o.range()[0]).attr("x2",o.range()[0]-8),d3.transition(C).attr("y1",function(a,b){return p(m.y()(a,b))}).attr("y2",function(a,b){return p(m.y()(a,b))})}j.ticks(f/100).tickSize(-t,0),z.select(".x.axis").attr("transform","translate(0,"+p.range()[0]+")"),d3.transition(z.select(".x.axis")).call(j),k.ticks(t/36).tickSize(-f,0),d3.transition(z.select(".y.axis")).call(k),l.dispatch.on("legendClick",function(b,c,d){b.disabled=!b.disabled,e.filter(function(a){return!a.disabled}).length||e.map(function(a){return a.disabled=!1,u.selectAll(".series").classed("disabled",!1),a}),a.transition().call(s)}),m.dispatch.on("elementMouseover.tooltip",function(a){n.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex}),w.select(".series-"+a.seriesIndex+" .distX-"+a.pointIndex).attr("y1",a.pos[1]),w.select(".series-"+a.seriesIndex+" .distY-"+a.pointIndex).attr("x1",a.pos[0])}),m.dispatch.on("elementMouseout.tooltip",function(a){n.tooltipHide(a),w.select(".series-"+a.seriesIndex+" .distX-"+a.pointIndex).attr("y1",p.range()[0]),w.select(".series-"+a.seriesIndex+" .distY-"+a.pointIndex).attr("x1",o.range()[0])}),q=o.copy(),r=p.copy()}),s}var b={top:30,right:20,bottom:50,left:60},c=function(){return 960},d=function(){return 500},e=!1,f=!1,g=!1,h=!1,i=d3.scale.category20().range(),j=a.models.axis().orient("bottom").tickPadding(10),k=a.models.axis().orient("left").tickPadding(10),l=a.models.legend().height(30),m=a.models.scatter(),n=d3.dispatch("tooltipShow","tooltipHide"),o,p,q,r;return s.dispatch=n,s.legend=l,s.xAxis=j,s.yAxis=k,d3.rebind(s,m,"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=d3.functor(a),s):c},s.height=function(a){return arguments.length?(d=d3.functor(a),s):d},s.color=function(a){return arguments.length?(i=a,l.color(a),s):i},s.showDistX=function(a){return arguments.length?(g=a,s):g},s.showDistY=function(a){return arguments.length?(h=a,s):h},s},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*2%20]});var p=o.selectAll("path").data(function(a){return[a]});p.enter().append("path"),p.exit().remove(),p.attr("d",d3.svg.line().x(function(a,b){return j(e(a,b))}).y(function(a,b){return k(f(a,b))}));var q=o.selectAll("circle.point").data(function(a){return a.filter(function(a,b){return k.domain().indexOf(f(a,b))!=-1||e(a,b)==j.domain()[1]})});q.enter().append("circle").attr("class","point"),q.exit().remove(),q.attr("cx",function(a,b){return j(e(a,b))}).attr("cy",function(a,b){return k(f(a,b))}).attr("r",2).style("stroke",function(a,b){return a.x==j.domain()[1]?"#444":a.y==k.domain()[0]?"#d62728":"#2ca02c"}).style("fill",function(a,b){return a.x==j.domain()[1]?"#444":a.y==k.domain()[0]?"#d62728":"#2ca02c"})}),l}var a={top:0,right:0,bottom:0,left:0},b=400,c=32,d=!0,e=function(a){return a.x},f=function(a){return a.y},g=d3.scale.category20().range(),h,i,j=d3.scale.linear(),k=d3.scale.linear();return l.margin=function(b){return arguments.length?(a=b,l):a},l.width=function(a){return arguments.length?(b=a,l):b},l.height=function(a){return arguments.length?(c=a,l):c},l.x=function(a){return arguments.length?(e=d3.functor(a),l):e},l.y=function(a){return arguments.length?(f=d3.functor(a),l):f},l.xDomain=function(a){return arguments.length?(h=a,l):h},l.yDomain=function(a){return arguments.length?(i=a,l):i},l.animate=function(a){return arguments.length?(d=a,l):d},l},a.models.sparklinePlus=function(){function o(a){return a.each(function(a){function w(){var c=d3.event.offsetX-b.left;t.attr("x1",c).attr("x2",c),u.attr("transform",function(a){return"translate("+(c-6)+","+ -b.top+")"}).text(j(Math.round(l.invert(c)))),v.attr("transform",function(a){return"translate("+(c+6)+","+ -b.top+")"}).text(k(g(a[Math.round(l.invert(c))])))}var e=c-b.left-b.right,i=d-b.top-b.bottom;l.domain(d3.extent(a,f)).range([0,e]),m.domain(d3.extent(a,g)).range([i,0]);var o=d3.select(this).selectAll("g.sparklineplus").data([a]),p=o.enter().append("g"),q=p.append("g").attr("class","nvd3 sparklineplus").attr("transform","translate("+b.left+","+b.top+")").style("stroke",function(a,b){return a.color||h[b%10]});n.xDomain(l.domain()).yDomain(m.domain()),q.call(n);var r=q.append("g").attr("class","hoverValue"),s=q.append("g").attr("class","hoverArea");r.attr("transform",function(a){return"translate("+l(a)+",0)"});var t=r.append("line").attr("x1",l.range()[1]).attr("y1",-b.top).attr("x2",l.range()[1]).attr("y2",d),u=r.append("text").attr("class","xValue").attr("text-anchor","end").attr("dy",".9em"),v=r.append("text").attr("class","yValue").attr("text-anchor","start").attr("dy",".9em");s.append("rect").attr("width",e).attr("height",i).on("mousemove",w)}),o}var b={top:15,right:40,bottom:3,left:40},c=400,d=50,e=!0,f=function(a){return a.x},g=function(a){return a.y},h=d3.scale.category20().range(),i=Math.floor(Math.random()*1e5),j=d3.format(",r"),k=d3.format(",.2f"),l=d3.scale.linear(),m=d3.scale.linear(),n=a.models.sparkline();return o.margin=function(a){return arguments.length?(b=a,o):b},o.width=function(a){return arguments.length?(c=a,n.width(a-b.left-b.right),o):c},o.height=function(a){return arguments.length?(d=a,n.height(a-b.top-b.bottom),o):d},o.x=function(a){return arguments.length?(f=d3.functor(a),n.x(a),o):f},o.y=function(a){return arguments.length?(g=d3.functor(a),n.y(a),o):g},o.id=function(a){return arguments.length?(i=a,o):i},o.animate=function(a){return arguments.length?(e=a,o):e},o},a.models.stackedArea=function(){function q(a){return a.each(function(a){var i=JSON.parse(JSON.stringify(a)),q=c-b.left-b.right,r=d-b.top-b.bottom;i=d3.layout.stack().offset(j).order(k).values(function(a){return a.values}).y(h)(i);var s=d3.select(this).selectAll("g.wrap.stackedarea").data([i]),t=s.enter().append("g").attr("class","wrap nvd3 stackedarea"),u=t.append("defs"),v=t.append("g"),w=s.select("g");v.append("g").attr("class","areaWrap"),m.width(q).height(r).y(function(a){return a.y+a.y0}).forceY([0]).color(i.map(function(a,b){return a.color||e[b%20]}).filter(function(a,b){return!i[b].disabled})),v.append("g").attr("class","scatterWrap");var z=w.select(".scatterWrap").datum(i.filter(function(a){return!a.disabled}));d3.transition(z).call(m),s.attr("transform","translate("+b.left+","+b.top+")"),u.append("clipPath").attr("id","edge-clip-"+f).append("rect"),s.select("#edge-clip-"+f+" rect").attr("width",q).attr("height",r),w.attr("clip-path",l?"url(#edge-clip-"+f+")":"");var A=d3.svg.area().x(function(a,b){return n(g(a,b))}).y0(function(a){return o(a.y0)}).y1(function(a){return o(a.y+a.y0)}),B=d3.svg.area().x(function(a,b){return n(g(a,b))}).y0(function(a){return o(a.y0)}).y1(function(a){return o(a.y0)}),C=w.select(".areaWrap").selectAll("path.area").data(function(a){return a},function(a){return a.key});C.enter().append("path").attr("class",function(a,b){return"area area-"+b}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),p.areaMouseover({point:a,series:a.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:b})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),p.areaMouseout({point:a,series:a.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:b})}).on("click",function(a,b){d3.select(this).classed("hover",!1),p.areaClick({point:a,series:a.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:b})}),d3.transition(C.exit()).attr("d",function(a,b){return B(a.values,b)}).remove(),C.style("fill",function(a,b){return e[b%20]}).style("stroke",function(a,b){return e[b%20]}),d3.transition(C).attr("d",function(a,b){return A(a.values,b)}),m.dispatch.on("elementClick.area",function(a){p.areaClick(a)}),m.dispatch.on("elementMouseover.area",function(a){w.select(".area-"+a.seriesIndex).classed("hover",!0)}),m.dispatch.on("elementMouseout.area",function(a){w.select(".area-"+a.seriesIndex).classed("hover",!1)})}),q}var b={top:0,right:0,bottom:0,left:0},c=960,d=500,e=d3.scale.category20().range(),f=Math.floor(Math.random()*1e5),g=function(a){return a.x},h=function(a){return a.y},i="stack",j="zero",k="default",l=!1,m=a.models.scatter().size(2.2).sizeDomain([2.5]),n=m.xScale(),o=m.yScale(),p=d3.dispatch("tooltipShow","tooltipHide","areaClick","areaMouseover","areaMouseout");return q.dispatch=p,q.scatter=m,d3.rebind(q,m,"interactive","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius"),q.x=function(a){return arguments.length?(g=d3.functor(a),m.x(a),q):g},q.y=function(a){return arguments.length?(h=d3.functor(a),q):h},q.margin=function(a){return arguments.length?(b=a,q):b},q.width=function(a){return arguments.length?(c=a,q):c},q.height=function(a){return arguments.length?(d=a,q):d},q.clipEdge=function(a){return arguments.length?(l=a,q):l},q.color=function(a){return arguments.length?(e=a,q):e},q.offset=function(a){return arguments.length?(j=a,q):j},q.order=function(a){return arguments.length?(k=a,q):k},q.style=function(a){if(!arguments.length)return i;i=a;switch(i){case"stack":j="zero",k="default";break;case"stream":j="wiggle",k="inside-out";break;case"expand":j="expand",k="default"}return q},m.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],p.tooltipShow(a)}),m.dispatch.on("elementMouseout.tooltip",function(a){p.tooltipHide(a)}),q},a.models.stackedAreaWithLegend=function(){function s(a){return a.each(function(t){var u=c(),v=d(),w=u-b.left-b.right,z=v-b.top-b.bottom,A=t.filter(function(a){return!a.disabled}).reduce(function(a,b,c){return b.values.forEach(function(b,d){c||(a[d]={x:j(b,d),y:0}),a[d].y+=k(b,d)}),a},[]);h.domain(d3.extent(d3.merge(A),function(a){return a.x})).range([0,w]),i.domain(p.offset()=="zero"?[0,d3.max(A,function(a){return a.y})]:[0,1]).range([z,0]),p.width(w).height(z).color(t.map(function(a,b){return a.color||e[b%20]}).filter(function(a,b){return!t[b].disabled}));var B=d3.select(this).selectAll("g.wrap.stackedAreaWithLegend").data([t]),C=B.enter().append("g").attr("class","wrap nvd3 stackedAreaWithLegend").append("g");C.append("g").attr("class","x axis"),C.append("g").attr("class","y axis"),C.append("g").attr("class","stackedWrap"),C.append("g").attr("class","legendWrap"),C.append("g").attr("class","controlsWrap");var D=B.select("g");g&&(b.top=n.height(),n.width(u/2-b.right).color(e),D.select(".legendWrap").datum(t).attr("transform","translate("+(u/2-b.left)+","+ -b.top+")").call(n)),f&&(o.width(280).color(["#444","#444","#444"]),D.select(".controlsWrap").datum(r).attr("transform","translate(0,"+ -b.top+")").call(o)),D.attr("transform","translate("+b.left+","+b.top+")");var E=D.select(".stackedWrap").datum(t);d3.transition(E).call(p),l.domain(h.domain()).range(h.range()).ticks(u/100).tickSize(-z,0),D.select(".x.axis").attr("transform","translate(0,"+z+")"),d3.transition(D.select(".x.axis")).call(l),m.domain(i.domain()).range(i.range()).ticks(p.offset()=="wiggle"?0:v/36).tickSize(-w,0).tickFormat(p.offset()=="zero"?d3.format(",.2f"):d3.format("%")),d3.transition(D.select(".y.axis")).call(m),p.dispatch.on("areaClick.toggle",function(b){t.filter(function(a){return!a.disabled}).length===1?t=t.map(function(a){return a.disabled&&a.values.map(function(a){return a.y=a._y||a.y,a}),a.disabled=!1,a}):t=t.map(function(a,c){return!a.disabled&&c!==b.seriesIndex&&a.values.map(function(a){return a._y=a.y,a.y=0,a}),a.disabled&&c===b.seriesIndex&&a.values.map(function(a){return a.y=a._y||a.y,a}),a.disabled=c!=b.seriesIndex,a}),a.transition().call(s)}),n.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,b.disabled?b.values.map(function(a){return a._y=a.y,a.y=0,a}):b.values.map(function(a){return a.y=a._y,a}),t.filter(function(a){return!a.disabled}).length||t.map(function(a){return a.disabled=!1,a.values.map(function(a){return a.y=a._y,a}),a}),a.transition().call(s)}),o.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":p.style("stack");break;case"Stream":p.style("stream");break;case"Expanded":p.style("expand")}a.transition().call(s)}),p.dispatch.on("tooltipShow",function(a){if(!Math.round(k(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)}),p.dispatch.on("tooltipHide",function(a){q.tooltipHide(a)})}),s}var b={top:30,right:20,bottom:50,left:60},c=function(){return 960},d=function(){return 500},e=d3.scale.category20().range(),f=!0,g=!0,h=d3.scale.linear(),i=d3.scale.linear(),j=function(a){return a.x},k=function(a){return a.y},l=a.models.axis().scale(h).orient("bottom"),m=a.models.axis().scale(i).orient("left"),n=a.models.legend().height(30),o=a.models.legend().height(30),p=a.models.stackedArea(),q=d3.dispatch("tooltipShow","tooltipHide"),r=[{key:"Stacked"},{key:"Stream",disabled:!0},{key:"Expanded",disabled:!0}];return s.dispatch=q,s.stacked=p,s.xAxis=l,s.yAxis=m,d3.rebind(s,p,"interactive","offset","order","style","clipEdge","size","forceX","forceY","forceSize"),s.x=function(a){return arguments.length?(j=d3.functor(a),p.x(j),s):j},s.y=function(a){return arguments.length?(k=d3.functor(a),p.y(k),s):k},s.margin=function(a){return arguments.length?(b=a,s):b},s.width=function(a){return arguments.length?(c=d3.functor(a),s):c},s.height=function(a){return arguments.length?(d=d3.functor(a),s):d},s.showControls=function(a){return arguments.length?(f=a,s):f},s.showLegend=function(a){return arguments.length?(g=a,s):g},s},a.charts.cumulativeLineChartDaily=function(){function h(){return!b||!c.length?h:(d3.select(b).select("svg").datum(c).transition().duration(d).call(f),h)}var b=null,c=[],d=500,e=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" at "+b+"

"},f=a.models.cumulativeLine().x(function(a,b){return b}).color(d3.scale.category10().range()),g=function(c){var d=document.getElementById(b.substr(1)),g=c.pos[0]+d.offsetLeft,h=c.pos[1]+d.offsetTop,i=f.xAxis.tickFormat(),j=f.yAxis.tickFormat(),k=i(f.x()(c,c.pointIndex)),l=j(f.y()(c.point)),m=e(c.series.key,k,l,c,f);a.tooltip.show([g,h],m)};return f.xAxis.tickFormat(function(a){return d3.time.format("%x")(new Date(c[0].values[a].x))}),f.yAxis.tickFormat(d3.format(",.2%")),h.build=function(){return!b||!c.length?h:(a.addGraph({generate:function(){var a=d3.select(b),e=function(){return parseInt(a.style("width"))},g=function(){return parseInt(a.style("height"))},h=a.append("svg");return f.width(e).height(g),h.attr("width",e()).attr("height",g()).datum(c).transition().duration(d).call(f),f},callback:function(c){c.dispatch.on("tooltipShow",g),c.dispatch.on("tooltipHide",a.tooltip.cleanup),window.onresize=function(){d3.select(b+" svg").attr("width",c.width()()).attr("height",c.height()()).call(c)}}}),h)},h.data=function(a){return arguments.length?(c=a,h):c},h.selector=function(a){return arguments.length?(b=a,h):b},h.duration=function(a){return arguments.length?(d=a,h):d},h.tooltip=function(a){return arguments.length?(e=a,h):e},h.xTickFormat=function(a){return arguments.length?(f.xAxis.tickFormat(typeof a=="function"?a:d3.format(a)),h):f.xAxis.tickFormat()},h.yTickFormat=function(a){return arguments.length?(f.yAxis.tickFormat(typeof a=="function"?a:d3.format(a)),h):f.yAxis.tickFormat()},h.xAxisLabel=function(a){return arguments.length?(f.xAxis.axisLabel(a),h):f.xAxis.axisLabel()},h.yAxisLabel=function(a){return arguments.length?(f.yAxis.axisLabel(a),h):f.yAxis.axisLabel()},d3.rebind(h,f,"x","y"),h.graph=f,h},a.charts.line=function(){function h(){return!b||!c.length?h:(d3.select(b).select("svg").datum(c).transition().duration(d).call(f),h)}var b=null,c=[],d=500,e=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" at "+b+"

"},f=a.models.lineWithLegend(),g=function(c){var d=document.getElementById(b.substr(1)),g=c.pos[0]+d.offsetLeft,h=c.pos[1]+d.offsetTop,i=f.xAxis.tickFormat(),j=f.yAxis.tickFormat(),k=i(f.x()(c.point)),l=j(f.y()(c.point)),m=e(c.series.key,k,l,c,f);a.tooltip.show([g,h],m)};return f.xAxis.tickFormat(d3.format(",r")),f.yAxis.tickFormat(d3.format(",.2f")),h.build=function(){return!b||!c.length?h:(a.addGraph({generate:function(){var a=d3.select(b),e=function(){return parseInt(a.style("width"))},g=function(){return parseInt(a.style("height"))},h=a.append("svg");return f.width(e).height(g),h.attr("width",e()).attr("height",g()).datum(c).transition().duration(d).call(f),f},callback:function(c){c.dispatch.on("tooltipShow",g),c.dispatch.on("tooltipHide",a.tooltip.cleanup),window.onresize=function(){d3.select(b+" svg").attr("width",c.width()()).attr("height",c.height()()).call(c)}}}),h)},h.data=function(a){return arguments.length?(c=a,h):c},h.selector=function(a){return arguments.length?(b=a,h):b},h.duration=function(a){return arguments.length?(d=a,h):d},h.tooltip=function(a){return arguments.length?(e=a,h):e},h.xTickFormat=function(a){return arguments.length?(f.xAxis.tickFormat(typeof a=="function"?a:d3.format(a)),h):f.xAxis.tickFormat()},h.yTickFormat=function(a){return arguments.length?(f.yAxis.tickFormat(typeof a=="function"?a:d3.format(a)),h):f.yAxis.tickFormat()},h.xAxisLabel=function(a){return arguments.length?(f.xAxis.axisLabel(a),h):f.xAxis.axisLabel()},h.yAxisLabel=function(a){return arguments.length?(f.yAxis.axisLabel(a),h):f.yAxis.axisLabel()},d3.rebind(h,f,"x","y"),h.graph=f,h},a.charts.lineChartDaily=function(){function h(){return!b||!c.length?h:(d3.select(b).select("svg").datum(c).transition().duration(d).call(f),h)}var b=null,c=[],d=500,e=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" at "+b+"

"},f=a.models.lineWithLegend().x(function(a,b){return b}),g=function(c){var d=document.getElementById(b.substr(1)),g=c.pos[0]+d.offsetLeft,h=c.pos[1]+d.offsetTop,i=f.xAxis.tickFormat(),j=f.yAxis.tickFormat(),k=i(f.x()(c,c.pointIndex)),l=j(f.y()(c.point)),m=e(c.series.key,k,l,c,f);a.tooltip.show([g,h],m)};return f.xAxis.tickFormat(function(a){return d3.time.format("%x")(new Date(c[0].values[a].x))}),f.yAxis.tickFormat(d3.format(",.2%")),h.build=function(){return!b||!c.length?h:(a.addGraph({generate:function(){var a=d3.select(b),e=function(){return parseInt(a.style("width"))},g=function(){return parseInt(a.style("height"))},h=a.append("svg");return f.width(e).height(g),h.attr("width",e()).attr("height",g()).datum(c).transition().duration(d).call(f),f},callback:function(c){c.dispatch.on("tooltipShow",g),c.dispatch.on("tooltipHide",a.tooltip.cleanup),window.onresize=function(){d3.select(b+" svg").attr("width",c.width()()).attr("height",c.height()()).call(c)}}}),h)},h.data=function(a){return arguments.length?(c=a,h):c},h.selector=function(a){return arguments.length?(b=a,h):b},h.duration=function(a){return arguments.length?(d=a,h):d},h.tooltip=function(a){return arguments.length?(e=a,h):e},h.xTickFormat=function(a){return arguments.length?(f.xAxis.tickFormat(typeof a=="function"?a:d3.format(a)),h):f.xAxis.tickFormat()},h.yTickFormat=function(a){return arguments.length?(f.yAxis.tickFormat(typeof a=="function"?a:d3.format(a)),h):f.yAxis.tickFormat()},h.xAxisLabel=function(a){return arguments.length?(f.xAxis.axisLabel(a),h):f.xAxis.axisLabel()},h.yAxisLabel=function(a){return arguments.length?(f.yAxis.axisLabel(a),h):f.yAxis.axisLabel()},d3.rebind(h,f,"x","y"),h.graph=f,h},a.charts.stackedAreaChart=function(){function h(){return!b||!c.length?h:(d3.select(b).select("svg").datum(c).transition().duration(d).call(f),h)}var b=null,c=[],d=500,e=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" at "+b+"

"},f=a.models.stackedAreaWithLegend().x(function(a,b){return b}),g=function(c){var d=document.getElementById(b.substr(1)),g=c.pos[0]+d.offsetLeft,h=c.pos[1]+d.offsetTop,i=f.xAxis.tickFormat(),j=f.yAxis.tickFormat(),k=i(f.x()(c,c.pointIndex)),l=j(f.y()(c.point)),m=e(c.series.key,k,l,c,f);a.tooltip.show([g,h],m)};return f.xAxis.tickFormat(function(a){return d3.time.format("%x")(new Date(c[0].values[a].x))}),f.yAxis.tickFormat(d3.format(",.2%")),h.build=function(){return!b||!c.length?h:(a.addGraph({generate:function(){var a=d3.select(b),e=function(){return parseInt(a.style("width"))},g=function(){return parseInt(a.style("height"))},h=a.append("svg");return f.width(e).height(g),h.attr("width",e()).attr("height",g()).datum(c).transition().duration(d).call(f),f},callback:function(c){c.dispatch.on("tooltipShow",g),c.dispatch +.on("tooltipHide",a.tooltip.cleanup),window.onresize=function(){d3.select(b+" svg").attr("width",c.width()()).attr("height",c.height()()).call(c)}}}),h)},h.data=function(a){return arguments.length?(c=a,h):c},h.selector=function(a){return arguments.length?(b=a,h):b},h.duration=function(a){return arguments.length?(d=a,h):d},h.tooltip=function(a){return arguments.length?(e=a,h):e},h.xTickFormat=function(a){return arguments.length?(f.xAxis.tickFormat(typeof a=="function"?a:d3.format(a)),h):f.xAxis.tickFormat()},h.yTickFormat=function(a){return arguments.length?(f.yAxis.tickFormat(typeof a=="function"?a:d3.format(a)),h):f.yAxis.tickFormat()},h.xAxisLabel=function(a){return arguments.length?(f.xAxis.axisLabel(a),h):f.xAxis.axisLabel()},h.yAxisLabel=function(a){return arguments.length?(f.yAxis.axisLabel(a),h):f.yAxis.axisLabel()},d3.rebind(h,f,"x","y"),h.graph=f,h}})(); \ No newline at end of file diff --git a/src/d3.css b/src/d3.css index 8b0bb8f..340f22c 100644 --- a/src/d3.css +++ b/src/d3.css @@ -333,12 +333,12 @@ svg .title { -.nvd3 .stackedarea .groups .point { +.nvd3.stackedarea .groups .point { stroke-opacity: 0; fill-opacity: 0; } -.nvd3 .stackedarea .groups .point.hover { +.nvd3.stackedarea .groups .point.hover { stroke-width: 20px; stroke-opacity: .75; fill-opacity: 1; diff --git a/src/models/lineChart.js b/src/models/lineChart.js index 2ad5423..bd1dcdf 100644 --- a/src/models/lineChart.js +++ b/src/models/lineChart.js @@ -4,6 +4,7 @@ nv.models.lineChart = function() { color = d3.scale.category20().range(), width = null, height = null, + showLegend = true, tooltip = function(key, x, y, e, graph) { return '

' + key + '

' + '

' + y + ' at ' + x + '

' @@ -61,24 +62,29 @@ nv.models.lineChart = function() { gEnter.append('g').attr('class', 'legendWrap'); + var g = wrap.select('g'); - //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend - margin.top = legend.height(); - var g = wrap.select('g') - .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + if (showLegend) { + //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend + margin.top = legend.height(); - legend.width(availableWidth / 2); + legend.width(availableWidth); + //legend.width(availableWidth / 2); - g.select('.legendWrap') - .datum(data) - .attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')') - .call(legend); + g.select('.legendWrap') + .datum(data) + .attr('transform', 'translate(0,' + (-margin.top) +')') + .call(legend); + } + g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + var linesWrap = g.select('.linesWrap') .datum(data.filter(function(d) { return !d.disabled })) @@ -192,6 +198,12 @@ nv.models.lineChart = function() { return chart; }; + chart.showLegend = function(_) { + if (!arguments.length) return showLegend; + showLegend = _; + return chart; + }; + return chart; } diff --git a/src/models/stackedArea.js b/src/models/stackedArea.js index 604d00c..c34f4f3 100644 --- a/src/models/stackedArea.js +++ b/src/models/stackedArea.js @@ -108,7 +108,8 @@ nv.models.stackedArea = function() { var path = g.select('.areaWrap').selectAll('path.area') - .data(function(d) { return d }); + //.data(function(d) { return d }); + .data(function(d) { return d }, function(d) { return d.key }); path.enter().append('path').attr('class', function(d,i) { return 'area area-' + i }) .on('mouseover', function(d,i) { d3.select(this).classed('hover', true); diff --git a/src/models/stackedAreaWithLegend.js b/src/models/stackedAreaWithLegend.js index 3ac8fd8..a7b9813 100644 --- a/src/models/stackedAreaWithLegend.js +++ b/src/models/stackedAreaWithLegend.js @@ -3,7 +3,9 @@ nv.models.stackedAreaWithLegend = function() { var margin = {top: 30, right: 20, bottom: 50, left: 60}, getWidth = function() { return 960 }, getHeight = function() { return 500 }, - color = d3.scale.category20().range(); + color = d3.scale.category20().range(), + showControls = true, + showLegend = true; var x = d3.scale.linear(), y = d3.scale.linear(), @@ -53,7 +55,10 @@ nv.models.stackedAreaWithLegend = function() { stacked .width(availableWidth) .height(availableHeight) - .color(color) + //.color(color) + .color(data.map(function(d,i) { + return d.color || color[i % 20]; + }).filter(function(d,i) { return !data[i].disabled })) var wrap = d3.select(this).selectAll('g.wrap.stackedAreaWithLegend').data([data]); @@ -66,28 +71,34 @@ nv.models.stackedAreaWithLegend = function() { gEnter.append('g').attr('class', 'controlsWrap'); + var g = wrap.select('g'); - //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend - margin.top = legend.height(); - var g = wrap.select('g') - .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + if (showLegend) { + //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend + margin.top = legend.height(); + legend + .width(width/2 - margin.right) + .color(color); - legend - .width(width/2 - margin.right) - .color(color); + g.select('.legendWrap') + .datum(data) + .attr('transform', 'translate(' + (width/2 - margin.left) + ',' + (-margin.top) +')') + .call(legend); + } - g.select('.legendWrap') - .datum(data) - .attr('transform', 'translate(' + (width/2 - margin.left) + ',' + (-margin.top) +')') - .call(legend); - controls.width(280).color(['#444', '#444', '#444']); - g.select('.controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); + if (showControls) { + controls.width(280).color(['#444', '#444', '#444']); + g.select('.controlsWrap') + .datum(controlsData) + .attr('transform', 'translate(0,' + (-margin.top) +')') + .call(controls); + } + + + g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); var stackedWrap = g.select('.stackedWrap') @@ -229,9 +240,13 @@ nv.models.stackedAreaWithLegend = function() { return chart; } + chart.dispatch = dispatch; + chart.stacked = stacked; + chart.xAxis = xAxis; + chart.yAxis = yAxis; - d3.rebind(chart, stacked, 'interactive', 'clipEdge', 'size'); + d3.rebind(chart, stacked, 'interactive', 'offset', 'order', 'style', 'clipEdge', 'size', 'forceX', 'forceY', 'forceSize'); chart.x = function(_) { if (!arguments.length) return getX; @@ -265,9 +280,18 @@ nv.models.stackedAreaWithLegend = function() { return chart; }; - chart.stacked = stacked; - chart.xAxis = xAxis; - chart.yAxis = yAxis; + chart.showControls = function(_) { + if (!arguments.length) return showControls; + showControls = _; + return chart; + }; + + chart.showLegend = function(_) { + if (!arguments.length) return showLegend; + showLegend = _; + return chart; + }; + return chart; }