From a10eac2af650ee61532c79c235e22fae4ec5df1c Mon Sep 17 00:00:00 2001 From: Tsyren Ochirov Date: Thu, 28 Jun 2012 10:31:06 +0400 Subject: [PATCH 1/4] days in month refactor --- src/core.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/core.js b/src/core.js index 9128530..5da380c 100644 --- a/src/core.js +++ b/src/core.js @@ -78,20 +78,10 @@ nv.strip = function(s) { return s.replace(/(\s|&)/g,''); } - -/* An ugly implementation to get month end axis dates - * Will hopefully refactor sooner than later - */ - function daysInMonth(month,year) { - var m = [31,28,31,30,31,30,31,31,30,31,30,31]; - if (month != 2) return m[month - 1]; - if (year%4 != 0) return m[1]; - if (year%100 == 0 && year%400 != 0) return m[1]; - return m[1] + 1; + return (new Date(year, month+1, 0)).getMonth(); } - function d3_time_range(floor, step, number) { return function(t0, t1, dt) { var time = floor(t0), times = []; From 1ea04ec428b54815f7987e38520213c41c0eea5b Mon Sep 17 00:00:00 2001 From: Tsyren Ochirov Date: Thu, 28 Jun 2012 10:35:02 +0400 Subject: [PATCH 2/4] fix: get Date instead of get Month --- src/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.js b/src/core.js index 5da380c..b2441c7 100644 --- a/src/core.js +++ b/src/core.js @@ -79,7 +79,7 @@ nv.strip = function(s) { } function daysInMonth(month,year) { - return (new Date(year, month+1, 0)).getMonth(); + return (new Date(year, month+1, 0)).getDate(); } function d3_time_range(floor, step, number) { From d06d04ebed8746aa2eddccc41cbca9b6aebfb137 Mon Sep 17 00:00:00 2001 From: Tsyren Ochirov Date: Thu, 28 Jun 2012 11:00:35 +0400 Subject: [PATCH 3/4] define optional parametr parentID for tooltip element --- src/core.js | 16 ++++------------ src/tooltip.js | 6 ++++-- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/core.js b/src/core.js index b2441c7..15e91cd 100644 --- a/src/core.js +++ b/src/core.js @@ -60,7 +60,6 @@ nv.render = function render(step) { }; nv.render.queue = []; - nv.addGraph = function(obj) { if (typeof arguments[0] === 'function') obj = {generate: arguments[0], callback: arguments[1]}; @@ -70,17 +69,13 @@ nv.addGraph = function(obj) { if (!nv.render.active) nv.render(); }; - nv.identity = function(d) { return d }; - -nv.strip = function(s) { - return s.replace(/(\s|&)/g,''); -} +nv.strip = function(s) { return s.replace(/(\s|&)/g,''); }; function daysInMonth(month,year) { return (new Date(year, month+1, 0)).getDate(); -} +}; function d3_time_range(floor, step, number) { return function(t0, t1, dt) { @@ -97,19 +92,16 @@ function d3_time_range(floor, step, number) { } return times; }; -} - +}; d3.time.monthEnd = function(date) { return new Date(date.getFullYear(), date.getMonth(), 0); }; - d3.time.monthEnds = d3_time_range(d3.time.monthEnd, function(date) { date.setUTCDate(date.getUTCDate() + 1); date.setDate(daysInMonth(date.getMonth() + 1, date.getFullYear())); }, function(date) { return date.getMonth(); } -); - +); \ No newline at end of file diff --git a/src/tooltip.js b/src/tooltip.js index 9da0062..953624d 100644 --- a/src/tooltip.js +++ b/src/tooltip.js @@ -8,7 +8,9 @@ var nvtooltip = window.nv.tooltip = {}; - nvtooltip.show = function(pos, content, gravity, dist) { + nvtooltip.show = function() { + var args = arguments; + var pos = args[0], content = args[1], gravity = args[2], dist = args[3], parentId = args[4]; var container = document.createElement("div"); container.className = "nvtooltip"; @@ -16,7 +18,7 @@ gravity = gravity || 's'; dist = dist || 20; - var body = document.getElementsByTagName("body")[0]; + var body = parentId ? document.getElementById(parentId) : document.getElementsByTagName("body")[0]; container.innerHTML = content; container.style.left = 1; From eb8f9f48fb64212c2af04775811388cc149ed865 Mon Sep 17 00:00:00 2001 From: Tsyren Ochirov Date: Thu, 28 Jun 2012 11:42:26 +0400 Subject: [PATCH 4/4] tooltip optional base container --- .../discreteBarChartWithEnabledTooltip.html | 129 ++++++++++ nv.d3.js | 71 +++--- nv.d3.min.js | 7 +- .../discreteBarChartWithEnabledTooltip.js | 222 ++++++++++++++++++ src/models/multiBarChart.js | 2 +- src/tooltip.js | 6 +- 6 files changed, 389 insertions(+), 48 deletions(-) create mode 100644 examples/discreteBarChartWithEnabledTooltip.html create mode 100644 src/models/discreteBarChartWithEnabledTooltip.js diff --git a/examples/discreteBarChartWithEnabledTooltip.html b/examples/discreteBarChartWithEnabledTooltip.html new file mode 100644 index 0000000..f23732c --- /dev/null +++ b/examples/discreteBarChartWithEnabledTooltip.html @@ -0,0 +1,129 @@ + + + + + + + +
+ +
+ +
+ +
+ + + + + + + + + + \ No newline at end of file diff --git a/nv.d3.js b/nv.d3.js index b63ff9f..5337b84 100644 --- a/nv.d3.js +++ b/nv.d3.js @@ -61,7 +61,6 @@ nv.render = function render(step) { }; nv.render.queue = []; - nv.addGraph = function(obj) { if (typeof arguments[0] === 'function') obj = {generate: arguments[0], callback: arguments[1]}; @@ -71,27 +70,13 @@ nv.addGraph = function(obj) { if (!nv.render.active) nv.render(); }; - nv.identity = function(d) { return d }; - -nv.strip = function(s) { - return s.replace(/(\s|&)/g,''); -} - - -/* An ugly implementation to get month end axis dates - * Will hopefully refactor sooner than later - */ +nv.strip = function(s) { return s.replace(/(\s|&)/g,''); }; function daysInMonth(month,year) { - var m = [31,28,31,30,31,30,31,31,30,31,30,31]; - if (month != 2) return m[month - 1]; - if (year%4 != 0) return m[1]; - if (year%100 == 0 && year%400 != 0) return m[1]; - return m[1] + 1; -} - + return (new Date(year, month+1, 0)).getDate(); +}; function d3_time_range(floor, step, number) { return function(t0, t1, dt) { @@ -108,14 +93,12 @@ function d3_time_range(floor, step, number) { } return times; }; -} - +}; d3.time.monthEnd = function(date) { return new Date(date.getFullYear(), date.getMonth(), 0); }; - d3.time.monthEnds = d3_time_range(d3.time.monthEnd, function(date) { date.setUTCDate(date.getUTCDate() + 1); date.setDate(daysInMonth(date.getMonth() + 1, date.getFullYear())); @@ -123,8 +106,6 @@ d3.time.monthEnds = d3_time_range(d3.time.monthEnd, function(date) { return date.getMonth(); } ); - - /***** * A no frills tooltip implementation. *****/ @@ -134,7 +115,9 @@ d3.time.monthEnds = d3_time_range(d3.time.monthEnd, function(date) { var nvtooltip = window.nv.tooltip = {}; - nvtooltip.show = function(pos, content, gravity, dist) { + nvtooltip.show = function() { + var args = Array.prototype.slice.call(arguments), + pos = args[0], content = args[1], gravity = args[2], dist = args[3], parentId = args[4]; var container = document.createElement("div"); container.className = "nvtooltip"; @@ -142,7 +125,7 @@ d3.time.monthEnds = d3_time_range(d3.time.monthEnd, function(date) { gravity = gravity || 's'; dist = dist || 20; - var body = document.getElementsByTagName("body")[0]; + var body = parentId ? parentId : document.getElementsByTagName("body")[0]; container.innerHTML = content; container.style.left = 1; @@ -2515,10 +2498,7 @@ nv.models.line = function() { .id(id) .size(16) // default size .sizeDomain([16,256]), //set to speed up calculation, needs to be unset if there is a cstom size accessor - x = scatter.xScale(), - y = scatter.yScale(), - x0 = x, - y0 = y, + x, y, x0, y0, timeoutID; @@ -2527,6 +2507,13 @@ nv.models.line = function() { var availableWidth = width - margin.left - margin.right, availableHeight = height - margin.top - margin.bottom; + //scales need to be set here incase a custom scale was set + x = x || scatter.xScale(); + y = y || scatter.yScale(); + + x0 = x0 || x; + y0 = y0 || y; + var wrap = d3.select(this).selectAll('g.wrap.line').data([data]); var wrapEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 line'); @@ -2534,10 +2521,20 @@ nv.models.line = function() { var gEnter = wrapEnter.append('g'); var g = wrap.select('g') - wrapEnter.append('g').attr('class', 'scatterWrap'); - var scatterWrap = wrap.select('.scatterWrap').datum(data); - gEnter.append('g').attr('class', 'groups'); + gEnter.append('g').attr('class', 'scatterWrap'); + + + defsEnter.append('clipPath') + .attr('id', 'edge-clip-' + id) + .append('rect'); + + wrap.select('#edge-clip-' + id + ' rect') + .attr('width', availableWidth) + .attr('height', availableHeight); + + + var scatterWrap = wrap.select('.scatterWrap')//.datum(data); scatter @@ -2547,16 +2544,10 @@ nv.models.line = function() { d3.transition(scatterWrap).call(scatter); - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - defsEnter.append('clipPath') - .attr('id', 'edge-clip-' + id) - .append('rect'); - wrap.select('#edge-clip-' + id + ' rect') - .attr('width', availableWidth) - .attr('height', availableHeight); g .attr('clip-path', clipEdge ? 'url(#edge-clip-' + id + ')' : ''); scatterWrap @@ -4175,7 +4166,7 @@ nv.models.multiBarChart = function() { y = yAxis.tickFormat()(multibar.y()(e.point)), content = tooltip(e.series.key, x, y, e, chart); - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's'); + nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); }; //TODO: let user select default diff --git a/nv.d3.min.js b/nv.d3.min.js index e5bbf6f..71180db 100644 --- a/nv.d3.min.js +++ b/nv.d3.min.js @@ -1,4 +1,3 @@ -(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 g(h){h.each(function(g){var h=d3.select(this),i=h.selectAll("g.wrap.axis").data([g]),j=i.enter().append("g").attr("class","wrap axis"),k=j.append("g"),l=i.select("g");(e.orient()=="top"||e.orient()=="bottom")&&e.ticks(Math.abs(a.range()[1]-a.range()[0])/100),d3.transition(l).call(e),f=f||e.scale();var m=l.selectAll("text.axislabel").data([b||null]);m.exit().remove();switch(e.orient()){case"top":m.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",0),m.attr("x",a.range()[1]/2);if(c){var n=i.selectAll("g.axisMaxMin").data(a.domain());n.enter().append("g").attr("class","axisMaxMin").append("text"),n.exit().remove(),n.attr("transform",function(b,c){return"translate("+a(b)+",0)"}).select("text").attr("dy","0em").attr("y",-e.tickPadding()).attr("text-anchor","middle").text(function(a,b){return e.tickFormat()(a)}),d3.transition(n).attr("transform",function(b,c){return"translate("+a.range()[c]+",0)"})}break;case"bottom":m.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",25),m.attr("x",a.range()[1]/2);if(c){var n=i.selectAll("g.axisMaxMin").data(a.domain());n.enter().append("g").attr("class","axisMaxMin").append("text"),n.exit().remove(),n.attr("transform",function(b,c){return"translate("+a(b)+",0)"}).select("text").attr("dy",".71em").attr("y",e.tickPadding()).attr("text-anchor","middle").text(function(a,b){return e.tickFormat()(a)}),d3.transition(n).attr("transform",function(b,c){return"translate("+a.range()[c]+",0)"})}break;case"right":m.enter().append("text").attr("class","axislabel").attr("transform","rotate(90)").attr("y",-40),m.attr("x",-a.range()[0]/2);if(c){var n=i.selectAll("g.axisMaxMin").data(a.domain());n.enter().append("g").attr("class","axisMaxMin").append("text").style("opacity",0),n.exit().remove(),n.attr("transform",function(b,c){return"translate(0,"+a(b)+")"}).select("text").attr("dy",".32em").attr("dx",e.tickPadding()).attr("text-anchor","start").text(function(a,b){return e.tickFormat()(a)}),d3.transition(n).attr("transform",function(b,c){return"translate(0,"+a.range()[c]+")"}).select("text").style("opacity",1)}break;case"left":m.enter().append("text").attr("class","axislabel").attr("transform","rotate(-90)").attr("y",-40),m.attr("x",-a.range()[0]/2);if(c){var n=i.selectAll("g.axisMaxMin").data(a.domain());n.enter().append("g").attr("class","axisMaxMin").append("text").style("opacity",0),n.exit().remove(),n.attr("transform",function(a,b){return"translate(0,"+f(a)+")"}).select("text").attr("dy",".32em").attr("dx",-e.tickPadding()).attr("text-anchor","end").text(function(a,b){return e.tickFormat()(a)}),d3.transition(n).attr("transform",function(b,c){return"translate(0,"+a.range()[c]+")"}).select("text").style("opacity",1)}}m.text(function(a){return a}),c&&(e.orient()==="left"||e.orient()==="right")&&l.selectAll("g").filter(function(b,c){return b&&(a(b)<8||a(b)>a.range()[0]-8)}).remove();if(c&&(e.orient()==="top"||e.orient()==="bottom")){var o=[];i.selectAll("g.axisMaxMin").each(function(b,c){c?o.push(a(b)-this.getBBox().width-4):o.push(a(b)+this.getBBox().width+4)}),l.selectAll("g").filter(function(b,c){return b&&(a(b)o[1])}).remove()}d&&l.selectAll("line.tick").filter(function(a){return!parseFloat(Math.round(a*1e5)/1e6)}).classed("zero",!0),f=a.copy()});return g}var a=d3.scale.linear(),b=null,c=!0,d=!0,e=d3.svg.axis().scale(a).orient("bottom").tickFormat(function(a){return a}),f;d3.rebind(g,e,"orient","ticks","tickValues","tickSubdivide","tickSize","tickPadding","tickFormat"),d3.rebind(g,a,"domain","range","rangeBand","rangeBands"),g.axisLabel=function(a){if(!arguments.length)return b;b=a;return g},g.showMaxMin=function(a){if(!arguments.length)return c;c=a;return g},g.highlightZero=function(a){if(!arguments.length)return d;d=a;return g},g.scale=function(b){if(!arguments.length)return a;a=b,e.scale(a),d3.rebind(g,a,"domain","range","rangeBand","rangeBands");return g};return g},a.models.historicalBar=function(){function r(g){g.each(function(g){var h=b-a.left-a.right,o=c-a.top-a.bottom;m.domain(k||d3.extent(g[0].values,e)).range([0,h]),n.domain(l||d3.extent(g[0].values,f)).range([o,0]);var p=d3.select(this).on("click",function(a,b){q.chartClick({data:a,index:b,pos:d3.event,id:d})}),r=d3.select(this).selectAll("g.wrap.bar").data([g[0].values]),s=r.enter().append("g").attr("class","wrap nvd3 bar"),t=s.append("g");t.append("g").attr("class","bars"),r.attr("width",b).attr("height",c);var u=r.select("g").attr("transform","translate("+a.left+","+a.top+")");s.append("defs").append("clipPath").attr("id","chart-clip-path-"+d).append("rect"),r.select("#chart-clip-path-"+d+" rect").attr("width",h).attr("height",o),t.attr("clip-path",i?"url(#chart-clip-path-"+d+")":"");var v=t.append("g").attr("class","shiftWrap"),w=r.select(".bars").selectAll(".bar").data(function(a){return a});w.exit().remove();var z=w.enter().append("svg:rect").attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("fill",function(a,b){return j[0]}).attr("x",0).attr("y",function(a,b){return n(Math.max(0,f(a,b)))}).attr("height",function(a,b){return Math.abs(n(f(a,b))-n(0))}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),q.elementMouseover({point:a,series:g[0],pos:[m(e(a,b)),n(f(a,b))],pointIndex:b,seriesIndex:0,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),q.elementMouseout({point:a,series:g[0],pointIndex:b,seriesIndex:0,e:d3.event})}).on("click",function(a,b){q.elementClick({value:f(a,b),data:a,index:b,pos:[m(e(a,b)),n(f(a,b))],e:d3.event,id:d}),d3.event.stopPropagation()}).on("dblclick",function(a,b){q.elementDblClick({value:f(a,b),data:a,index:b,pos:[m(e(a,b)),n(f(a,b))],e:d3.event,id:d}),d3.event.stopPropagation()});w.attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("transform",function(a,b){return"translate("+(m(e(a,b))-m(.5))+",0)"}).attr("width",m(.9)),d3.transition(w).attr("y",function(a,b){return n(Math.max(0,f(a,b)))}).attr("height",function(a,b){return Math.abs(n(f(a,b))-n(0))})});return r}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=Math.floor(Math.random()*1e4),e=function(a){return a.x},f=function(a){return a.y},g=[],h=[],i=!0,j=d3.scale.category20().range(),k,l,m=d3.scale.linear(),n=d3.scale.linear(),o=d3.svg.axis().scale(m).orient("bottom"),p=d3.svg.axis().scale(n).orient("left"),q=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");r.dispatch=q,r.x=function(a){if(!arguments.length)return e;e=a;return r},r.y=function(a){if(!arguments.length)return f;f=a;return r},r.margin=function(b){if(!arguments.length)return a;a=b;return r},r.width=function(a){if(!arguments.length)return b;b=a;return r},r.height=function(a){if(!arguments.length)return c;c=a;return r},r.xScale=function(a){if(!arguments.length)return m;m=a;return r},r.yScale=function(a){if(!arguments.length)return n;n=a;return r},r.xDomain=function(a){if(!arguments.length)return k;k=a;return r},r.yDomain=function(a){if(!arguments.length)return l;l=a;return r},r.forceX=function(a){if(!arguments.length)return g;g=a;return r},r.forceY=function(a){if(!arguments.length)return h;h=a;return r},r.clipEdge=function(a){if(!arguments.length)return i;i=a;return r},r.color=function(a){if(!arguments.length)return j;j=a;return r},r.id=function(a){if(!arguments.length)return d;d=a;return r};return r},a.models.bullet=function(){function k(a){a.each(function(a,k){var l=d.call(this,a,k).slice().sort(d3.descending),m=e.call(this,a,k).slice().sort(d3.descending),n=f.call(this,a,k).slice().sort(d3.descending),o=d3.select(this),p=d3.scale.linear().domain([0,Math.max(l[0],m[0],n[0])]).range(b?[g,0]:[0,g]),q=this.__chart__||d3.scale.linear().domain([0,Infinity]).range(p.range());this.__chart__=p;var r=function(a){return Math.abs(q(a)-q(0))},s=function(a){return Math.abs(p(a)-p(0))},t=o.selectAll("rect.range").data(l);t.enter().append("rect").attr("class",function(a,b){return"range s"+b}).attr("width",r).attr("height",h).attr("x",b?q:0).on("mouseover",function(a,b){j.elementMouseover({value:a,label:b<=0?"Maximum":b>1?"Minimum":"Mean",pos:[p(a),h/2]})}).on("mouseout",function(a,b){j.elementMouseout({value:a,label:b<=0?"Minimum":b>=1?"Maximum":"Mean"})}).transition().duration(c).attr("width",s).attr("x",b?p:0),t.transition().duration(c).attr("x",b?p:0).attr("width",s).attr("height",h);var u=o.selectAll("rect.measure").data(n);u.enter().append("rect").attr("class",function(a,b){return"measure s"+b}).attr("width",r).attr("height",h/3).attr("x",b?q:0).attr("y",h/3).on("mouseover",function(a){j.elementMouseover({value:a,label:"Current",pos:[p(a),h/2]})}).on("mouseout",function(a){j.elementMouseout({value:a,label:"Current"})}).transition().duration(c).attr("width",s).attr("x",b?p:0),u.transition().duration(c).attr("width",s).attr("height",h/3).attr("x",b?p:0).attr("y",h/3);var v=o.selectAll("path.markerTriangle").data(m),w=h/6;v.enter().append("path").attr("class","markerTriangle").attr("transform",function(a){return"translate("+q(a)+","+h/2+")"}).attr("d","M0,"+w+"L"+w+","+ -w+" "+ -w+","+ -w+"Z").on("mouseover",function(a,b){j.elementMouseover({value:a,label:"Previous",pos:[p(a),h/2]})}).on("mouseout",function(a,b){j.elementMouseout({value:a,label:"Previous"})}),v.transition().duration(c).attr("transform",function(a){return"translate("+p(a)+","+h/2+")"}),v.exit().remove();var x=i||p.tickFormat(8),y=o.selectAll("g.tick").data(p.ticks(8),function(a){return this.textContent||x(a)}),z=y.enter().append("g").attr("class","tick").attr("transform",function(a){return"translate("+q(a)+",0)"}).style("opacity",1e-6);z.append("line").attr("y1",h).attr("y2",h*7/6),z.append("text").attr("text-anchor","middle").attr("dy","1em").attr("y",h*7/6).text(x),z.transition().duration(c).attr("transform",function(a){return"translate("+p(a)+",0)"}).style("opacity",1);var A=y.transition().duration(c).attr("transform",function(a){return"translate("+p(a)+",0)"}).style("opacity",1);A.select("line").attr("y1",h).attr("y2",h*7/6),A.select("text").attr("y",h*7/6),y.exit().transition().duration(c).attr("transform",function(a){return"translate("+p(a)+",0)"}).style("opacity",1e-6).remove()}),d3.timer.flush()}var a="left",b=!1,c=0,d=function(a){return a.ranges},e=function(a){return a.markers},f=function(a){return a.measures},g=380,h=30,i=null,j=d3.dispatch("elementMouseover","elementMouseout");k.dispatch=j,k.orient=function(c){if(!arguments.length)return a;a=c,b=a=="right"||a=="bottom";return k},k.ranges=function(a){if(!arguments.length)return d;d=a;return k},k.markers=function(a){if(!arguments.length)return e;e=a;return k},k.measures=function(a){if(!arguments.length)return f;f=a;return k},k.width=function(a){if(!arguments.length)return g;g=a;return k},k.height=function(a){if(!arguments.length)return h;h=a;return k},k.tickFormat=function(a){if(!arguments.length)return i;i=a;return k},k.duration=function(a){if(!arguments.length)return c;c=a;return k};return k},a.models.cumulativeLine=function(){function B(a,b){return b.map(function(b,c){var d=h(b.values[a],a);return{key:b.key,values:b.values.map(function(a,b){return{x:g(a,b),y:(h(a,b)-d)/(1+d)}}),disabled:b.disabled,hover:b.hover}})}function A(a){a.each(function(f){var g=c(),h=d(),x=g-b.left-b.right,y=h-b.top-b.bottom,z=B(u.i,f),C=z.filter(function(a){return!k||!a.disabled}).map(function(a){return a.values});l.domain(d3.extent(d3.merge(C),function(a){return a.x})).range([0,x]),m.domain([0,f[0].values.length-1]).range([0,x]).clamp(!0),n.domain(d3.extent(d3.merge(C),function(a){return a.y})).range([y,0]),s.width(x).height(y).color(f.map(function(a,b){return a.color||e[b%e.length]}).filter(function(a,b){return!f[b].disabled}));var D=d3.select(this).classed("chart-"+i,!0).selectAll("g.wrap").data([z]),E=D.enter().append("g").attr("class","wrap nvd3 cumulativeLine").append("g");E.append("g").attr("class","x axis"),E.append("g").attr("class","y axis"),E.append("g").attr("class","linesWrap"),E.append("g").attr("class","legendWrap"),E.append("g").attr("class","controlsWrap"),b.top=q.height();var F=D.select("g").attr("transform","translate("+b.left+","+b.top+")");q.width(g/2-b.right),F.select(".legendWrap").datum(f).attr("transform","translate("+(g/2-b.left)+","+ -b.top+")").call(q),j&&(r.width(140).color(["#444","#444","#444"]),F.select(".controlsWrap").datum(v).attr("transform","translate(0,"+ -b.top+")").call(r));var G=F.select(".linesWrap").datum(z.filter(function(a){return!a.disabled}));d3.transition(G).call(s);var H=G.selectAll(".indexLine").data([u]);H.enter().append("rect").attr("class","indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).call(w),H.attr("transform",function(a){return"translate("+m(a.i)+",0)"}).attr("height",y),o.domain(l.domain()).range(l.range()).ticks(g/100).tickSize(-y,0),F.select(".x.axis").attr("transform","translate(0,"+n.range()[0]+")"),d3.transition(F.select(".x.axis")).call(o),p.domain(n.domain()).range(n.range()).ticks(h/36).tickSize(-x,0),d3.transition(F.select(".y.axis")).call(p),q.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,f.filter(function(a){return!a.disabled}).length||f.map(function(a){a.disabled=!1,D.selectAll(".series").classed("disabled",!1);return a}),a.transition().call(A)}),r.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,k=!b.disabled,a.transition().call(A)}),s.dispatch.on("elementMouseover.tooltip",function(a){t.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),s.dispatch.on("elementMouseout.tooltip",function(a){t.tooltipHide(a)})});return A}function z(a,b){d3.transition(d3.select(".chart-"+i)).call(A)}function y(a,b){a.x+=d3.event.dx,a.i=Math.round(m.invert(a.x)),d3.select(this).attr("transform","translate("+m(a.i)+",0)")}function x(a,b){}var b={top:30,right:20,bottom:30,left:60},c=function(){return 960},d=function(){return 500},e=d3.scale.category20().range(),f=function(){return 2.5},g=function(a){return a.x},h=function(a){return a.y},i=Math.floor(Math.random()*1e4),j=!0,k=!0,l=d3.scale.linear(),m=d3.scale.linear(),n=d3.scale.linear(),o=a.models.axis().scale(l).orient("bottom"),p=a.models.axis().scale(n).orient("left"),q=a.models.legend().height(30),r=a.models.legend().height(30),s=a.models.line(),t=d3.dispatch("tooltipShow","tooltipHide"),u={i:0,x:0},v=[{key:"Re-scale y-axis"}],w=d3.behavior.drag().on("dragstart",x).on("drag",y).on("dragend",z);A.dispatch=t,A.x=function(a){if(!arguments.length)return g;g=a;return A},A.y=function(a){if(!arguments.length)return h;h=a;return A},A.margin=function(a){if(!arguments.length)return b;b=a;return A},A.width=function(a){if(!arguments.length)return c;c=d3.functor(a);return A},A.height=function(a){if(!arguments.length)return d;d=d3.functor(a);return A},A.color=function(a){if(!arguments.length)return e;e=a,q.color(a);return A},A.dotRadius=function(a){if(!arguments.length)return f;f=d3.functor(a),s.dotRadius=a;return A},A.showRescaleToggle=function(a){if(!arguments.length)return j;j=a;return A},A.xAxis=o,A.yAxis=p;return A},a.models.cumulativeLineChart=function(){function C(a,b){return b.map(function(b,c){var d=k.y()(b.values[a],a);return{key:b.key,values:b.values.map(function(a,b){return{x:k.x()(a,b),y:(k.y()(a,b)-d)/(1+d)}}),disabled:b.disabled,hover:b.hover}})}function B(h){h.each(function(y){var z=d3.select(this).classed("chart-"+o,!0),A=this,D=(d||parseInt(z.style("width"))||960)-b.left-b.right,E=(e||parseInt(z.style("height"))||400)-b.top-b.bottom,F=C(u.i,y);n.domain([0,y[0].values.length-1]).range([0,D]).clamp(!0);var G=z.selectAll("g.wrap.cumulativeLine").data([F]),H=G.enter().append("g").attr("class","wrap nvd3 cumulativeLine").append("g");H.append("g").attr("class","x axis"),H.append("g").attr("class","y axis"),H.append("g").attr("class","linesWrap"),H.append("g").attr("class","legendWrap"),H.append("g").attr("class","controlsWrap");var I=G.select("g");f&&(r.width(D),I.select(".legendWrap").datum(y).call(r),b.top!=r.height()&&(b.top=r.height(),E=(e||parseInt(z.style("height"))||400)-b.top-b.bottom),I.select(".legendWrap").attr("transform","translate(0,"+ -b.top+")")),i&&(s.width(140).color(["#444","#444","#444"]),I.select(".controlsWrap").datum(v).attr("transform","translate(0,"+ -b.top+")").call(s)),k.width(D).height(E).color(F.map(function(a,b){return a.color||c[b%c.length]}).filter(function(a,b){return!y[b].disabled})),I.attr("transform","translate("+b.left+","+b.top+")");var J=I.select(".linesWrap").datum(F.filter(function(a){return!a.disabled}));d3.transition(J).call(k);var K=J.selectAll(".indexLine").data([u]);K.enter().append("rect").attr("class","indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).call(x),K.attr("transform",function(a){return"translate("+n(a.i)+",0)"}).attr("height",E),p.scale(l).ticks(D/100).tickSize(-E,0),I.select(".x.axis").attr("transform","translate(0,"+m.range()[0]+")"),d3.transition(I.select(".x.axis")).call(p),q.scale(m).ticks(E/36).tickSize(-D,0),d3.transition(I.select(".y.axis")).call(q),s.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,j=!a.disabled,h.transition().call(B)}),r.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,y.filter(function(a){return!a.disabled}).length||y.map(function(a){a.disabled=!1,G.selectAll(".series").classed("disabled",!1);return a}),h.transition().call(B)}),k.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],t.tooltipShow(a)}),g&&t.on("tooltipShow",function(a){w(a,A.parentNode)}),k.dispatch.on("elementMouseout.tooltip",function(a){t.tooltipHide(a)}),g&&t.on("tooltipHide",a.tooltip.cleanup)}),B.update=function(){B(h)},B.container=this;return B}function A(a,b){B.update()}function z(a,b){a.x+=d3.event.dx,a.i=Math.round(n.invert(a.x)),d3.select(this).attr("transform","translate("+n(a.i)+",0)")}function y(a,b){}var b={top:30,right:20,bottom:50,left:60},c=d3.scale.category20().range(),d=null,e=null,f=!0,g=!0,h=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" at "+b+"

"},i=!1,j=!0,k=a.models.line(),l=k.xScale(),m=k.yScale(),n=d3.scale.linear(),o=k.id(),p=a.models.axis().scale(l).orient("bottom").tickPadding(5),q=a.models.axis().scale(m).orient("left"),r=a.models.legend().height(30),s=a.models.legend().height(30),t=d3.dispatch("tooltipShow","tooltipHide"),u={i:0,x:0},v=[{key:"Re-scale y-axis"}],w=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=p.tickFormat()(k.x()(b.point)),g=q.tickFormat()(k.y()(b.point)),i=h(b.series.key,f,g,b,B);a.tooltip.show([d,e],i)},x=d3.behavior.drag().on("dragstart",y).on("drag",z).on("dragend",A);B.dispatch=t,B.legend=r,B.xAxis=p,B.yAxis=q,d3.rebind(B,k,"x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),B.margin=function(a){if(!arguments.length)return b;b=a;return B},B.width=function(a){if(!arguments.length)return d;d=a;return B},B.height=function(a){if(!arguments.length)return e;e=a;return B},B.color=function(a){if(!arguments.length)return c;c=a,r.color(a);return B},B.showLegend=function(a){if(!arguments.length)return f;f=a;return B},B.tooltips=function(a){if(!arguments.length)return g;g=a;return B},B.tooltipContent=function(a){if(!arguments.length)return h;h=a;return B};return B},a.models.discreteBar=function(){function r(d){d.each(function(s){var t=b-a.left-a.right,u=c-a.top-a.bottom;s=s.map(function(a,b){a.values=a.values.map(function(a){a.series=b;return a});return a});var v=m&&n?[]:s.map(function(a){return a.values.map(function(a,b){return{x:g(a,b),y:h(a,b),y0:a.y0}})});e.domain(m||d3.merge(v).map(function(a){return a.x})).rangeBands([0,t],.1),f.domain(n||d3.extent(d3.merge(v).map(function(a){return a.y}).concat(i))),k?f.range([u-(f.domain()[0]<0?12:0),f.domain()[1]<0?0:12]):f.range([u,0]),o=o||e,p=p||d3.scale.linear().domain(f.domain()).range([f(0),f(0)]);var w=d3.select(this).selectAll("g.wrap.discretebar").data([s]),z=w.enter().append("g").attr("class","wrap nvd3 discretebar"),A=z.append("g");A.append("g").attr("class","groups");var B=w.select("g");w.attr("transform","translate("+a.left+","+a.top+")");var C=w.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});C.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(C.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),C.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}),d3.transition(C).style("stroke-opacity",1).style("fill-opacity",.75);var D=C.selectAll("g.bar").data(function(a){return a.values});D.exit().remove();var E=D.enter().append("g").attr("transform",function(a,b,c){return"translate("+e(g(a,b))+", "+f(0)+")"}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),q.elementMouseover({value:h(a,b),point:a,series:s[a.series],pos:[e(g(a,b))+e.rangeBand()*(a.series+.5)/s.length,f(h(a,b))],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),q.elementMouseout({value:h(a,b),point:a,series:s[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){q.elementClick({value:h(a,b),point:a,series:s[a.series],pos:[e(g(a,b))+e.rangeBand()*(a.series+.5)/s.length,f(h(a,b))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(a,b){q.elementDblClick({value:h(a,b),point:a,series:s[a.series],pos:[e(g(a,b))+e.rangeBand()*(a.series+.5)/s.length,f(h(a,b))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()});E.append("rect").attr("height",0).attr("width",e.rangeBand()/s.length).style("fill",function(a,b){return a.color||j[b%j.length]}).style("stroke",function(a,b){return a.color||j[b%j.length]}),k?(E.append("text").attr("text-anchor","middle"),D.selectAll("text").attr("dx",e.rangeBand()/2).attr("dy",function(a,b){return h(a,b)<0?f(h(a,b))-f(0)+12:-4}).text(function(a,b){return l(h(a,b))})):D.selectAll("text").remove(),D.attr("class",function(a,b){return h(a,b)<0?"bar negative":"bar positive"}).attr("transform",function(a,b){return"translate("+e(g(a,b))+", "+(h(a,b)<0?p(0):p(h(a,b)))+")"}).selectAll("rect").attr("width",e.rangeBand()/s.length),d3.transition(D).attr("transform",function(a,b){return"translate("+e(g(a,b))+", "+(h(a,b)<0?f(0):f(h(a,b)))+")"}).selectAll("rect").attr("height",function(a,b){return Math.abs(f(h(a,b))-f(0))}),r.update=function(){d.transition().call(r)},o=e.copy(),p=f.copy()});return r}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=Math.floor(Math.random()*1e4),e=d3.scale.ordinal(),f=d3.scale.linear(),g=function(a){return a.x},h=function(a){return a.y},i=[0],j=d3.scale.category20().range(),k=!1,l=d3.format(",.2f"),m,n,o,p,q=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");r.dispatch=q,r.x=function(a){if(!arguments.length)return g;g=a;return r},r.y=function(a){if(!arguments.length)return h;h=a;return r},r.margin=function(b){if(!arguments.length)return a;a=b;return r},r.width=function(a){if(!arguments.length)return b;b=a;return r},r.height=function(a){if(!arguments.length)return c;c=a;return r},r.xScale=function(a){if(!arguments.length)return e;e=a;return r},r.yScale=function(a){if(!arguments.length)return f;f=a;return r},r.xDomain=function(a){if(!arguments.length)return m;m=a;return r},r.yDomain=function(a){if(!arguments.length)return n;n=a;return r},r.forceY=function(a){if(!arguments.length)return i;i=a;return r},r.color=function(a){if(!arguments.length)return j;j=a;return r},r.id=function(a){if(!arguments.length)return d;d=a;return r},r.showValues=function(a){if(!arguments.length)return k;k=a;return r},r.valuesFormat=function(a){if(!arguments.length)return l;l=a;return r};return r},a.models.discreteBarChart=function(){function q(e){e.each(function(h){var p=d3.select(this),r=this,s=(c||parseInt(p.style("width"))||960)-b.left-b.right,t=(d||parseInt(p.style("height"))||400)-b.top-b.bottom;i.width(s).height(t);var u=p.selectAll("g.wrap.discreteBarWithAxes").data([h]),v=u.enter().append("g").attr("class","wrap nvd3 discreteBarWithAxes").append("g"),w=v.append("defs");v.append("g").attr("class","x axis"),v.append("g").attr("class","y axis"),v.append("g").attr("class","barsWrap");var z=u.select("g");z.attr("transform","translate("+b.left+","+b.top+")");var A=z.select(".barsWrap").datum(h.filter(function(a){return!a.disabled}));d3.transition(A).call(i),w.append("clipPath").attr("id","x-label-clip-"+i.id()).append("rect"),z.select("#x-label-clip-"+i.id()+" rect").attr("width",j.rangeBand()*(f?2:1)).attr("height",16).attr("x",-j.rangeBand()/(f?1:2)),l.ticks(s/100).tickSize(-t,0),z.select(".x.axis").attr("transform","translate(0,"+(k.range()[0]+(i.showValues()?16:0))+")"),z.select(".x.axis").transition().duration(0).call(l);var B=z.select(".x.axis").selectAll("g");f&&B.selectAll("text").attr("transform",function(a,b,c){return"translate(0,"+(c%2==0?"0":"12")+")"}),B.selectAll("text").attr("clip-path",function(a,b,c){return"url(#x-label-clip-"+i.id()+")"}),m.ticks(t/36).tickSize(-s,0),d3.transition(z.select(".y.axis")).call(m),i.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],n.tooltipShow(a)}),g&&n.on("tooltipShow",function(a){o(a,r.parentNode)}),i.dispatch.on("elementMouseout.tooltip",function(a){n.tooltipHide(a)}),g&&n.on("tooltipHide",a.tooltip.cleanup),q.update=function(){e.transition().call(q)},q.container=this});return q}var b={top:30,right:20,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!1,g=!0,h=function(a,b,c,d,e){return"

"+b+"

"+"

"+c+"

"},i=a.models.discreteBar(),j=i.xScale(),k=i.yScale(),l=a.models.axis().scale(j).orient("bottom").highlightZero(!1).showMaxMin(!1),m=a.models.axis().scale(k).orient("left"),n=d3.dispatch("tooltipShow","tooltipHide");l.tickFormat(function(a){return a}),m.tickFormat(d3.format(",.1f"));var o=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=l.tickFormat()(i.x()(b.point)),g=m.tickFormat()(i.y()(b.point)),j=h(b.series.key,f,g,b,q);a.tooltip.show([d,e],j,b.value<0?"n":"s")},p=[{key:"Grouped"},{key:"Stacked",disabled:!0}];q.dispatch=n,q.discretebar=i,q.xAxis=l,q.yAxis=m,d3.rebind(q,i,"x","y","xDomain","yDomain","forceX","forceY","id","showValues","valueFormat"),q.margin=function(a){if(!arguments.length)return b;b=a;return q},q.width=function(a){if(!arguments.length)return c;c=a;return q},q.height=function(a){if(!arguments.length)return d;d=a;return q},q.color=function(a){if(!arguments.length)return e;e=a,i.color(a);return q},q.staggerLabels=function(a){if(!arguments.length)return f;f=a;return q},q.tooltips=function(a){if(!arguments.length)return g;g=a;return q},q.tooltipContent=function(a){if(!arguments.length)return h;h=a;return q};return q},a.models.distribution=function(){function j(g){g.each(function(g){var j=b-(d==="x"?a.left+a.right:a.top+a.bottom),k=d=="x"?"y":"x";i=i||h;var l=d3.select(this).selectAll("g.distribution").data([g]),m=l.enter().append("g").attr("class","nvd3 distribution"),n=m.append("g"),o=l.select("g");l.attr("transform","translate("+a.left+","+a.top+")");var p=o.selectAll("g.dist").data(function(a){return a},function(a){return a.key});p.enter().append("g"),p.attr("class",function(a,b){return"dist series-"+b}).style("stroke",function(a,b){return f[b%f.length]});var q=p.selectAll("line.dist"+d).data(function(a){return a.values});q.enter().append("line").attr(d+"1",function(a,b){return i(e(a,b))}).attr(d+"2",function(a,b){return i(e(a,b))}),d3.transition(p.exit().selectAll("line.dist"+d)).attr(d+"1",function(a,b){return h(e(a,b))}).attr(d+"2",function(a,b){return h(e(a,b))}).style("stroke-opacity",0).remove(),q.attr("class",function(a,b){return"dist"+d+" dist"+d+"-"+b}).attr(k+"1",0).attr(k+"2",c),d3.transition(q).attr(d+"1",function(a,b){return h(e(a,b))}).attr(d+"2",function(a,b){return h(e(a,b))}),i=h.copy()});return j}var a={top:0,right:0,bottom:0,left:0},b=400,c=8,d="x",e=function(a){return a[d]},f=d3.scale.category20().range(),g,h=d3.scale.linear(),i;j.margin=function(b){if(!arguments.length)return a;a=b;return j},j.width=function(a){if(!arguments.length)return b;b=a;return j},j.axis=function(a){if(!arguments.length)return d;d=a;return j},j.size=function(a){if(!arguments.length)return c;c=a;return j},j.getData=function(a){if(!arguments.length)return e;e=d3.functor(a);return j},j.scale=function(a){if(!arguments.length)return h;h=a;return j},j.color=function(a){if(!arguments.length)return f;f=a;return j};return j},a.models.legend=function(){function g(h){h.each(function(g){var h=b-a.left-a.right,i=d3.select(this).selectAll("g.legend").data([g]),j=i.enter().append("g").attr("class","nvd3 legend").append("g"),l=i.select("g").attr("transform","translate("+a.left+","+a.top+")"),m=l.selectAll(".series").data(function(a){return a}),n=m.enter().append("g").attr("class","series").on("mouseover",function(a,b){f.legendMouseover(a,b)}).on("mouseout",function(a,b){f.legendMouseout(a,b)}).on("click",function(a,b){f.legendClick(a,b)}).on("dblclick",function(a,b){f.legendDblclick(a,b)});n.append("circle").style("fill",function(a,b){return a.color||d[b%d.length]}).style("stroke",function(a,b){return a.color||d[b%d.length]}).style("stroke-width",2).attr("r",5),n.append("text").text(function(a){return a.key}).attr("text-anchor","start").attr("dy",".32em").attr -("dx","8"),m.classed("disabled",function(a){return a.disabled}),m.exit().remove();if(e){var o=[];m.each(function(a,b){o.push(d3.select(this).select("text").node().getComputedTextLength()+28)});var p=0,q=0,r=[];while(qh&&p>1){r=[],p--;for(k=0;k(r[k%p]||0)&&(r[k%p]=o[k]);q=r.reduce(function(a,b,c,d){return a+b})}var s=[];for(var t=0,u=0;tx&&(x=w);return"translate("+y+","+v+")"}),l.attr("transform","translate("+(b-a.right-x)+","+a.top+")"),c=a.top+a.bottom+v+15}});return g}var a={top:5,right:0,bottom:5,left:0},b=400,c=20,d=d3.scale.category20().range(),e=!0,f=d3.dispatch("legendClick","legendDblclick","legendMouseover","legendMouseout");g.dispatch=f,g.margin=function(b){if(!arguments.length)return a;a=b;return g},g.width=function(a){if(!arguments.length)return b;b=a;return g},g.height=function(a){if(!arguments.length)return c;c=a;return g},g.color=function(a){if(!arguments.length)return d;d=a;return g},g.align=function(a){if(!arguments.length)return e;e=a;return g};return g},a.models.line=function(){function p(a){a.each(function(a){var o=c-b.left-b.right,p=d-b.top-b.bottom,q=d3.select(this).selectAll("g.wrap.line").data([a]),r=q.enter().append("g").attr("class","wrap nvd3 line"),s=r.append("defs"),t=r.append("g"),u=q.select("g");r.append("g").attr("class","scatterWrap");var v=q.select(".scatterWrap").datum(a);t.append("g").attr("class","groups"),j.width(o).height(p),d3.transition(v).call(j),q.attr("transform","translate("+b.left+","+b.top+")"),s.append("clipPath").attr("id","edge-clip-"+f).append("rect"),q.select("#edge-clip-"+f+" rect").attr("width",o).attr("height",p),u.attr("clip-path",i?"url(#edge-clip-"+f+")":""),v.attr("clip-path",i?"url(#edge-clip-"+f+")":"");var w=q.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});w.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(w.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),w.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return e[b%e.length]}).style("stroke",function(a,b){return e[b%e.length]}),d3.transition(w).style("stroke-opacity",1).style("fill-opacity",.5);var z=w.selectAll("path").data(function(a,b){return[a.values]});z.enter().append("path").attr("class","line").attr("d",d3.svg.line().x(function(a,b){return m(g(a,b))}).y(function(a,b){return n(h(a,b))})),d3.transition(w.exit().selectAll("path")).attr("d",d3.svg.line().x(function(a,b){return k(g(a,b))}).y(function(a,b){return l(h(a,b))})).remove(),d3.transition(z).attr("d",d3.svg.line().x(function(a,b){return k(g(a,b))}).y(function(a,b){return l(h(a,b))})),m=k.copy(),n=l.copy()});return p}var b={top:0,right:0,bottom:0,left:0},c=960,d=500,e=d3.scale.category20().range(),f=Math.floor(Math.random()*1e4),g=function(a){return a.x},h=function(a){return a.y},i=!1,j=a.models.scatter().id(f).size(16).sizeDomain([16,256]),k=j.xScale(),l=j.yScale(),m=k,n=l,o;p.dispatch=j.dispatch,d3.rebind(p,j,"interactive","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius"),p.margin=function(a){if(!arguments.length)return b;b=a;return p},p.width=function(a){if(!arguments.length)return c;c=a;return p},p.height=function(a){if(!arguments.length)return d;d=a;return p},p.x=function(a){if(!arguments.length)return g;g=a,j.x(a);return p},p.y=function(a){if(!arguments.length)return h;h=a,j.y(a);return p},p.clipEdge=function(a){if(!arguments.length)return i;i=a;return p},p.color=function(a){if(!arguments.length)return e;e=a,j.color(a);return p},p.id=function(a){if(!arguments.length)return f;f=a;return p};return p},a.models.indentedTree=function(){function i(d){d.each(function(e){function B(a){var b=a.values||a._values;return b&&b.length}function A(a){return a._values&&a._values.length}function z(a){return a._values&&a._values.length?iconOpen:a.values&&a.values.length?iconClose:""}function y(a,b,c){d3.event.stopPropagation();if(d3.event.shiftKey&&!c){d3.event.shiftKey=!1,a.values&&a.values.forEach(function(a){(a.values||a._values)&&y(a,0,!0)});return!0}if(!B(a))return!0;a.values?(a._values=a.values,a.values=null):(a.values=a._values,a._values=null),i.update()}var j=b-a.left-a.right,k=c-a.top-a.bottom;i.update=function(){d.transition().call(i)};var l=0,m=1,n=d3.layout.tree().children(function(a){return a.values}).size([c,childIndent]);e[0].key||(e[0].key=g);var o=n.nodes(e[0]),p=d3.select(this).selectAll("div").data([[o]]),q=p.enter().append("div").attr("class","wrap nvd3 indentedtree"),r=q.append("table"),s=p.select("table").attr("width","100%").attr("class",tableClass);if(f){var t=r.append("thead"),u=t.append("tr");columns.forEach(function(a){u.append("th").attr("width",a.width?a.width:"10%").style("text-align",a.type=="numeric"?"right":"left").append("span").text(a.label)})}var v=s.selectAll("tbody").data(function(a){return a});v.enter().append("tbody"),m=d3.max(o,function(a){return a.depth}),n.size([c,m*childIndent]);var w=v.selectAll("tr").data(function(a){return a},function(a){return a.id||a.id==++l});w.exit().remove(),w.select("img.treeicon").attr("src",z).classed("folded",A);var x=w.enter().append("tr");columns.forEach(function(a,b){var c=x.append("td").style("padding-left",function(a){return(b?0:a.depth*childIndent+12+(z(a)?0:16))+"px"},"important").style("text-align",a.type=="numeric"?"right":"left");b==0&&c.append("img").classed("treeicon",!0).classed("folded",A).attr("src",z).style("width","14px").style("height","14px").style("padding","0 1px").style("display",function(a){return z(a)?"inline-block":"none"}).on("click",y),c.append("span").attr("class",d3.functor(a.classes)).text(function(b){return a.format?a.format(b):b[a.key]||"-"}),a.showCount&&c.append("span").attr("class","childrenCount").text(function(a){return a.values&&a.values.length||a._values&&a._values.length?"("+(a.values&&a.values.length||a._values&&a._values.length)+")":""}),a.click&&c.select("span").on("click",a.click)}),w.order().on("click",function(a){h.elementClick({row:this,data:a,pos:[a.x,a.y]})}).on("dblclick",function(a){h.elementDblclick({row:this,data:a,pos:[a.x,a.y]})}).on("mouseover",function(a){h.elementMouseover({row:this,data:a,pos:[a.x,a.y]})}).on("mouseout",function(a){h.elementMouseout({row:this,data:a,pos:[a.x,a.y]})})});return i}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=d3.scale.category20().range(),e=Math.floor(Math.random()*1e4),f=!0,g="No Results found.";childIndent=20,columns=[{key:"key",label:"Name",type:"text"}],tableClass=null,iconOpen="images/grey-plus.png",iconClose="images/grey-minus.png";var h=d3.dispatch("elementClick","elementDblclick","elementMouseover","elementMouseout");i.margin=function(b){if(!arguments.length)return a;a=b;return i},i.width=function(a){if(!arguments.length)return b;b=a;return i},i.height=function(a){if(!arguments.length)return c;c=a;return i},i.color=function(a){if(!arguments.length)return d;d=a,scatter.color(a);return i},i.id=function(a){if(!arguments.length)return e;e=a;return i},i.header=function(a){if(!arguments.length)return f;f=a;return i},i.noResultsText=function(a){if(!arguments.length)return g;g=a;return i},i.columns=function(a){if(!arguments.length)return columns;columns=a;return i},i.tableClass=function(a){if(!arguments.length)return tableClass;tableClass=a;return i};return i},a.models.lineChart=function(){function q(h){h.each(function(j){var r=d3.select(this),s=this,t=(d||parseInt(r.style("width"))||960)-b.left-b.right,u=(e||parseInt(r.style("height"))||400)-b.top-b.bottom,v=r.selectAll("g.wrap.lineChart").data([j]),w=v.enter().append("g").attr("class","wrap nvd3 lineChart").append("g");w.append("g").attr("class","x axis"),w.append("g").attr("class","y axis"),w.append("g").attr("class","linesWrap"),w.append("g").attr("class","legendWrap");var x=v.select("g");f&&(n.width(t),x.select(".legendWrap").datum(j).call(n),b.top!=n.height()&&(b.top=n.height(),u=(e||parseInt(r.style("height"))||400)-b.top-b.bottom),x.select(".legendWrap").attr("transform","translate(0,"+ -b.top+")")),i.width(t).height(u).color(j.map(function(a,b){return a.color||c[b%c.length]}).filter(function(a,b){return!j[b].disabled})),x.attr("transform","translate("+b.left+","+b.top+")");var z=x.select(".linesWrap").datum(j.filter(function(a){return!a.disabled}));d3.transition(z).call(i),l.ticks(t/100).tickSize(-u,0),x.select(".x.axis").attr("transform","translate(0,"+k.range()[0]+")"),d3.transition(x.select(".x.axis")).call(l),m.ticks(u/36).tickSize(-t,0),d3.transition(x.select(".y.axis")).call(m),n.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,j.filter(function(a){return!a.disabled}).length||j.map(function(a){a.disabled=!1,v.selectAll(".series").classed("disabled",!1);return a}),h.transition().call(q)}),i.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],o.tooltipShow(a)}),g&&o.on("tooltipShow",function(a){p(a,s.parentNode)}),i.dispatch.on("elementMouseout.tooltip",function(a){o.tooltipHide(a)}),g&&o.on("tooltipHide",a.tooltip.cleanup)}),q.update=function(){q(h)},q.container=this;return q}var b={top:30,right:20,bottom:50,left:60},c=d3.scale.category20().range(),d=null,e=null,f=!0,g=!0,h=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" at "+b+"

"},i=a.models.line(),j=i.xScale(),k=i.yScale(),l=a.models.axis().scale(j).orient("bottom").tickPadding(5),m=a.models.axis().scale(k).orient("left"),n=a.models.legend().height(30),o=d3.dispatch("tooltipShow","tooltipHide"),p=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=l.tickFormat()(i.x()(b.point)),g=m.tickFormat()(i.y()(b.point)),j=h(b.series.key,f,g,b,q);a.tooltip.show([d,e],j)};q.dispatch=o,q.legend=n,q.xAxis=l,q.yAxis=m,d3.rebind(q,i,"x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),q.margin=function(a){if(!arguments.length)return b;b=a;return q},q.width=function(a){if(!arguments.length)return d;d=a;return q},q.height=function(a){if(!arguments.length)return e;e=a;return q},q.color=function(a){if(!arguments.length)return c;c=a,n.color(a);return q},q.showLegend=function(a){if(!arguments.length)return f;f=a;return q},q.tooltips=function(a){if(!arguments.length)return g;g=a;return q},q.tooltipContent=function(a){if(!arguments.length)return h;h=a;return q};return q},a.models.linePlusBarChart=function(){function v(j){j.each(function(o){var w=d3.select(this),y=this,z=(c||parseInt(w.style("width"))||960)-b.left-b.right,A=(d||parseInt(w.style("height"))||400)-b.top-b.bottom,B=o.filter(function(a){return!a.disabled&&a.bar}),C=o.filter(function(a){return!a.disabled&&!a.bar}),D=o.filter(function(a){return!a.disabled&&a.bar}).map(function(a){return a.values.map(function(a,b){return{x:e(a,b),y:f(a,b)}})}),E=o.filter(function(a){return!a.disabled&&!a.bar}).map(function(a){return a.values.map(function(a,b){return{x:e(a,b),y:f(a,b)}})});m.domain(d3.extent(d3.merge(D.concat(E)),function(a){return a.x})).range([0,z]),k.width(z).height(A).color(o.map(function(a,b){return a.color||g[b%g.length]}).filter(function(a,b){return!o[b].disabled&&!o[b].bar})),l.width(z).height(A).color(o.map(function(a,b){return a.color||g[b%g.length]}).filter(function(a,b){return!o[b].disabled&&o[b].bar}));var F=d3.select(this).selectAll("g.wrap.linePlusBar").data([o]),G=F.enter().append("g").attr("class","wrap nvd3 linePlusBar").append("g");G.append("g").attr("class","x axis"),G.append("g").attr("class","y1 axis"),G.append("g").attr("class","y2 axis"),G.append("g").attr("class","barsWrap"),G.append("g").attr("class","linesWrap"),G.append("g").attr("class","legendWrap");var H=F.select("g");h&&(s.width(z),H.select(".legendWrap").datum(o.map(function(a){a.key=a.key+(a.bar?" (left axis)":" (right axis)");return a})).call(s),b.top!=s.height()&&(b.top=s.height(),A=(d||parseInt(w.style("height"))||400)-b.top-b.bottom),H.select(".legendWrap").attr("transform","translate(0,"+ -b.top+")"));var I=H.select(".barsWrap").datum(B.length?B:[{values:[]}]),J=H.select(".linesWrap").datum(C.length?C:[{values:[]}]);d3.transition(I).call(l),d3.transition(J).call(k),H.attr("transform","translate("+b.left+","+b.top+")"),p.ticks(z/100).tickSize(-A,0),H.select(".x.axis").attr("transform","translate(0,"+n.range()[0]+")"),d3.transition(H.select(".x.axis")).call(p),q.ticks(A/36).tickSize(-z,0),d3.transition(H.select(".y1.axis")).call(q),r.ticks(A/36).tickSize(B.length?0:-z,0),H.select(".y2.axis").attr("transform","translate("+m.range()[1]+",0)"),d3.transition(H.select(".y2.axis")).call(r),s.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,o.filter(function(a){return!a.disabled}).length||o.map(function(a){a.disabled=!1,F.selectAll(".series").classed("disabled",!1);return a}),j.transition().call(v)}),k.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],t.tooltipShow(a)}),i&&t.on("tooltipShow",function(a){u(a,y.parentNode)}),k.dispatch.on("elementMouseout.tooltip",function(a){t.tooltipHide(a)}),i&&t.on("tooltipHide",a.tooltip.cleanup),l.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],t.tooltipShow(a)}),i&&t.on("tooltipShow",function(a){u(a,y.parentNode)}),l.dispatch.on("elementMouseout.tooltip",function(a){t.tooltipHide(a)}),i&&t.on("tooltipHide",a.tooltip.cleanup),v.update=function(){j.transition().call(v)},v.container=this});return v}var b={top:30,right:60,bottom:50,left:60},c=null,d=null,e=function(a){return a.x},f=function(a){return a.y},g=d3.scale.category20().range(),h=!0,i=!0,j=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" at "+b+"

"},k=a.models.line(),l=a.models.historicalBar(),m=d3.scale.linear(),n=l.yScale(),o=k.yScale(),p=a.models.axis().scale(m).orient("bottom").tickPadding(5),q=a.models.axis().scale(n).orient("left"),r=a.models.axis().scale(o).orient("right"),s=a.models.legend().height(30),t=d3.dispatch("tooltipShow","tooltipHide"),u=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=p.tickFormat()(k.x()(b.point)),g=q.tickFormat()(k.y()(b.point)),h=j(b.series.key,f,g,b,v);a.tooltip.show([d,e],h,b.value<0?"n":"s")};v.dispatch=t,v.legend=s,v.lines=k,v.bars=l,v.xAxis=p,v.yAxis1=q,v.yAxis2=r,d3.rebind(v,k,"size","clipVoronoi"),v.x=function(a){if(!arguments.length)return e;e=a,k.x(a),l.x(a);return v},v.y=function(a){if(!arguments.length)return f;f=a,k.y(a),l.y(a);return v},v.margin=function(a){if(!arguments.length)return b;b=a;return v},v.width=function(a){if(!arguments.length)return c;c=a;return v},v.height=function(a){if(!arguments.length)return d;d=a;return v},v.color=function(a){if(!arguments.length)return g;g=a,s.color(a);return v},v.showLegend=function(a){if(!arguments.length)return h;h=a;return v},v.tooltips=function(a){if(!arguments.length)return i;i=a;return v},v.tooltipContent=function(a){if(!arguments.length)return j;j=a;return v};return v},a.models.lineWithFocusChart=function(){function y(j){j.each(function(z){function O(){var a=w.empty()?p.domain():d3.extent(d3.merge(z.filter(function(a){return!a.disabled}).map(function(a){return a.values})).filter(function(a){return k.x()(a)>=w.extent()[0]&&k.x()(a)<=w.extent()[1]}),k.y());typeof a[0]=="undefined"&&(a=p.domain()),m.domain(w.empty()?o.domain():w.extent()),n.domain(a),k.xDomain(m.domain()),k.yDomain(n.domain())}function N(){O(),K.call(k),J.select(".focus .x.axis").call(q),J.select(".focus .y.axis").call(r)}function M(a){var b=+(a=="e"),c=b?1:-1,d=E/3;return"M"+.5*c+","+d+"A6,6 0 0 "+b+" "+6.5*c+","+(d+6)+"V"+(2*d-6)+"A6,6 0 0 "+b+" "+.5*c+","+2*d+"Z"+"M"+2.5*c+","+(d+8)+"V"+(2*d-8)+"M"+4.5*c+","+(d+8)+"V"+(2*d-8)}var A=d3.select(this),B=this,C=(e||parseInt(A.style("width"))||960)-b.left-b.right,D=(f||parseInt(A.style("height"))||400)-b.top-b.bottom-g,E=g-c.top-c.bottom;w.on("brush",N);var F=A.selectAll("g.wrap.lineWithFocusChart").data([z]),G=F.enter().append("g").attr("class","wrap nvd3 lineWithFocusChart").append("g"),H=G.append("g").attr("class","focus");H.append("g").attr("class","x axis"),H.append("g").attr("class","y axis"),H.append("g").attr("class","linesWrap");var I=G.append("g").attr("class","context");I.append("g").attr("class","x axis"),I.append("g").attr("class","y axis"),I.append("g").attr("class","linesWrap"),I.append("g").attr("class","x brush"),G.append("g").attr("class","legendWrap");var J=F.select("g");h&&(u.width(C),J.select(".legendWrap").datum(z).call(u),b.top!=u.height()&&(b.top=u.height(),D=(f||parseInt(A.style("height"))||400)-b.top-b.bottom),J.select(".legendWrap").attr("transform","translate(0,"+ -b.top+")")),k.width(C).height(D).color(z.map(function(a,b){return a.color||d[b%d.length]}).filter(function(a,b){return!z[b].disabled})),l.width(C).height(E).color(z.map(function(a,b){return a.color||d[b%d.length]}).filter(function(a,b){return!z[b].disabled})),J.attr("transform","translate("+b.left+","+b.top+")");var K=J.select(".focus .linesWrap").datum(z.filter(function(a){return!a.disabled}));d3.transition(K).call(k),q.ticks(C/100).tickSize(-D,0),J.select(".focus .x.axis").attr("transform","translate(0,"+n.range()[0]+")"),d3.transition(J.select(".focus .x.axis")).call(q),r.ticks(D/36).tickSize(-C,0),d3.transition(J.select(".focus .y.axis")).call(r),J.select(".context").attr("transform","translate(0,"+(D+b.bottom+c.top)+")");var L=J.select(".context .linesWrap").datum(z.filter(function(a){return!a.disabled}));d3.transition(L).call(l),gBrush=J.select(".x.brush").call(w),gBrush.selectAll("rect").attr("height",E),gBrush.selectAll(".resize").append("path").attr("d",M),s.tickFormat(q.tickFormat()).ticks(C/100).tickSize(-E,0),J.select(".context .x.axis").attr("transform","translate(0,"+p.range()[0]+")"),d3.transition(J.select(".context .x.axis")).call(s),t.tickFormat(r.tickFormat()).ticks(E/36).tickSize(-C,0),d3.transition(J.select(".context .y.axis")).call(t),O(),u.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,z.filter(function(a){return!a.disabled}).length||z.map(function(a){a.disabled=!1,F.selectAll(".series").classed("disabled",!1);return a}),j.transition().call(y)}),k.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],v.tooltipShow(a)}),i&&v.on("tooltipShow",function(a){x(a,B.parentNode)}),k.dispatch.on("elementMouseout.tooltip",function(a){v.tooltipHide(a)}),i&&v.on("tooltipHide",a.tooltip.cleanup)}),y.update=function(){y(j)},y.container=this;return y}var b={top:30,right:20,bottom:50,left:60},c={top:0,right:20,bottom:20,left:60},d=d3.scale.category20().range(),e=null,f=null,g=100,h=!0,i=!0,j=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" at "+b+"

"},k=a.models.line().clipEdge(!0),l=a.models.line().interactive(!1),m=k.xScale(),n=k.yScale(),o=l.xScale(),p=l.yScale(),q=a.models.axis().scale(m).orient("bottom").tickPadding(5),r=a.models.axis().scale(n).orient("left"),s=a.models.axis().scale(m).orient("bottom").tickPadding(5),t=a.models.axis().scale(p).orient("left"),u=a.models.legend().height(30),v=d3.dispatch("tooltipShow","tooltipHide"),w=d3.svg.brush().x(o),x=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=q.tickFormat()(k.x()(b.point)),g=r.tickFormat()(k.y()(b.point)),h=j(b.series.key,f,g,b,y);a.tooltip.show([d,e],h)};y.dispatch=v,y.legend=u,y.xAxis=q,y.yAxis=r,d3.rebind(y,k,"x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),y.margin=function(a){if(!arguments.length)return b;b=a;return y},y.width=function(a){if(!arguments.length)return e;e=a;return y},y.height=function(a){if(!arguments.length)return f;f=a;return y},y.color=function(a){if(!arguments.length)return d;d=a,u.color(a);return y},y.showLegend=function(a){if(!arguments.length)return h;h=a;return y},y.tooltips=function(a){if(!arguments.length)return i;i=a;return y},y.tooltipContent=function(a){if(!arguments.length)return j;j=a;return y};return y},a.models.multiBar=function(){function s(t){t.each(function(u){var v=b-a.left-a.right,w=c-a.top-a.bottom;n=n||p,o=o||q,i&&(u=d3.layout.stack().offset("zero").values(function(a){return a.values}).y(f)(u)),u=u.map(function(a,b){a.values=a.values.map(function(a){a.series=b;return a});return a});var z=l&&m?[]:u.map(function(a){return a.values.map(function(a,b){return{x:e(a,b),y:f(a,b),y0:a.y0}})});p.domain(d3.merge(z).map(function(a){return a.x})).rangeBands([0,v],.1),q.domain(m||d3.extent(d3.merge(z).map(function(a){return a.y+(i?a.y0:0)}).concat(g))).range([w,0]);var A=d3.select(this).selectAll("g.wrap.multibar").data([u]),B=A.enter().append("g").attr("class","wrap nvd3 multibar"),C=B.append("defs"),D=B.append("g");D.append("g").attr("class","groups");var E=A.select("g");A.attr("transform","translate("+a.left+","+a.top+")"),C.append("clipPath").attr("id","edge-clip-"+d).append("rect"),A.select("#edge-clip-"+d+" rect").attr("width",v).attr("height",w),E.attr("clip-path",h?"url(#edge-clip-"+d+")":"");var F=A.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});F.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(F.exit()).selectAll("rect.bar").delay(function(a,b){return b*k/u[0].values.length}).attr("y",function(a){return i?o(a.y0):o(0)}).attr("height",0).remove(),F.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return j[b%j.length]}).style("stroke",function(a,b){return j[b%j.length]}),d3.transition(F).style("stroke-opacity",1).style("fill-opacity",.75);var G=F.selectAll("rect.bar").data(function(a){return a.values});G.exit().remove();var H=G.enter().append("rect").attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("x",function(a,b,c){return i?0:c*p.rangeBand()/u.length}).attr("y",function(a){return o(i?a.y0:0)}).attr("height",0).attr("width",p.rangeBand()/(i?1:u.length)).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),r.elementMouseover({value:f(a,b),point:a,series:u[a.series],pos:[p(e(a,b))+p.rangeBand()*(i?u.length/2:a.series+.5)/u.length,q(f(a,b)+(i?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),r.elementMouseout({value:f(a,b),point:a,series:u[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){r.elementClick({value:f(a,b),point:a,series:u[a.series],pos:[p(e(a,b))+p.rangeBand()*(i?u.length/2:a.series+.5)/u.length,q(f(a,b)+(i?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(a,b){r.elementDblClick({value:f(a,b),point:a,series:u[a.series],pos:[p(e(a,b))+p.rangeBand()*(i?u.length/2:a.series+.5)/u.length,q(f(a,b)+(i?a.y0:0))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()});G.attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("transform",function(a,b){return"translate("+p(e(a,b))+",0)"}),i?d3.transition(G).delay(function(a,b){return b*k/u[0].values.length}).attr("y",function(a,b){return q(f(a,b)+(i?a.y0:0))}).attr("height",function(a,b){return Math.abs(q(a.y+(i?a.y0:0))-q(i?a.y0:0))}).each("end",function(){d3.transition(d3.select(this)).attr("x",function(a,b){return i?0:a.series*p.rangeBand()/u.length}).attr("width",p.rangeBand()/(i?1:u.length))}):d3.transition(G).delay(function(a,b){return b*k/u[0].values.length}).attr("x",function(a,b){return a.series*p.rangeBand()/u.length}).attr("width",p.rangeBand()/u.length).each("end",function(){d3.transition(d3.select(this)).attr("y",function(a,b){return f(a,b)<0?q(0):q(f(a,b))}).attr("height",function(a,b){return Math.abs(q(f(a,b))-q(0))})}),s.update=function(){t.transition().call(s)},n=p.copy(),o=q.copy()});return s}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=Math.floor(Math.random()*1e4),e=function(a){return a.x},f=function(a){return a.y},g=[0],h=!0,i=!1,j=d3.scale.category20().range(),k=1200,l,m,n,o,p=d3.scale.ordinal(),q=d3.scale.linear(),r=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");s.dispatch=r,s.x=function(a){if(!arguments.length)return e;e=a;return s},s.y=function(a){if(!arguments.length)return f;f=a;return s},s.margin=function(b){if(!arguments.length)return a;a=b;return s},s.width=function(a){if(!arguments.length)return b;b=a;return s},s.height=function(a){if(!arguments.length)return c;c=a;return s},s.xScale=function(a){if(!arguments.length)return p;p=a;return s},s.yScale=function(a){if(!arguments.length)return q;q=a;return s},s.xDomain=function(a){if(!arguments.length)return l;l=a;return s},s.yDomain=function(a){if(!arguments.length)return m;m=a;return s},s.forceY=function(a){if(!arguments.length)return g;g=a;return s},s.stacked=function(a){if(!arguments.length)return i;i=a;return s},s.clipEdge=function(a){if(!arguments.length)return h;h=a;return s},s.color=function(a){if(!arguments.length)return j;j=a;return s},s.id=function(a){if(!arguments.length)return d;d=a;return s},s.delay=function(a){if(!arguments.length)return k;k=a;return s};return s},a.models.multiBarChart=function(){function t(i){i.each(function(k){var u=d3.select(this),v=this,w=(c||parseInt(u.style("width"))||960)-b.left-b.right,x=(d||parseInt(u.style("height"))||400)-b.top-b.bottom,z=u.selectAll("g.wrap.multiBarWithLegend").data([k]),A=z.enter().append("g").attr("class","wrap nvd3 multiBarWithLegend").append("g");A.append("g").attr("class","x axis"),A.append("g").attr("class","y axis"),A.append("g").attr("class","barsWrap"),A.append("g").attr("class","legendWrap"),A.append("g").attr("class","controlsWrap");var B=z.select("g");g&&(o.width(w/2),B.select(".legendWrap").datum(k).call(o),b.top!=o.height()&&(b.top=o.height(),x=(d||parseInt(u.style("height"))||400)-b.top-b.bottom),B.select(".legendWrap").attr("transform","translate("+w/2+","+ -b.top+")")),j.width(w).height(x).color(k.map(function(a,b){return a.color||e[b%e.length]}).filter(function(a,b){return!k[b].disabled})),f&&(p.width(180).color(["#444","#444","#444"]),B.select(".controlsWrap").datum(s).attr("transform","translate(0,"+ -b.top+")").call(p)),B.attr("transform","translate("+b.left+","+b.top+")");var C=B.select(".barsWrap").datum(k.filter(function(a){return!a.disabled}));d3.transition(C).call(j),m.ticks(w/100).tickSize(-x,0),B.select(".x.axis").attr("transform","translate(0,"+l.range()[0]+")"),d3.transition(B.select(".x.axis")).call(m);var D=B.select(".x.axis").selectAll("g");D.selectAll("line, text").style("opacity",1),D.filter(function(a,b){return b%Math.ceil(k[0].values.length/(w/100))!==0}).selectAll("line, text").style("opacity",0),n.ticks(x/36).tickSize(-w,0),d3.transition(B.select(".y.axis")).call(n),o.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,k.filter(function(a){return!a.disabled}).length||k.map(function(a){a.disabled=!1,z.selectAll(".series").classed("disabled",!1);return a}),i.transition().call(t)}),p.dispatch.on("legendClick",function(a,b){if(!!a.disabled){s=s.map(function(a){a.disabled=!0;return a}),a.disabled=!1;switch(a.key){case"Grouped":j.stacked(!1);break;case"Stacked":j.stacked(!0)}i.transition().call(t)}}),j.dispatch.on("elementMouseover.tooltip2",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],q.tooltipShow(a)}),h&&q.on("tooltipShow",function(a){r(a,v.parentNode)}),j.dispatch.on("elementMouseout.tooltip",function(a){q.tooltipHide(a)}),h&&q.on("tooltipHide",a.tooltip.cleanup),t.update=function(){i.transition().call(t)},t.container=this});return t}var b={top:30,right:20,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!0,g=!0,h=!0,i=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" on "+b+"

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

"+b+"

"+"

"+c+"

"},j=a.models.multiBarHorizontal().stacked(!1),k=j.xScale(),l=j.yScale(),m=a.models.axis().scale(k).orient("left").highlightZero(!1).showMaxMin(!1),n=a.models.axis().scale(l).orient("bottom"),o=a.models.legend().height(30),p=a.models.legend().height(30),q=d3.dispatch("tooltipShow","tooltipHide");m.tickFormat(function(a){return a}),n.tickFormat(d3.format(",.1f"));var r=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=m.tickFormat()(j.x()(b.point)),g=n.tickFormat()(j.y()(b.point)),h=i(b.series.key,f,g,b,t);a.tooltip.show([d,e],h,b.value<0?"e":"w")},s=[{key:"Grouped"},{key:"Stacked",disabled:!0}];t.dispatch=q,t.multibar=j,t.legend=o,t.xAxis=m,t.yAxis=n,d3.rebind(t,j,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id","delay","showValues","valueFormat"),t.margin=function(a){if(!arguments.length)return b;b=a;return t},t.width=function(a){if(!arguments.length)return c;c=a;return t},t.height=function(a){if(!arguments.length)return d;d=a;return t},t.color=function(a){if(!arguments.length)return e;e=a,o.color(a);return t},t.showControls=function(a){if(!arguments.length)return f;f=a;return t},t.showLegend=function(a){if(!arguments.length)return g;g=a;return t},t.tooltips=function(a){if(!arguments.length)return h;h=a;return t},t.tooltipContent=function(a){if(!arguments.length)return i;i=a;return t};return t},a.models.pie=function(){function p(m){m.each(function(m){function z(a){a.innerRadius=0;var b=d3.interpolate({startAngle:0,endAngle:0},a);return function(a){return t(b(a))}}function y(a){var b=(a.startAngle+a.endAngle)*90/Math.PI-90;return b>90?b-180:b}var n=d3.select(this).on("click",function(a,b){o.chartClick({data:a,index:b,pos:d3.event,id:h})}),p=n.selectAll("svg.margin").data([m]),q=p.enter();q.append("text").attr("class","title").attr("dy",".91em").attr("text-anchor","start").text(l),q.append("svg").attr("class","margin").attr("x",a.left).attr("y",a.top).style("overflow","visible");var r=p.selectAll("g.wrap").data([m]);r.exit().remove();var s=r.enter();s.append("g").attr("class","wrap").attr("id","wrap-"+h).append("g").attr("class","pie"),r.attr("width",b).attr("height",c).attr("transform","translate("+e+","+e+")");var t=d3.svg.arc().outerRadius(e-e/5);k&&t.innerRadius(e/2);var u=d3.layout.pie().value(function(a){return a[g]}),v=p.select(".pie").selectAll(".slice").data(u);v.exit().remove();var w=v.enter().append("svg:g").attr("class","slice").on("mouseover",function(a,b){d3.select(this).classed("hover",!0),o.tooltipShow({label:a.data[f],value:a.data[g],data:a.data,index:b,pos:[d3.event.pageX,d3.event.pageY],id:h})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),o.tooltipHide({label:a.data[f],value:a.data[g],data:a.data,index:b,id:h})}).on("click",function(a,b){o.elementClick({label:a.data[f],value:a.data[g],data:a.data,index:b,pos:d3.event,id:h}),d3.event.stopPropagation()}).on("dblclick",function(a,b){o.elementDblClick({label:a.data[f],value:a.data[g],data:a.data,index:b,pos:d3.event,id:h}),d3.event.stopPropagation()}),x=w.append("svg:path").attr("class","path").attr("fill",function(a,b){return i(b)});v.select(".path").attr("d",t).transition().ease("bounce").duration(d).attrTween("d",z),j&&(w.append("text"),v.select("text").transition().duration(d).ease("bounce").attr("transform",function(a){a.outerRadius=e+10,a.innerRadius=e+15;return"translate("+t.centroid(a)+")"}).attr("text-anchor","middle").style("font","bold 12px Arial").text(function(a,b){return a.data[f]}))});return p}var a={top:20,right:20,bottom:20,left:20},b=500,c=500,d=2e3,e=Math.min(b-(a.right+a.left),c-(a.top+a.bottom))/2,f="label",g="y",h=Math.floor(Math.random()*1e4),i=d3.scale.category20(),j=!0,k=!1,l="",m=0,n=0,o=d3.dispatch("chartClick","elementClick","elementDblClick","tooltipShow","tooltipHide");p.margin=function(b){if(!arguments.length)return a;a=b;return p},p.width=function(d){if(!arguments.length)return b;a.left+a.right+20>d?b=a.left+a.right+20:b=d,e=Math.min(b-(a.left+a.right),c-(a.top+a.bottom))/2;return p},p.height=function(d){if(!arguments.length)return c;a.top+a.bottom+20>d?c=a.top+a.bottom+20:c=d,e=Math.min(b-(a.left+a.right),c-(a.top+a.bottom))/2;return p},p.animate=function(a){if(!arguments.length)return d;d=a;return p},p.labelField=function(a){if(!arguments.length)return f;f=a;return p},p.dataField=function(a){if(!arguments.length)return g;g=a;return p},p.showLabels=function(a){if(!arguments.length)return j;j=a;return p},p.donut=function(a){if(!arguments.length)return k;k=a;return p},p.title=function(a){if(!arguments.length)return l;l=a;return p},p.id=function(a){if(!arguments.length)return h;h=a;return p},p.dispatch=o;return p},a.models.scatter=function(){function B(C){C.each(function(B){function L(){if(!p)return!1;J.append("g").attr("class","point-paths");var b=d3.merge(B.map(function(a,b){return a.values.map(function(a,c){return[g(j(a,c))*(Math.random()/1e12+1),h(k(a,c))*(Math.random()/1e12+1),b,c]})}));if(r){I.append("clipPath").attr("id","points-clip-"+f);var c=G.select("#points-clip-"+f).selectAll("circle").data(b);c.enter().append("circle").attr("r",s),c.exit().remove(),c.attr("cx",function(a){return a[0]}).attr("cy",function(a){return a[1]}),G.select(".point-paths").attr("clip-path","url(#points-clip-"+f+")")}var d=d3.geom.voronoi(b).map(function(a,c){return{data:a,series:b[c][2],point:b[c][3]}}),e=G.select(".point-paths").selectAll("path").data(d);e.enter().append("path").attr("class",function(a,b){return"path-"+b}),e.exit().remove(),e.attr("d",function(a){return"M"+a.data.join(",")+"Z"}).on("click",function(b){var c=B[b.series],d=c.values[b.point];w.elementClick({point:d,series:c,pos:[g(j(d,b.point))+a.left,h(k(d,b.point))+a.top],seriesIndex:b.series,pointIndex:b.point})}).on("mouseover",function(b){var c=B[b.series],d=c.values[b.point];w.elementMouseover({point:d,series:c,pos:[g(j(d,b.point))+a.left,h(k(d,b.point))+a.top],seriesIndex:b.series,pointIndex:b.point})}).on("mouseout",function(a,b){w.elementMouseout({point:B[a.series].values[a.point],series:B[a.series],seriesIndex:a.series,pointIndex:a.point})}),w.on("elementMouseover.point",function(a){d3.select(".chart-"+f+" .series-"+a.seriesIndex+" .point-"+a.pointIndex).classed("hover",!0)}),w.on("elementMouseout.point",function(a){d3.select(".chart-"+f+" .series-"+a.seriesIndex+" .point-"+a.pointIndex).classed("hover",!1)})}var C=b-a.left-a.right,D=c-a.top-a.bottom,E=d3.select(this);x=x||g,y=y||h,z=z||i,B=B.map(function(a,b){a.values=a.values.map(function(a){a.series=b;return a});return a});var F=t&&u&&v?[]:B.map(function(a){return a.values.map(function(a,b){return{x:j(a,b),y:k(a,b),size:l(a,b)}})});g.domain(t||d3.extent(d3.merge(F).map(function(a){return a.x}).concat(m))).range([0,C]),h.domain(u||d3.extent(d3.merge(F).map(function(a){return a.y}).concat(n))).range([D,0]),i.domain(v||d3.extent(d3.merge(F).map(function(a){return a.size}).concat(o))).range([16,256]);var G=E.selectAll("g.wrap.scatter").data([B]),H=G.enter().append("g").attr("class","wrap nvd3 scatter chart-"+f),I=H.append("defs"),J=H.append("g"),K=G.select("g");J.append("g").attr("class","groups"),G.attr("transform","translate("+a.left+","+a.top+")"),I.append("clipPath").attr("id","edge-clip-"+f).append("rect"),G.select("#edge-clip-"+f+" rect").attr("width",C).attr("height",D),K.attr("clip-path",q?"url(#edge-clip-"+f+")":"");var M=G.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});M.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(M.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),M.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}),d3.transition(M).style("fill",function(a,b){return d[b%d.length]}).style("stroke",function(a,b){return d[b%d.length]}).style("stroke-opacity",1).style("fill-opacity",.5);var N=M.selectAll("path.point").data(function(a){return a.values});N.enter().append("path").attr("transform",function(a,b){return"translate("+x(j(a,b))+","+y(k(a,b))+")"}).attr("d",d3.svg.symbol().type(function(a,b){return a.shape||e}).size(function(a,b){return i(l(a,b))})),d3.transition(M.exit().selectAll("path.point")).attr("transform",function(a,b){return"translate("+g(j(a,b))+","+h(k(a,b))+")"}).remove(),N.attr("class",function(a,b){return"point point-"+b}),d3.transition(N).attr("transform",function(a,b){return"translate("+g(j(a,b))+","+h(k(a,b))+")"}).attr("d",d3.svg.symbol().type(function(a,b){return a.shape||e}).size(function(a,b){return i(l(a,b))})),clearTimeout(A),A=setTimeout(L,750),x=g.copy(),y=h.copy(),z=i.copy()});return B}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=d3.scale.category20().range(),e="circle",f=Math.floor(Math.random()*1e5),g=d3.scale.linear(),h=d3.scale.linear(),i=d3.scale.linear(),j=function(a){return a.x},k=function(a){return a.y},l=function(a){return a.size},m=[],n=[],o=[],p=!0,q=!1,r=!0,s=function(){return 25},t,u,v,w=d3.dispatch("elementClick","elementMouseover","elementMouseout"),x,y,z,A;B.dispatch=w,B.x=function(a){if(!arguments.length)return j;j=d3.functor(a);return B},B.y=function(a){if(!arguments.length)return k;k=d3.functor(a);return B},B.size=function(a){if(!arguments.length)return l;l=d3.functor(a);return B},B.margin=function(b){if(!arguments.length)return a;a=b;return B},B.width=function(a){if(!arguments.length)return b;b=a;return B},B.height=function(a){if(!arguments.length)return c;c=a;return B},B.xScale=function(a){if(!arguments.length)return g;g=a;return B},B.yScale=function(a){if(!arguments.length)return h;h=a;return B},B.zScale=function(a){if(!arguments.length)return i;i=a;return B},B.xDomain=function(a){if(!arguments.length)return t;t=a;return B},B.yDomain=function(a){if(!arguments.length)return u;u=a;return B},B.sizeDomain=function(a){if(!arguments.length)return v;v=a;return B},B.forceX=function(a){if(!arguments.length)return m;m=a;return B},B.forceY=function(a){if(!arguments.length)return n;n=a;return B},B.forceSize=function(a){if(!arguments.length)return o;o=a;return B},B.interactive=function(a){if(!arguments.length)return p;p=a;return B},B.clipEdge=function(a){if(!arguments.length)return q;q=a;return B},B.clipVoronoi=function(a){if(!arguments.length)return r;r=a;return B},B.clipRadius=function(a){if(!arguments.length)return s;s=a;return B},B.color=function(a){if(!arguments.length)return d;d=a;return B},B.shape=function(a){if(!arguments.length)return e;e=a;return B},B.id=function(a){if(!arguments.length)return f;f=a;return B};return B},a.models.scatterChart=function(){function D(f){f.each(function(g){function J(){if(k){H.select(".point-paths").style("pointer-events","all");return!1}H.select(".background").style("pointer-events","all"),H.select(".point-paths").style("pointer-events","none");var a=d3.mouse(this);p.distortion(j).focus(a[0]),q.distortion(j).focus(a[1]),I.call(r),H.select(".x.axis").call(s),H.select(".y.axis").call(t),H.select(".distributionX").datum(g.filter(function(a){return!a.disabled})).call(w),H.select(".distributionY").datum(g.filter(function(a){return!a.disabled})).call(x)}var m=d3.select(this),n=this,o=(c||parseInt(m.style("width"))||960)-b.left-b.right,E=(d||parseInt(m.style("height"))||400)-b.top-b.bottom;z=z||r.xScale(),A=A||r.yScale();var F=m.selectAll("g.wrap.scatterChart").data([g]),G=F.enter().append("g").attr("class","wrap nvd3 scatterChart chart-"+r.id()).append("g");G.append("rect").attr("class","nvd3 background").attr("width",o).attr("height",E),G.append("g").attr("class","x axis"),G.append("g").attr("class","y axis"),G.append("g").attr("class","scatterWrap"),G.append("g").attr("class","distWrap"),G.append("g").attr("class","legendWrap"),G.append("g").attr("class","controlsWrap");var H=F.select("g");h&&(u.width(o/2),F.select(".legendWrap").datum(g).call(u),b.top!=u.height()&&(b.top=u.height(),E=(d||parseInt(m.style("height"))||400)-b.top-b.bottom),F.select(".legendWrap").attr("transform","translate("+o/2+","+ -b.top+")")),i&&(v.width(180).color(["#444"]),H.select(".controlsWrap").datum(C).attr("transform","translate(0,"+ -b.top+")").call(v)),r.width(o).height(E).color(g.map(function(a,b){return a.color||e[b%e.length]}).filter(function(a,b){return!g[b].disabled})),H.attr("transform","translate("+b.left+","+b.top+")");var I=F.select(".scatterWrap").datum(g.filter(function(a){return!a.disabled}));d3.transition(I).call(r),s.ticks(o/100).tickSize(-E,0),H.select(".x.axis").attr("transform","translate(0,"+q.range()[0]+")"),d3.transition(H.select(".x.axis")).call(s),t.ticks(E/36).tickSize(-o,0),d3.transition(H.select(".y.axis")).call(t),w.width(o).color(g.map(function(a,b){return a.color||e[b%e.length]}).filter(function(a,b){return!g[b].disabled})),G.select(".distWrap").append("g").attr("class","distributionX").attr("transform","translate(0,"+q.range()[0]+")"),H.select(".distributionX").datum(g.filter(function(a){return!a.disabled})).call(w),x.width(E).color(g.map(function(a,b){return a.color||e[b%e.length]}).filter(function(a,b){return!g[b].disabled})),G.select(".distWrap").append("g").attr("class","distributionY").attr("transform","translate(-"+x.size()+",0)"),H.select(".distributionY").datum(g.filter(function(a){return!a.disabled})).call(x),H.select(".background").on("mousemove",J),H.select(".background").on("click",function(){k=!k}),v.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,j=a.disabled?0:2.5,H.select(".background").style("pointer-events",a.disabled?"none":"all"),H.select(".point-paths").style("pointer-events",a.disabled?"all":"none"),a.disabled?(p.distortion(j).focus(0),q.distortion(j).focus(0),I.call(r),H.select(".x.axis").call(s),H.select(".y.axis").call(t)):k=!1,f.transition().call(D)}),u.dispatch.on("legendClick",function(a,b,c){a.disabled=!a.disabled,g.filter(function(a){return!a.disabled}).length||g.map(function(a){a.disabled=!1,F.selectAll(".series").classed("disabled",!1);return a}),f.transition().call(D)}),r.dispatch.on("elementMouseover.tooltip",function(a){d3.select(".chart-"+r.id()+" .series-"+a.seriesIndex+" .distx-"+a.pointIndex).attr("y1",a.pos[1]-E),d3.select(".chart-"+r.id()+" .series-"+a.seriesIndex+" .disty-"+a.pointIndex).attr("x2",a.pos[0]+w.size()),a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],y.tooltipShow(a)}),l&&y.on("tooltipShow",function(a){B(a,n.parentNode)}),r.dispatch.on("elementMouseout.tooltip",function(a){y.tooltipHide(a),d3.select(".chart-"+r.id()+" .series-"+a.seriesIndex+" .distx-"+a.pointIndex).attr("y1",0),d3.select(".chart-"+r.id()+" .series-"+a.seriesIndex+" .disty-"+a.pointIndex).attr("x2",x.size())}),l&&y.on("tooltipHide",a.tooltip.cleanup),z=p.copy(),A=q.copy(),D.update=function(){f.transition().call(D)},D.container=this});return D}var b={top:30,right:20,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!1,g=!1,h=!0,i=!0,j=0,k=!1,l=!0,m=function(a,b,c){return""+b+""},n=function(a,b,c){return""+c+""},o=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" at "+b+"

"},p=d3.fisheye.scale(d3.scale.linear).distortion(0),q=d3.fisheye.scale(d3.scale.linear).distortion(0),r=a.models.scatter().xScale(p).yScale(q),s=a.models.axis().orient("bottom").scale(p).tickPadding(10),t=a.models.axis().orient("left").scale(q).tickPadding(10),u=a.models.legend().height(30),v=a.models.legend().height(30),w=a.models.distribution().axis("x").scale(p),x=a.models.distribution().axis("y").scale(q),y=d3.dispatch("tooltipShow","tooltipHide"),z,A,B=function(c,d){var e=c.pos[0]+(d.offsetLeft||0),f=q.range()[0]+b.top+(d.offsetTop||0),g=p.range()[0]+b.left+(d.offsetLeft||0),h=c.pos[1]+(d.offsetTop||0),i=s.tickFormat()(r.x()(c.point)),j=t.tickFormat()(r.y()(c.point)),k=m(c.series.key,i,j,c,D),l=n(c.series.key,i,j,c,D);a.tooltip.show([e,f],k,"n",1),a.tooltip.show([g,h],l,"e",1)},C=[{key:"Magnify",disabled:!0}];D.dispatch=y,D.legend=u,D.xAxis=s,D.yAxis=t,d3.rebind(D,r,"interactive","shape","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius","fisheye","fisheyeRadius"),D.margin=function(a){if(!arguments.length)return b;b=a;return D},D.width=function(a){if(!arguments.length)return c;c=a;return D},D.height=function(a){if(!arguments.length)return d;d=a;return D},D.color=function(a){if(!arguments.length)return e;e=a,u.color(a),w.color(a),x.color(a);return D},D.showDistX=function(a){if(!arguments.length)return f;f=a;return D},D.showDistY=function(a){if(!arguments.length)return g;g=a;return D},D.showControls=function(a){if(!arguments.length)return i;i=a;return D},D.showLegend=function(a){if(!arguments.length)return h;h=a;return D},D.fisheye=function(a){if(!arguments.length)return j;j=a;return D},D.tooltips=function(a){if(!arguments.length)return l;l=a;return D},D.tooltipContent=function(a){if(!arguments.length)return o;o=a;return D};return D},a.models.sparkline=function(){function l(d){d.each(function(d){var l=b-a.left-a.right,m=c-a.top-a.bottom;j.domain(h||d3.extent(d,e)).range([0,l]),k.domain(i||d3.extent(d,f)).range([m,0]);var n=d3.select(this).selectAll("g.sparkline").data([d]),o=n.enter().append("g").attr("class","nvd3 sparkline");o.attr("transform","translate("+a.left+","+a.top+")").style("stroke",function(a,b){return a.color||g[b*g.length]});var p=o.selectAll("path").data(function(a){return[a]});p.enter().append("path"),p.exit().remove(),p.attr("d",d3.svg.line().x(function(a,b){return j(e(a,b))}).y(function(a,b){return k(f(a,b))}));var q=o.selectAll("circle.point").data(function(a){return a.filter(function(a,b){return k.domain().indexOf(f(a,b))!=-1||e(a,b)==j.domain()[1]})});q.enter().append("circle").attr("class","point"),q.exit().remove(),q.attr("cx",function(a,b){return j(e(a,b))}).attr("cy",function(a,b){return k(f(a,b))}).attr("r",2).style("stroke",function(a,b){return a.x==j.domain()[1]?"#444":a.y==k.domain()[0]?"#d62728":"#2ca02c"}).style("fill",function(a,b){return a.x==j.domain()[1]?"#444":a.y==k.domain()[0]?"#d62728":"#2ca02c"})});return l}var a={top:0,right:0,bottom:0,left:0},b=400,c=32,d=!0,e=function(a){return a.x},f=function(a){return a.y},g=d3.scale.category20().range(),h,i,j=d3.scale.linear(),k=d3.scale.linear();l.margin=function(b){if(!arguments.length)return a;a=b;return l},l.width=function(a){if(!arguments.length)return b;b=a;return l},l.height=function(a){if(!arguments.length)return c;c=a;return l},l.x=function(a){if(!arguments.length)return e;e=d3.functor(a);return l},l.y=function(a){if(!arguments.length)return f;f=d3.functor(a);return l},l.xDomain=function(a){if(!arguments.length)return h;h=a;return l},l.yDomain=function(a){if(!arguments.length)return i;i=a;return l},l.animate=function(a){if(!arguments.length)return d;d=a;return l};return l},a.models.sparklinePlus=function(){function o(a){a.each(function(a){function w(){var c=d3.event.offsetX-b.left;t.attr("x1",c).attr("x2",c),u.attr("transform",function(a){return"translate("+(c-6)+","+ -b.top+")"}).text(j(Math.round(l.invert(c)))),v.attr("transform",function(a){return"translate("+(c+6)+","+ -b.top+")"}).text(k(g(a[Math.round(l.invert(c))])))}var e=c-b.left-b.right,i=d-b.top-b.bottom;l.domain(d3.extent(a,f)).range([0,e]),m.domain(d3.extent(a,g)).range([i,0]);var o=d3.select(this).selectAll("g.sparklineplus").data([a]),p=o.enter().append("g"),q=p.append("g").attr("class","nvd3 sparklineplus").attr("transform","translate("+b.left+","+b.top+")").style("stroke",function(a,b){return a.color||h[b%h.length]});n.xDomain(l.domain()).yDomain(m.domain()),q.call(n);var r=q.append("g").attr("class","hoverValue"),s=q.append("g").attr("class","hoverArea");r.attr("transform",function(a){return"translate("+l(a)+",0)"});var t=r.append("line").attr("x1",l.range()[1]).attr("y1",-b.top).attr("x2",l.range()[1]).attr("y2",d),u=r.append("text").attr("class","xValue").attr("text-anchor","end").attr("dy",".9em"),v=r.append("text").attr("class","yValue").attr("text-anchor","start").attr("dy",".9em");s.append("rect").attr("width",e).attr("height",i).on("mousemove",w)});return o}var b={top:15,right:40,bottom:3,left:40},c=400,d=50,e=!0,f=function(a){return a.x},g=function(a){return a.y},h=d3.scale.category20().range(),i=Math.floor(Math.random()*1e5),j=d3.format(",r"),k=d3.format(",.2f"),l=d3.scale.linear(),m=d3.scale.linear(),n=a.models.sparkline();o.margin=function(a){if(!arguments.length)return b;b=a;return o},o.width=function(a){if(!arguments.length)return c;c=a,n.width(a-b.left-b.right);return o},o.height=function(a){if(!arguments.length)return d;d=a,n.height(a-b.top-b.bottom);return o},o.x=function(a){if(!arguments.length)return f;f=d3.functor(a),n.x(a);return o},o.y=function(a){if(!arguments.length)return g;g=d3.functor(a),n.y(a);return o},o.id=function(a){if(!arguments.length)return i;i=a;return o},o.animate=function(a){if(!arguments.length)return e;e=a;return o};return o},a.models.stackedArea=function(){function r(a){a.each(function(a){var i=c-b.left-b.right,m=d-b.top-b.bottom;a=a.map(function(a,b){a.values=a.values.map(function(b,c){b.index=c,b.stackedY=a.disabled?0:h(b,c);return b});return a}),a=d3.layout.stack().order(k).offset(j).values(function(a){return a.values}).x(g).y(function(a){return a.stackedY}).out(function(a,b,c){a.display={y:c,y0:b}})(a);var r=d3.select(this).selectAll("g.wrap.stackedarea").data([a]),s=r.enter().append("g").attr("class","wrap nvd3 stackedarea"),t=s.append("defs"),u=s.append("g"),v=r.select("g");u.append("g").attr("class","areaWrap"),n.width(i).height(m).x(g).y(function(a){return a.display.y+a.display.y0}).forceY([0]).color(a.map(function(a,b){return a.color||e[b%e.length]}).filter(function(b,c){return!a[c].disabled})),u.append("g").attr("class","scatterWrap");var w=v.select(".scatterWrap").datum(a.filter(function(a){return!a.disabled}));d3.transition(w).call(n),r.attr("transform","translate("+b.left+","+b.top+")"),t.append("clipPath").attr("id","edge-clip-"+f).append("rect"),r.select("#edge-clip-"+f+" rect").attr("width",i).attr("height",m),v.attr("clip-path",l?"url(#edge-clip-"+f+")":"");var z=d3.svg.area().x(function(a,b){return o(g(a,b))}).y0(function(a){return p(a.display.y0)}).y1(function(a){return p(a.display.y+a.display.y0)}),A=d3.svg.area().x(function(a,b){return o(g(a,b))}).y0(function(a){return p(a.display.y0)}).y1(function(a){return p(a.display.y0)}),B=v.select(".areaWrap").selectAll("path.area").data(function(a){return a});B.enter().append("path").attr("class",function(a,b){return"area area-"+b}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),q.areaMouseover({point:a,series:a.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:b})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),q.areaMouseout({point:a,series:a.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:b})}).on("click",function(a,b){d3.select(this).classed("hover",!1),q.areaClick({point:a,series:a.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:b})}),d3.transition(B.exit()).attr("d",function(a,b){return A(a.values,b)}).remove(),B.style("fill",function(a,b){return a.color||e[b%e.length]}).style("stroke",function(a,b){return a.color||e[b%e.length]}),d3.transition(B).attr("d",function(a,b){return z(a.values,b)}),n.dispatch.on("elementClick.area",function(a){q.areaClick(a)}),n.dispatch.on("elementMouseover.area",function(a){v.select(".area-"+a.seriesIndex).classed("hover",!0)}),n.dispatch.on("elementMouseout.area",function(a){v.select(".area-"+a.seriesIndex).classed("hover",!1)})});return r}var b={top:0,right:0,bottom:0,left:0},c=960,d=500,e=d3.scale.category20().range(),f=Math.floor(Math.random()*1e5),g=function(a){return a.x},h=function(a){return a.y},i="stack",j="zero",k="default",l=!1,m=d3.layout.stack().values(function(a){return a.values}).x(g).y(function(a){return a.stackedY}).out(function(a,b,c){a.display={y:c,y0:b}}),n=a.models.scatter().size(2.2).sizeDomain([2.5]),o=n.xScale(),p=n.yScale(),q=d3.dispatch("tooltipShow","tooltipHide","areaClick","areaMouseover","areaMouseout");r.dispatch=q,r.scatter=n,d3.rebind(r,n,"interactive","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius"),r.x=function(a){if(!arguments.length)return g;g=d3.functor(a);return r},r.y=function(a){if(!arguments.length)return h;h=d3.functor(a);return r},r.margin=function(a){if(!arguments.length)return b;b=a;return r},r.width=function(a){if(!arguments.length)return c;c=a;return r},r.height=function(a){if(!arguments.length)return d;d=a;return r},r.clipEdge=function(a){if(!arguments.length)return l;l=a;return r},r.color=function(a){if(!arguments.length)return e;e=a;return r},r.offset=function(a){if(!arguments.length)return j;j=a;return r},r.order=function(a){if(!arguments.length)return k;k=a;return r},r.style=function(a){if(!arguments.length)return i;i=a;switch(i){case"stack":r.offset("zero"),r.order("default");break;case"stream":r.offset("wiggle"),r.order("inside-out");break;case"expand":r.offset("expand"),r.order("default")}return r},n.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],q.tooltipShow(a)}),n.dispatch.on("elementMouseout.tooltip",function(a){q.tooltipHide(a)});return r},a.models.stackedAreaChart=function(){function t(e){e.each(function(i){var k=d3.select(this),l=this,u=(c||parseInt(k.style("width"))||960)-b.left-b.right,v=(d||parseInt(k.style("height"))||400)-b.top-b.bottom,w=k.selectAll("g.wrap.stackedAreaChart").data([i]),x=w.enter().append("g").attr("class","wrap nvd3 stackedAreaChart").append("g");x.append("g").attr("class","x axis"),x.append("g").attr("class","y axis"),x.append("g").attr("class","stackedWrap"),x.append("g").attr("class","legendWrap"),x.append("g").attr("class","controlsWrap");var y=w.select("g");g&&(o.width(u/2),y.select(".legendWrap").datum(i).call(o),b.top!=o.height()&&(b.top=o.height(),v=(d||parseInt(k.style("height"))||400)-b.top-b.bottom),y.select(".legendWrap").attr("transform","translate("+(u/2-b.left)+","+ -b.top+")")),j.width(u).height(v),f&&(p.width(280).color(["#444","#444","#444"]),y.select(".controlsWrap").datum(r).attr("transform","translate(0,"+ -b.top+")").call(p)),y.attr("transform","translate("+b.left+","+b.top+")");var z=y.select(".stackedWrap").datum(i);d3.transition(z).call(j),m.ticks(u/100).tickSize(-v,0),y.select(".x.axis").attr("transform","translate(0,"+v+")"),d3.transition(y.select(".x.axis")).call(m),n.ticks(j.offset()=="wiggle"?0:v/36).tickSize(-u,0).tickFormat(j.offset()=="expand"?d3.format("%"):d3.format(",.2f")),d3.transition(y.select(".y.axis")).call(n),j.dispatch.on("areaClick.toggle",function(a){i.filter(function(a){return!a.disabled}).length===1?i=i.map(function(a){a.disabled=!1;return a}):i=i.map(function(b,c){b.disabled=c!=a.seriesIndex;return b}),e.transition().call(t)}),o.dispatch.on("legendClick",function(a,b){a.disabled=!a.disabled,i.filter(function(a){return!a.disabled}).length||i.map(function(a){a.disabled=!1;return a}),e.transition().call(t)}),p.dispatch.on("legendClick",function(a,b){if(!!a.disabled){r=r.map(function(a){a.disabled=!0;return a}),a.disabled=!1;switch(a.key){case"Stacked":j.style("stack");break;case"Stream":j.style("stream");break;case"Expanded":j.style("expand")}e.transition().call(t)}}),j.dispatch.on("tooltipShow",function(a){if(!Math.round(j.y()(a.point)*100)){setTimeout(function(){d3.selectAll(".point.hover").classed("hover",!1)},0);return!1}a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],q.tooltipShow(a)}),h&&q.on("tooltipShow",function(a){s(a,l.parentNode)}),j.dispatch.on("tooltipHide",function(a){q.tooltipHide(a)}),h&&q.on("tooltipHide",a.tooltip.cleanup),t.update=function(){e.transition().call(t)},t.container=this});return t}var b={top:30,right:25,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!0,g=!0,h=!0,i=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" on "+b+"

"},j=a.models.stackedArea(),k=j.xScale(),l=j.yScale(),m=a.models.axis().scale(k).orient("bottom").tickPadding(5),n=a.models.axis().scale(l).orient("left"),o=a.models.legend().height(30),p=a.models.legend().height(30),q=d3.dispatch("tooltipShow","tooltipHide"),r=[{key:"Stacked"},{key:"Stream",disabled:!0},{key:"Expanded",disabled:!0}],s=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=m.tickFormat()(j.x()(b.point)),g=n.tickFormat()(j.y()(b.point)),h=i(b.series.key,f,g,b,t);a.tooltip.show([d,e],h,b.value<0?"n":"s")};t.dispatch=q,t.stacked=j,t.xAxis=m,t.yAxis=n,d3.rebind(t,j,"x","y","interactive","offset","order","style","clipEdge","size","forceX","forceY","forceSize"),t.margin=function(a){if(!arguments.length)return b;b=a;return t},t.width=function(a){if(!arguments.length)return getWidth;c=a;return t},t.height=function(a){if(!arguments -.length)return getHeight;d=a;return t},t.color=function(a){if(!arguments.length)return e;e=a,o.color(a);return t},t.showControls=function(a){if(!arguments.length)return f;f=a;return t},t.showLegend=function(a){if(!arguments.length)return g;g=a;return t},t.tooltips=function(a){if(!arguments.length)return h;h=a;return t},t.tooltipContent=function(a){if(!arguments.length)return i;i=a;return t};return t}})() \ No newline at end of file +(function(){function t(e,t){return(new Date(t,e+1,0)).getDate()}function n(e,t,n){return function(r,i,s){var o=e(r),u=[];o1)while(op+h&&(m=p-f-5);break;case"w":v=n[0]+s,m=n[1]-f/2,v+l>c&&(v=n[0]-l-s),mp+h&&(m=p-f-5);break;case"n":v=n[0]-l/2,m=n[1]+s,vc&&(v=c-l-5),m+f>p+h&&(m=n[1]-f-s);break;case"s":v=n[0]-l/2,m=n[1]-f-s,vc&&(v=c-l-5),p>m&&(m=n[1]+20)}return u.style.left=v+"px",u.style.top=m+"px",u.style.opacity=1,u},t.cleanup=function(){var e=document.getElementsByClassName("nvtooltip"),t=[];while(e.length)t.push(e[0]),e[0].style.transitionDelay="0 !important",e[0].style.opacity=0,e[0].className="nvtooltip-pending-removal";setTimeout(function(){while(t.length){var e=t.pop();e.parentNode.removeChild(e)}},500)}}(),e.utils.windowSize=function(){var e={width:640,height:480};return document.body&&document.body.offsetWidth&&(e.width=document.body.offsetWidth,e.height=document.body.offsetHeight),document.compatMode=="CSS1Compat"&&document.documentElement&&document.documentElement.offsetWidth&&(e.width=document.documentElement.offsetWidth,e.height=document.documentElement.offsetHeight),window.innerWidth&&window.innerHeight&&(e.width=window.innerWidth,e.height=window.innerHeight),e},e.utils.windowResize=function(e){var t=window.onresize;window.onresize=function(n){typeof t=="function"&&t(n),e(n)}},e.models.axis=function(){function o(u){return u.each(function(o){var u=d3.select(this),a=u.selectAll("g.wrap.axis").data([o]),f=a.enter().append("g").attr("class","wrap axis"),l=f.append("g"),c=a.select("g");(i.orient()=="top"||i.orient()=="bottom")&&i.ticks(Math.abs(e.range()[1]-e.range()[0])/100),d3.transition(c).call(i),s=s||i.scale();var h=c.selectAll("text.axislabel").data([t||null]);h.exit().remove();switch(i.orient()){case"top":h.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",0),h.attr("x",e.range()[1]/2);if(n){var p=a.selectAll("g.axisMaxMin").data(e.domain());p.enter().append("g").attr("class","axisMaxMin").append("text"),p.exit().remove(),p.attr("transform",function(t,n){return"translate("+e(t)+",0)"}).select("text").attr("dy","0em").attr("y",-i.tickPadding()).attr("text-anchor","middle").text(function(e,t){return i.tickFormat()(e)}),d3.transition(p).attr("transform",function(t,n){return"translate("+e.range()[n]+",0)"})}break;case"bottom":h.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",25),h.attr("x",e.range()[1]/2);if(n){var p=a.selectAll("g.axisMaxMin").data(e.domain());p.enter().append("g").attr("class","axisMaxMin").append("text"),p.exit().remove(),p.attr("transform",function(t,n){return"translate("+e(t)+",0)"}).select("text").attr("dy",".71em").attr("y",i.tickPadding()).attr("text-anchor","middle").text(function(e,t){return i.tickFormat()(e)}),d3.transition(p).attr("transform",function(t,n){return"translate("+e.range()[n]+",0)"})}break;case"right":h.enter().append("text").attr("class","axislabel").attr("transform","rotate(90)").attr("y",-40),h.attr("x",-e.range()[0]/2);if(n){var p=a.selectAll("g.axisMaxMin").data(e.domain());p.enter().append("g").attr("class","axisMaxMin").append("text").style("opacity",0),p.exit().remove(),p.attr("transform",function(t,n){return"translate(0,"+e(t)+")"}).select("text").attr("dy",".32em").attr("dx",i.tickPadding()).attr("text-anchor","start").text(function(e,t){return i.tickFormat()(e)}),d3.transition(p).attr("transform",function(t,n){return"translate(0,"+e.range()[n]+")"}).select("text").style("opacity",1)}break;case"left":h.enter().append("text").attr("class","axislabel").attr("transform","rotate(-90)").attr("y",-40),h.attr("x",-e.range()[0]/2);if(n){var p=a.selectAll("g.axisMaxMin").data(e.domain());p.enter().append("g").attr("class","axisMaxMin").append("text").style("opacity",0),p.exit().remove(),p.attr("transform",function(e,t){return"translate(0,"+s(e)+")"}).select("text").attr("dy",".32em").attr("dx",-i.tickPadding()).attr("text-anchor","end").text(function(e,t){return i.tickFormat()(e)}),d3.transition(p).attr("transform",function(t,n){return"translate(0,"+e.range()[n]+")"}).select("text").style("opacity",1)}}h.text(function(e){return e}),n&&(i.orient()==="left"||i.orient()==="right")&&c.selectAll("g").filter(function(t,n){return t&&(e(t)<8||e(t)>e.range()[0]-8)}).remove();if(n&&(i.orient()==="top"||i.orient()==="bottom")){var d=[];a.selectAll("g.axisMaxMin").each(function(t,n){n?d.push(e(t)-this.getBBox().width-4):d.push(e(t)+this.getBBox().width+4)}),c.selectAll("g").filter(function(t,n){return t&&(e(t)d[1])}).remove()}r&&c.selectAll("line.tick").filter(function(e){return!parseFloat(Math.round(e*1e5)/1e6)}).classed("zero",!0),s=e.copy()}),o}var e=d3.scale.linear(),t=null,n=!0,r=!0,i=d3.svg.axis().scale(e).orient("bottom").tickFormat(function(e){return e}),s;return d3.rebind(o,i,"orient","ticks","tickValues","tickSubdivide","tickSize","tickPadding","tickFormat"),d3.rebind(o,e,"domain","range","rangeBand","rangeBands"),o.axisLabel=function(e){return arguments.length?(t=e,o):t},o.showMaxMin=function(e){return arguments.length?(n=e,o):n},o.highlightZero=function(e){return arguments.length?(r=e,o):r},o.scale=function(t){return arguments.length?(e=t,i.scale(e),d3.rebind(o,e,"domain","range","rangeBand","rangeBands"),o):e},o},e.models.historicalBar=function(){function g(o){return o.each(function(o){var u=t-e.left-e.right,d=n-e.top-e.bottom;h.domain(l||d3.extent(o[0].values,i)).range([0,u]),p.domain(c||d3.extent(o[0].values,s)).range([d,0]);var v=d3.select(this).on("click",function(e,t){m.chartClick({data:e,index:t,pos:d3.event,id:r})}),g=d3.select(this).selectAll("g.wrap.bar").data([o[0].values]),b=g.enter().append("g").attr("class","wrap nvd3 bar"),w=b.append("g");w.append("g").attr("class","bars"),g.attr("width",t).attr("height",n);var E=g.select("g").attr("transform","translate("+e.left+","+e.top+")");b.append("defs").append("clipPath").attr("id","chart-clip-path-"+r).append("rect"),g.select("#chart-clip-path-"+r+" rect").attr("width",u).attr("height",d),w.attr("clip-path",a?"url(#chart-clip-path-"+r+")":"");var S=w.append("g").attr("class","shiftWrap"),T=g.select(".bars").selectAll(".bar").data(function(e){return e});T.exit().remove();var N=T.enter().append("svg:rect").attr("class",function(e,t){return s(e,t)<0?"bar negative":"bar positive"}).attr("fill",function(e,t){return f[0]}).attr("x",0).attr("y",function(e,t){return p(Math.max(0,s(e,t)))}).attr("height",function(e,t){return Math.abs(p(s(e,t))-p(0))}).on("mouseover",function(e,t){d3.select(this).classed("hover",!0),m.elementMouseover({point:e,series:o[0],pos:[h(i(e,t)),p(s(e,t))],pointIndex:t,seriesIndex:0,e:d3.event})}).on("mouseout",function(e,t){d3.select(this).classed("hover",!1),m.elementMouseout({point:e,series:o[0],pointIndex:t,seriesIndex:0,e:d3.event})}).on("click",function(e,t){m.elementClick({value:s(e,t),data:e,index:t,pos:[h(i(e,t)),p(s(e,t))],e:d3.event,id:r}),d3.event.stopPropagation()}).on("dblclick",function(e,t){m.elementDblClick({value:s(e,t),data:e,index:t,pos:[h(i(e,t)),p(s(e,t))],e:d3.event,id:r}),d3.event.stopPropagation()});T.attr("class",function(e,t){return s(e,t)<0?"bar negative":"bar positive"}).attr("transform",function(e,t){return"translate("+(h(i(e,t))-h(.5))+",0)"}).attr("width",h(.9)),d3.transition(T).attr("y",function(e,t){return p(Math.max(0,s(e,t)))}).attr("height",function(e,t){return Math.abs(p(s(e,t))-p(0))})}),g}var e={top:0,right:0,bottom:0,left:0},t=960,n=500,r=Math.floor(Math.random()*1e4),i=function(e){return e.x},s=function(e){return e.y},o=[],u=[],a=!0,f=d3.scale.category20().range(),l,c,h=d3.scale.linear(),p=d3.scale.linear(),d=d3.svg.axis().scale(h).orient("bottom"),v=d3.svg.axis().scale(p).orient("left"),m=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return g.dispatch=m,g.x=function(e){return arguments.length?(i=e,g):i},g.y=function(e){return arguments.length?(s=e,g):s},g.margin=function(t){return arguments.length?(e=t,g):e},g.width=function(e){return arguments.length?(t=e,g):t},g.height=function(e){return arguments.length?(n=e,g):n},g.xScale=function(e){return arguments.length?(h=e,g):h},g.yScale=function(e){return arguments.length?(p=e,g):p},g.xDomain=function(e){return arguments.length?(l=e,g):l},g.yDomain=function(e){return arguments.length?(c=e,g):c},g.forceX=function(e){return arguments.length?(o=e,g):o},g.forceY=function(e){return arguments.length?(u=e,g):u},g.clipEdge=function(e){return arguments.length?(a=e,g):a},g.color=function(e){return arguments.length?(f=e,g):f},g.id=function(e){return arguments.length?(r=e,g):r},g},e.models.bullet=function(){function l(e){e.each(function(e,l){var c=r.call(this,e,l).slice().sort(d3.descending),h=i.call(this,e,l).slice().sort(d3.descending),p=s.call(this,e,l).slice().sort(d3.descending),d=d3.select(this),v=d3.scale.linear().domain([0,Math.max(c[0],h[0],p[0])]).range(t?[o,0]:[0,o]),m=this.__chart__||d3.scale.linear().domain([0,Infinity]).range(v.range());this.__chart__=v;var g=function(e){return Math.abs(m(e)-m(0))},y=function(e){return Math.abs(v(e)-v(0))},b=d.selectAll("rect.range").data(c);b.enter().append("rect").attr("class",function(e,t){return"range s"+t}).attr("width",g).attr("height",u).attr("x",t?m:0).on("mouseover",function(e,t){f.elementMouseover({value:e,label:t<=0?"Maximum":t>1?"Minimum":"Mean",pos:[v(e),u/2]})}).on("mouseout",function(e,t){f.elementMouseout({value:e,label:t<=0?"Minimum":t>=1?"Maximum":"Mean"})}).transition().duration(n).attr("width",y).attr("x",t?v:0),b.transition().duration(n).attr("x",t?v:0).attr("width",y).attr("height",u);var w=d.selectAll("rect.measure").data(p);w.enter().append("rect").attr("class",function(e,t){return"measure s"+t}).attr("width",g).attr("height",u/3).attr("x",t?m:0).attr("y",u/3).on("mouseover",function(e){f.elementMouseover({value:e,label:"Current",pos:[v(e),u/2]})}).on("mouseout",function(e){f.elementMouseout({value:e,label:"Current"})}).transition().duration(n).attr("width",y).attr("x",t?v:0),w.transition().duration(n).attr("width",y).attr("height",u/3).attr("x",t?v:0).attr("y",u/3);var E=d.selectAll("path.markerTriangle").data(h),S=u/6;E.enter().append("path").attr("class","markerTriangle").attr("transform",function(e){return"translate("+m(e)+","+u/2+")"}).attr("d","M0,"+S+"L"+S+","+ -S+" "+ -S+","+ -S+"Z").on("mouseover",function(e,t){f.elementMouseover({value:e,label:"Previous",pos:[v(e),u/2]})}).on("mouseout",function(e,t){f.elementMouseout({value:e,label:"Previous"})}),E.transition().duration(n).attr("transform",function(e){return"translate("+v(e)+","+u/2+")"}),E.exit().remove();var x=a||v.tickFormat(8),T=d.selectAll("g.tick").data(v.ticks(8),function(e){return this.textContent||x(e)}),N=T.enter().append("g").attr("class","tick").attr("transform",function(e){return"translate("+m(e)+",0)"}).style("opacity",1e-6);N.append("line").attr("y1",u).attr("y2",u*7/6),N.append("text").attr("text-anchor","middle").attr("dy","1em").attr("y",u*7/6).text(x),N.transition().duration(n).attr("transform",function(e){return"translate("+v(e)+",0)"}).style("opacity",1);var C=T.transition().duration(n).attr("transform",function(e){return"translate("+v(e)+",0)"}).style("opacity",1);C.select("line").attr("y1",u).attr("y2",u*7/6),C.select("text").attr("y",u*7/6),T.exit().transition().duration(n).attr("transform",function(e){return"translate("+v(e)+",0)"}).style("opacity",1e-6).remove()}),d3.timer.flush()}var e="left",t=!1,n=0,r=function(e){return e.ranges},i=function(e){return e.markers},s=function(e){return e.measures},o=380,u=30,a=null,f=d3.dispatch("elementMouseover","elementMouseout");return l.dispatch=f,l.orient=function(n){return arguments.length?(e=n,t=e=="right"||e=="bottom",l):e},l.ranges=function(e){return arguments.length?(r=e,l):r},l.markers=function(e){return arguments.length?(i=e,l):i},l.measures=function(e){return arguments.length?(s=e,l):s},l.width=function(e){return arguments.length?(o=e,l):o},l.height=function(e){return arguments.length?(u=e,l):u},l.tickFormat=function(e){return arguments.length?(a=e,l):a},l.duration=function(e){return arguments.length?(n=e,l):n},l},e.models.cumulativeLine=function(){function x(e,t){}function T(e,t){e.x+=d3.event.dx,e.i=Math.round(h.invert(e.x)),d3.select(this).attr("transform","translate("+h(e.i)+",0)")}function N(e,t){d3.transition(d3.select(".chart-"+a)).call(C)}function C(e){return e.each(function(s){var o=n(),u=r(),x=o-t.left-t.right,T=u-t.top-t.bottom,N=k(w.i,s),L=N.filter(function(e){return!l||!e.disabled}).map(function(e){return e.values});c.domain(d3.extent(d3.merge(L),function(e){return e.x})).range([0,x]),h.domain([0,s[0].values.length-1]).range([0,x]).clamp(!0),p.domain(d3.extent(d3.merge(L),function(e){return e.y})).range([T,0]),y.width(x).height(T).color(s.map(function(e,t){return e.color||i[t%i.length]}).filter(function(e,t){return!s[t].disabled}));var A=d3.select(this).classed("chart-"+a,!0).selectAll("g.wrap").data([N]),O=A.enter().append("g").attr("class","wrap nvd3 cumulativeLine").append("g");O.append("g").attr("class","x axis"),O.append("g").attr("class","y axis"),O.append("g").attr("class","linesWrap"),O.append("g").attr("class","legendWrap"),O.append("g").attr("class","controlsWrap"),t.top=m.height();var M=A.select("g").attr("transform","translate("+t.left+","+t.top+")");m.width(o/2-t.right),M.select(".legendWrap").datum(s).attr("transform","translate("+(o/2-t.left)+","+ -t.top+")").call(m),f&&(g.width(140).color(["#444","#444","#444"]),M.select(".controlsWrap").datum(E).attr("transform","translate(0,"+ -t.top+")").call(g));var _=M.select(".linesWrap").datum(N.filter(function(e){return!e.disabled}));d3.transition(_).call(y);var D=_.selectAll(".indexLine").data([w]);D.enter().append("rect").attr("class","indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).call(S),D.attr("transform",function(e){return"translate("+h(e.i)+",0)"}).attr("height",T),d.domain(c.domain()).range(c.range()).ticks(o/100).tickSize(-T,0),M.select(".x.axis").attr("transform","translate(0,"+p.range()[0]+")"),d3.transition(M.select(".x.axis")).call(d),v.domain(p.domain()).range(p.range()).ticks(u/36).tickSize(-x,0),d3.transition(M.select(".y.axis")).call(v),m.dispatch.on("legendClick",function(t,n){t.disabled=!t.disabled,s.filter(function(e){return!e.disabled}).length||s.map(function(e){return e.disabled=!1,A.selectAll(".series").classed("disabled",!1),e}),e.transition().call(C)}),g.dispatch.on("legendClick",function(t,n){t.disabled=!t.disabled,l=!t.disabled,e.transition().call(C)}),y.dispatch.on("elementMouseover.tooltip",function(e){b.tooltipShow({point:e.point,series:e.series,pos:[e.pos[0]+t.left,e.pos[1]+t.top],seriesIndex:e.seriesIndex,pointIndex:e.pointIndex})}),y.dispatch.on("elementMouseout.tooltip",function(e){b.tooltipHide(e)})}),C}function k(e,t){return t.map(function(t,n){var r=u(t.values[e],e);return{key:t.key,values:t.values.map(function(e,t){return{x:o(e,t),y:(u(e,t)-r)/(1+r)}}),disabled:t.disabled,hover:t.hover}})}var t={top:30,right:20,bottom:30,left:60},n=function(){return 960},r=function(){return 500},i=d3.scale.category20().range(),s=function(){return 2.5},o=function(e){return e.x},u=function(e){return e.y},a=Math.floor(Math.random()*1e4),f=!0,l=!0,c=d3.scale.linear(),h=d3.scale.linear(),p=d3.scale.linear(),d=e.models.axis().scale(c).orient("bottom"),v=e.models.axis().scale(p).orient("left"),m=e.models.legend().height(30),g=e.models.legend().height(30),y=e.models.line(),b=d3.dispatch("tooltipShow","tooltipHide"),w={i:0,x:0},E=[{key:"Re-scale y-axis"}],S=d3.behavior.drag().on("dragstart",x).on("drag",T).on("dragend",N);return C.dispatch=b,C.x=function(e){return arguments.length?(o=e,C):o},C.y=function(e){return arguments.length?(u=e,C):u},C.margin=function(e){return arguments.length?(t=e,C):t},C.width=function(e){return arguments.length?(n=d3.functor(e),C):n},C.height=function(e){return arguments.length?(r=d3.functor(e),C):r},C.color=function(e){return arguments.length?(i=e,m.color(e),C):i},C.dotRadius=function(e){return arguments.length?(s=d3.functor(e),y.dotRadius=e,C):s},C.showRescaleToggle=function(e){return arguments.length?(f=e,C):f},C.xAxis=d,C.yAxis=v,C},e.models.cumulativeLineChart=function(){function T(e,t){}function N(e,t){e.x+=d3.event.dx,e.i=Math.round(p.invert(e.x)),d3.select(this).attr("transform","translate("+p(e.i)+",0)")}function C(e,t){k.update()}function k(u){return u.each(function(T){var N=d3.select(this).classed("chart-"+d,!0),C=this,A=(r||parseInt(N.style("width"))||960)-t.left-t.right,O=(i||parseInt(N.style("height"))||400)-t.top-t.bottom,M=L(w.i,T);p.domain([0,T[0].values.length-1]).range([0,A]).clamp(!0);var _=N.selectAll("g.wrap.cumulativeLine").data([M]),D=_.enter().append("g").attr("class","wrap nvd3 cumulativeLine").append("g");D.append("g").attr("class","x axis"),D.append("g").attr("class","y axis"),D.append("g").attr("class","linesWrap"),D.append("g").attr("class","legendWrap"),D.append("g").attr("class","controlsWrap");var P=_.select("g");s&&(g.width(A),P.select(".legendWrap").datum(T).call(g),t.top!=g.height()&&(t.top=g.height(),O=(i||parseInt(N.style("height"))||400)-t.top-t.bottom),P.select(".legendWrap").attr("transform","translate(0,"+ -t.top+")")),a&&(y.width(140).color(["#444","#444","#444"]),P.select(".controlsWrap").datum(E).attr("transform","translate(0,"+ -t.top+")").call(y)),l.width(A).height(O).color(M.map(function(e,t){return e.color||n[t%n.length]}).filter(function(e,t){return!T[t].disabled})),P.attr("transform","translate("+t.left+","+t.top+")");var H=P.select(".linesWrap").datum(M.filter(function(e){return!e.disabled}));d3.transition(H).call(l);var B=H.selectAll(".indexLine").data([w]);B.enter().append("rect").attr("class","indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).call(x),B.attr("transform",function(e){return"translate("+p(e.i)+",0)"}).attr("height",O),v.scale(c).ticks(A/100).tickSize(-O,0),P.select(".x.axis").attr("transform","translate(0,"+h.range()[0]+")"),d3.transition(P.select(".x.axis")).call(v),m.scale(h).ticks(O/36).tickSize(-A,0),d3.transition(P.select(".y.axis")).call(m),y.dispatch.on("legendClick",function(e,t){e.disabled=!e.disabled,f=!e.disabled,u.transition().call(k)}),g.dispatch.on("legendClick",function(e,t){e.disabled=!e.disabled,T.filter(function(e){return!e.disabled}).length||T.map(function(e){return e.disabled=!1,_.selectAll(".series").classed("disabled",!1),e}),u.transition().call(k)}),l.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],b.tooltipShow(e)}),o&&b.on("tooltipShow",function(e){S(e,C.parentNode)}),l.dispatch.on("elementMouseout.tooltip",function(e){b.tooltipHide(e)}),o&&b.on("tooltipHide",e.tooltip.cleanup)}),k.update=function(){k(u)},k.container=this,k}function L(e,t){return t.map(function(t,n){var r=l.y()(t.values[e],e);return{key:t.key,values:t.values.map(function(e,t){return{x:l.x()(e,t),y:(l.y()(e,t)-r)/(1+r)}}),disabled:t.disabled,hover:t.hover}})}var t={top:30,right:20,bottom:50,left:60},n=d3.scale.category20().range(),r=null,i=null,s=!0,o=!0,u=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},a=!1,f=!0,l=e.models.line(),c=l.xScale(),h=l.yScale(),p=d3.scale.linear(),d=l.id(),v=e.models.axis().scale(c).orient("bottom").tickPadding(5),m=e.models.axis().scale(h).orient("left"),g=e.models.legend().height(30),y=e.models.legend().height(30),b=d3.dispatch("tooltipShow","tooltipHide"),w={i:0,x:0},E=[{key:"Re-scale y-axis"}],S=function(t,n){var r=t.pos[0]+(n.offsetLeft||0),i=t.pos[1]+(n.offsetTop||0),s=v.tickFormat()(l.x()(t.point)),o=m.tickFormat()(l.y()(t.point)),a=u(t.series.key,s,o,t,k);e.tooltip.show([r,i],a)},x=d3.behavior.drag().on("dragstart",T).on("drag",N).on("dragend",C);return k.dispatch=b,k.legend=g,k.xAxis=v,k.yAxis=m,d3.rebind(k,l,"x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),k.margin=function(e){return arguments.length?(t=e,k):t},k.width=function(e){return arguments.length?(r=e,k):r},k.height=function(e){return arguments.length?(i=e,k):i},k.color=function(e){return arguments.length?(n=e,g.color(e),k):n},k.showLegend=function(e){return arguments.length?(s=e,k):s},k.tooltips=function(e){return arguments.length?(o=e,k):o},k.tooltipContent=function(e){return arguments.length?(u=e,k):u},k},e.models.discreteBar=function(){function g(r){return r.each(function(b){var w=t-e.left-e.right,E=n-e.top-e.bottom;b=b.map(function(e,t){return e.values=e.values.map(function(e){return e.series=t,e}),e});var S=h&&p?[]:b.map(function(e){return e.values.map(function(e,t){return{x:o(e,t),y:u(e,t),y0:e.y0}})});i.domain(h||d3.merge(S).map(function(e){return e.x})).rangeBands([0,w],.1),s.domain(p||d3.extent(d3.merge(S).map(function(e){return e.y}).concat(a))),l?s.range([E-(s.domain()[0]<0?12:0),s.domain()[1]<0?0:12]):s.range([E,0]),d=d||i,v=v||d3.scale.linear().domain(s.domain()).range([s(0),s(0)]);var T=d3.select(this).selectAll("g.wrap.discretebar").data([b]),N=T.enter().append("g").attr("class","wrap nvd3 discretebar"),C=N.append("g");C.append("g").attr("class","groups");var k=T.select("g");T.attr("transform","translate("+e.left+","+e.top+")");var L=T.select(".groups").selectAll(".group").data(function(e){return e},function(e){return e.key});L.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(L.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),L.attr("class",function(e,t){return"group series-"+t}).classed("hover",function(e){return e.hover}),d3.transition(L).style("stroke-opacity",1).style("fill-opacity",.75);var A=L.selectAll("g.bar").data(function(e){return e.values});A.exit().remove();var O=A.enter().append("g").attr("transform",function(e,t,n){return"translate("+i(o(e,t))+", "+s(0)+")"}).on("mouseover",function(e,t){d3.select(this).classed("hover",!0),m.elementMouseover({value:u(e,t),point:e,series:b[e.series],pos:[i(o(e,t))+i.rangeBand()*(e.series+.5)/b.length,s(u(e,t))],pointIndex:t,seriesIndex:e.series,e:d3.event})}).on("mouseout",function(e,t){d3.select(this).classed("hover",!1),m.elementMouseout({value:u(e,t),point:e,series:b[e.series],pointIndex:t,seriesIndex:e.series,e:d3.event})}).on("click",function(e,t){m.elementClick({value:u(e,t),point:e,series:b[e.series],pos:[i(o(e,t))+i.rangeBand()*(e.series+.5)/b.length,s(u(e,t))],pointIndex:t,seriesIndex:e.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(e,t){m.elementDblClick({value:u(e,t),point:e,series:b[e.series],pos:[i(o(e,t))+i.rangeBand()*(e.series+.5)/b.length,s(u(e,t))],pointIndex:t,seriesIndex:e.series,e:d3.event}),d3.event.stopPropagation()});O.append("rect").attr("height",0).attr("width",i.rangeBand()/b.length).style("fill",function(e,t){return e.color||f[t%f.length]}).style("stroke",function(e,t){return e.color||f[t%f.length]}),l?(O.append("text").attr("text-anchor","middle"),A.selectAll("text").attr("dx",i.rangeBand()/2).attr("dy",function(e,t){return u(e,t)<0?s(u(e,t))-s(0)+12:-4}).text(function(e,t){return c(u(e,t))})):A.selectAll("text").remove(),A.attr("class",function(e,t){return u(e,t)<0?"bar negative":"bar positive"}).attr("transform",function(e,t){return"translate("+i(o(e,t))+", "+(u(e,t)<0?v(0):v(u(e,t)))+")"}).selectAll("rect").attr("width",i.rangeBand()/b.length),d3.transition(A).attr("transform",function(e,t){return"translate("+i(o(e,t))+", "+(u(e,t)<0?s(0):s(u(e,t)))+")"}).selectAll("rect").attr("height",function(e,t){return Math.abs(s(u(e,t))-s(0))}),g.update=function(){r.transition().call(g)},d=i.copy(),v=s.copy()}),g}var e={top:0,right:0,bottom:0,left:0},t=960,n=500,r=Math.floor(Math.random()*1e4),i=d3.scale.ordinal(),s=d3.scale.linear(),o=function(e){return e.x},u=function(e){return e.y},a=[0],f=d3.scale.category20().range(),l=!1,c=d3.format(",.2f"),h,p,d,v,m=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return g.dispatch=m,g.x=function(e){return arguments.length?(o=e,g):o},g.y=function(e){return arguments.length?(u=e,g):u},g.margin=function(t){return arguments.length?(e=t,g):e},g.width=function(e){return arguments.length?(t=e,g):t},g.height=function(e){return arguments.length?(n=e,g):n},g.xScale=function(e){return arguments.length?(i=e,g):i},g.yScale=function(e){return arguments.length?(s=e,g):s},g.xDomain=function(e){return arguments.length?(h=e,g):h},g.yDomain=function(e){return arguments.length?(p=e,g):p},g.forceY=function(e){return arguments.length?(a=e,g):a},g.color=function(e){return arguments.length?(f=e,g):f},g.id=function(e){return arguments.length?(r=e,g):r},g.showValues=function(e){return arguments.length?(l=e,g):l},g.valuesFormat=function(e){return arguments.length?(c=e,g):c},g},e.models.discreteBarChart=function(){function m(i){return i.each(function(u){var v=d3.select(this),g=this,b=(n||parseInt(v.style("width"))||960)-t.left-t.right,w=(r||parseInt(v.style("height"))||400)-t.top-t.bottom;a.width(b).height(w);var E=v.selectAll("g.wrap.discreteBarWithAxes").data([u]),S=E.enter().append("g").attr("class","wrap nvd3 discreteBarWithAxes").append("g"),T=S.append("defs");S.append("g").attr("class","x axis"),S.append("g").attr("class","y axis"),S.append("g").attr("class","barsWrap");var N=E.select("g");N.attr("transform","translate("+t.left+","+t.top+")");var C=N.select(".barsWrap").datum(u.filter(function(e){return!e.disabled}));d3.transition(C).call(a),T.append("clipPath").attr("id","x-label-clip-"+a.id()).append("rect"),N.select("#x-label-clip-"+a.id()+" rect").attr("width",f.rangeBand()*(s?2:1)).attr("height",16).attr("x",-f.rangeBand()/(s?1:2)),c.ticks(b/100).tickSize(-w,0),N.select(".x.axis").attr("transform","translate(0,"+(l.range()[0]+(a.showValues()?16:0))+")"),N.select(".x.axis").transition().duration(0).call(c);var k=N.select(".x.axis").selectAll("g");s&&k.selectAll("text").attr("transform",function(e,t,n){return"translate(0,"+(n%2==0?"0":"12")+")"}),k.selectAll("text").attr("clip-path",function(e,t,n){return"url(#x-label-clip-"+a.id()+")"}),h.ticks(w/36).tickSize(-b,0),d3.transition(N.select(".y.axis")).call(h),a.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],p.tooltipShow(e)}),o&&p.on("tooltipShow",function(e){d(e,g.parentNode)}),a.dispatch.on("elementMouseout.tooltip",function(e){p.tooltipHide(e)}),o&&p.on("tooltipHide",e.tooltip.cleanup),m.update=function(){i.transition().call(m)},m.container=this}),m}var t={top:30,right:20,bottom:50,left:60},n=null,r=null,i=d3.scale.category20().range(),s=!1,o=!0,u=function(e,t,n,r,i){return"

"+t+"

"+"

"+n+"

"},a=e.models.discreteBar(),f=a.xScale(),l=a.yScale(),c=e.models.axis().scale(f).orient("bottom").highlightZero(!1).showMaxMin(!1),h=e.models.axis().scale(l).orient("left"),p=d3.dispatch("tooltipShow","tooltipHide");c.tickFormat(function(e){return e}),h.tickFormat(d3.format(",.1f"));var d=function(t,n){var r=t.pos[0]+(n.offsetLeft||0),i=t.pos[1]+(n.offsetTop||0),s=c.tickFormat()(a.x()(t.point)),o=h.tickFormat()(a.y()(t.point)),f=u(t.series.key,s,o,t,m);e.tooltip.show([r,i],f,t.value<0?"n":"s")},v=[{key:"Grouped"},{key:"Stacked",disabled:!0}];return m.dispatch=p,m.discretebar=a,m.xAxis=c,m.yAxis=h,d3.rebind(m,a,"x","y","xDomain","yDomain","forceX","forceY","id","showValues","valueFormat"),m.margin=function(e){return arguments.length?(t=e,m):t},m.width=function(e){return arguments.length?(n=e,m):n},m.height=function(e){return arguments.length?(r=e,m):r},m.color=function(e){return arguments.length?(i=e,a.color(e),m):i},m.staggerLabels=function(e){return arguments.length?(s=e,m):s},m.tooltips=function(e){return arguments.length?(o=e,m):o},m.tooltipContent=function(e){return arguments.length?(u=e,m):u},m},e.models.distribution=function(){function f(o){return o.each(function(o){var f=t-(r==="x"?e.left+e.right:e.top+e.bottom),l=r=="x"?"y":"x";a=a||u;var c=d3.select(this).selectAll("g.distribution").data([o]),h=c.enter().append("g").attr("class","nvd3 distribution"),p=h.append("g"),d=c.select("g");c.attr("transform","translate("+e.left+","+e.top+")");var v=d.selectAll("g.dist").data(function(e){return e},function(e){return e.key});v.enter().append("g"),v.attr("class",function(e,t){return"dist series-"+t}).style("stroke",function(e,t){return s[t%s.length]});var m=v.selectAll("line.dist"+r).data(function(e){return e.values});m.enter().append("line").attr(r+"1",function(e,t){return a(i(e,t))}).attr(r+"2",function(e,t){return a(i(e,t))}),d3.transition(v.exit().selectAll("line.dist"+r)).attr(r+"1",function(e,t){return u(i(e,t))}).attr(r+"2",function(e,t){return u(i(e,t))}).style("stroke-opacity",0).remove(),m.attr("class",function(e,t){return"dist"+r+" dist"+r+"-"+t}).attr(l+"1",0).attr(l+"2",n),d3.transition(m).attr(r+"1",function(e,t){return u(i(e,t))}).attr(r+"2",function(e,t){return u(i(e,t))}),a=u.copy()}),f}var e={top:0,right:0,bottom:0,left:0},t=400,n=8,r="x",i=function(e){return e[r]},s=d3.scale.category20().range(),o,u=d3.scale.linear(),a;return f.margin=function(t){return arguments.length?(e=t,f):e},f.width=function(e){return arguments.length?(t=e,f):t},f.axis=function(e){return arguments.length?(r=e,f):r},f.size=function(e){return arguments.length?(n=e,f):n},f.getData=function(e){return arguments.length?(i=d3.functor(e),f):i},f.scale=function(e){return arguments.length?(u=e,f):u},f.color=function(e){return arguments.length?(s=e,f):s},f},e.models.legend=function(){function o(u){return u.each(function(o){var u=t-e.left-e.right,a=d3.select(this).selectAll("g.legend").data([o]),f=a.enter().append("g").attr("class","nvd3 legend").append("g"),l=a.select("g").attr("transform","translate("+e.left+","+e.top+")"),c=l.selectAll(".series").data(function(e){return e}),h=c.enter().append("g").attr("class","series").on("mouseover",function(e,t){s.legendMouseover(e,t)}).on("mouseout",function(e,t){s.legendMouseout(e,t)}).on("click",function(e,t){s.legendClick(e,t)}).on("dblclick",function(e,t){s.legendDblclick(e,t)});h.append("circle").style("fill",function(e,t){return e.color||r[t%r.length]}).style("stroke",function(e,t){return e.color||r[t%r.length]}).style("stroke-width",2).attr("r",5),h.append("text").text(function(e){return e.key}).attr("text-anchor","start").attr("dy",".32em").attr("dx","8"),c.classed("disabled",function(e){return e.disabled}),c.exit().remove();if(i){var p=[];c.each(function(e,t){p.push(d3.select(this).select("text").node().getComputedTextLength()+28)});var d=0,v=0,m=[];while(vu&&d>1){m=[],d--;for(k=0;k(m[k%d]||0)&&(m[k%d]=p[k]);v=m.reduce(function(e,t,n,r){return e+t})}var g=[];for(var y=0,b=0;yS&&(S=E),"translate("+x+","+w+")"}),l.attr("transform","translate("+(t-e.right-S)+","+e.top+")"),n=e.top+e.bottom+w+15}}),o}var e={top:5,right:0,bottom:5,left:0},t=400,n=20,r=d3.scale.category20().range(),i=!0,s=d3.dispatch("legendClick","legendDblclick","legendMouseover","legendMouseout");return o.dispatch=s,o.margin=function(t){return arguments.length?(e=t,o):e},o.width=function(e){return arguments.length?(t=e,o):t},o.height=function(e){return arguments.length?(n=e,o):n},o.color=function(e){return arguments.length?(r=e,o):r},o.align=function(e){return arguments.length?(i=e,o):i},o},e.models.line=function(){function v(e){return e.each(function(e){var d=n-t.left-t.right,v=r-t.top-t.bottom;l=l||f.xScale(),c=c||f.yScale(),h=h||l,p=p||c;var m=d3.select(this).selectAll("g.wrap.line").data([e]),g=m.enter().append("g").attr("class","wrap nvd3 line"),b=g.append("defs"),w=g.append("g"),E=m.select("g");w.append("g").attr("class","groups"),w.append("g").attr("class","scatterWrap"),b.append("clipPath").attr("id","edge-clip-"+s).append("rect"),m.select("#edge-clip-"+s+" rect").attr("width",d).attr("height",v);var S=m.select(".scatterWrap");f.width(d).height(v),d3.transition(S).call(f),m.attr("transform","translate("+t.left+","+t.top+")"),E.attr("clip-path",a?"url(#edge-clip-"+s+")":""),S.attr("clip-path",a?"url(#edge-clip-"+s+")":"");var T=m.select(".groups").selectAll(".group").data(function(e){return e},function(e){return e.key});T.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(T.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),T.attr("class",function(e,t){return"group series-"+t}).classed("hover",function(e){return e.hover}).style("fill",function(e,t){return i[t%i.length]}).style("stroke",function(e,t){return i[t%i.length]}),d3.transition(T).style("stroke-opacity",1).style("fill-opacity",.5);var N=T.selectAll("path").data(function(e,t){return[e.values]});N.enter().append("path").attr("class","line").attr("d",d3.svg.line().x(function(e,t){return h(o(e,t))}).y(function(e,t){return p(u(e,t))})),d3.transition(T.exit().selectAll("path")).attr("d",d3.svg.line().x(function(e,t){return l(o(e,t))}).y(function(e,t){return c(u(e,t))})).remove(),d3.transition(N).attr("d",d3.svg.line().x(function(e,t){return l(o(e,t))}).y(function(e,t){return c(u(e,t))})),h=l.copy(),p=c.copy()}),v}var t={top:0,right:0,bottom:0,left:0},n=960,r=500,i=d3.scale.category20().range(),s=Math.floor(Math.random()*1e4),o=function(e){return e.x},u=function(e){return e.y},a=!1,f=e.models.scatter().id(s).size(16).sizeDomain([16,256]),l,c,h,p,d;return v.dispatch=f.dispatch,d3.rebind(v,f,"interactive","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius"),v.margin=function(e){return arguments.length?(t=e,v):t},v.width=function(e){return arguments.length?(n=e,v):n},v.height=function(e){return arguments.length?(r=e,v):r},v.x=function(e){return arguments.length?(o=e,f.x(e),v):o},v.y=function(e){return arguments.length?(u=e,f.y(e),v):u},v.clipEdge=function(e){return arguments.length?(a=e,v):a},v.color=function(e){return arguments.length?(i=e,f.color(e),v):i},v.id=function(e){return arguments.length?(s=e,v):s},v},e.models.indentedTree=function(){function a(r){return r.each(function(i){function T(e,t,n){d3.event.stopPropagation();if(d3.event.shiftKey&&!n)return d3.event.shiftKey=!1,e.values&&e.values.forEach(function(e){(e.values||e._values)&&T(e,0,!0)}),!0;if(!k(e))return!0;e.values?(e._values=e.values,e.values=null):(e.values=e._values,e._values=null),a.update()}function N(e){return e._values&&e._values.length?iconOpen:e.values&&e.values.length?iconClose:""}function C(e){return e._values&&e._values.length}function k(e){var t=e.values||e._values;return t&&t.length}var f=t-e.left-e.right,l=n-e.top-e.bottom;a.update=function(){r.transition().call(a)};var c=0,h=1,p=d3.layout.tree().children(function(e){return e.values}).size([n,childIndent]);i[0].key||(i[0].key=o);var d=p.nodes(i[0]),v=d3.select(this).selectAll("div").data([[d]]),m=v.enter().append("div").attr("class","wrap nvd3 indentedtree"),g=m.append("table"),y=v.select("table").attr("width","100%").attr("class",tableClass);if(s){var b=g.append("thead"),w=b.append("tr");columns.forEach(function(e){w.append("th").attr("width",e.width?e.width:"10%").style("text-align",e.type=="numeric"?"right":"left").append("span").text(e.label)})}var E=y.selectAll("tbody").data(function(e){return e});E.enter().append("tbody"),h=d3.max(d,function(e){return e.depth}),p.size([n,h*childIndent]);var S=E.selectAll("tr").data(function(e){return e},function(e){return e.id||e.id==++c});S.exit().remove(),S.select("img.treeicon").attr("src",N).classed("folded",C);var x=S.enter().append("tr");columns.forEach(function(e,t){var n=x.append("td").style("padding-left",function(e){return(t?0:e.depth*childIndent+12+(N(e)?0:16))+"px"},"important").style("text-align",e.type=="numeric"?"right":"left");t==0&&n.append("img").classed("treeicon",!0).classed("folded",C).attr("src",N).style("width","14px").style("height","14px").style("padding","0 1px").style("display",function(e){return N(e)?"inline-block":"none"}).on("click",T),n.append("span").attr("class",d3.functor(e.classes)).text(function(t){return e.format?e.format(t):t[e.key]||"-"}),e.showCount&&n.append("span").attr("class","childrenCount").text(function(e){return e.values&&e.values.length||e._values&&e._values.length?"("+(e.values&&e.values.length||e._values&&e._values.length)+")":""}),e.click&&n.select("span").on("click",e.click)}),S.order().on("click",function(e){u.elementClick({row:this,data:e,pos:[e.x,e.y]})}).on("dblclick",function(e){u.elementDblclick({row:this,data:e,pos:[e.x,e.y]})}).on("mouseover",function(e){u.elementMouseover({row:this,data:e,pos:[e.x,e.y]})}).on("mouseout",function(e){u.elementMouseout({row:this,data:e,pos:[e.x,e.y]})})}),a}var e={top:0,right:0,bottom:0,left:0},t=960,n=500,r=d3.scale.category20().range(),i=Math.floor(Math.random()*1e4),s=!0,o="No Results found.";childIndent=20,columns=[{key:"key",label:"Name",type:"text"}],tableClass=null,iconOpen="images/grey-plus.png",iconClose="images/grey-minus.png";var u=d3.dispatch("elementClick","elementDblclick","elementMouseover","elementMouseout");return a.margin=function(t){return arguments.length?(e=t,a):e},a.width=function(e){return arguments.length?(t=e,a):t},a.height=function(e){return arguments.length?(n=e,a):n},a.color=function(e){return arguments.length?(r=e,scatter.color(e),a):r},a.id=function(e){return arguments.length?(i=e,a):i},a.header=function(e){return arguments.length?(s=e,a):s},a.noResultsText=function(e){return arguments.length?(o=e,a):o},a.columns=function(e){return arguments.length?(columns=e,a):columns},a.tableClass=function(e){return arguments.length?(tableClass=e,a):tableClass},a},e.models.lineChart=function(){function m(u){return u.each(function(f){var g=d3.select(this),b=this,w=(r||parseInt(g.style("width"))||960)-t.left-t.right,E=(i||parseInt(g.style("height"))||400)-t.top-t.bottom,S=g.selectAll("g.wrap.lineChart").data([f]),x=S.enter().append("g").attr("class","wrap nvd3 lineChart").append("g");x.append("g").attr("class","x axis"),x.append("g").attr("class","y axis"),x.append("g").attr("class","linesWrap"),x.append("g").attr("class","legendWrap");var T=S.select("g");s&&(p.width(w),T.select(".legendWrap").datum(f).call(p),t.top!=p.height()&&(t.top=p.height(),E=(i||parseInt(g.style("height"))||400)-t.top-t.bottom),T.select(".legendWrap").attr("transform","translate(0,"+ -t.top+")")),a.width(w).height(E).color(f.map(function(e,t){return e.color||n[t%n.length]}).filter(function(e,t){return!f[t].disabled})),T.attr("transform","translate("+t.left+","+t.top+")");var N=T.select(".linesWrap").datum(f.filter(function(e){return!e.disabled}));d3.transition(N).call(a),c.ticks(w/100).tickSize(-E,0),T.select(".x.axis").attr("transform","translate(0,"+l.range()[0]+")"),d3.transition(T.select(".x.axis")).call(c),h.ticks(E/36).tickSize(-w,0),d3.transition(T.select(".y.axis")).call(h),p.dispatch.on("legendClick",function(e,t){e.disabled=!e.disabled,f.filter(function(e){return!e.disabled}).length||f.map(function(e){return e.disabled=!1,S.selectAll(".series").classed("disabled",!1),e}),u.transition().call(m)}),a.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],d.tooltipShow(e)}),o&&d.on("tooltipShow",function(e){v(e,b.parentNode)}),a.dispatch.on("elementMouseout.tooltip",function(e){d.tooltipHide(e)}),o&&d.on("tooltipHide",e.tooltip.cleanup)}),m.update=function(){m(u)},m.container=this,m}var t={top:30,right:20,bottom:50,left:60},n=d3.scale.category20().range(),r=null,i=null,s=!0,o=!0,u=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},a=e.models.line(),f=a.xScale(),l=a.yScale(),c=e.models.axis().scale(f).orient("bottom").tickPadding(5),h=e.models.axis().scale(l).orient("left"),p=e.models.legend().height(30),d=d3.dispatch("tooltipShow","tooltipHide"),v=function(t,n){var r=t.pos[0]+(n.offsetLeft||0),i=t.pos[1]+(n.offsetTop||0),s=c.tickFormat()(a.x()(t.point)),o=h.tickFormat()(a.y()(t.point)),f=u(t.series.key,s,o,t,m);e.tooltip.show([r,i],f)};return m.dispatch=d,m.legend=p,m.xAxis=c,m.yAxis=h,d3.rebind(m,a,"x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),m.margin=function(e){return arguments.length?(t=e,m):t},m.width=function(e){return arguments.length?(r=e,m):r},m.height=function(e){return arguments.length?(i=e,m):i},m.color=function(e){return arguments.length?(n=e,p.color(e),m):n},m.showLegend=function(e){return arguments.length?(s=e,m):s},m.tooltips=function(e){return arguments.length?(o=e,m):o},m.tooltipContent=function(e){return arguments.length?(u=e,m):u},m},e.models.linePlusBarChart=function(){function E(f){return f.each(function(d){var S=d3.select(this),T=this,N=(n||parseInt(S.style("width"))||960)-t.left-t.right,C=(r||parseInt(S.style("height"))||400)-t.top-t.bottom,k=d.filter(function(e){return!e.disabled&&e.bar}),L=d.filter(function(e){return!e.disabled&&!e.bar}),A=d.filter(function(e){return!e.disabled&&e.bar}).map(function(e){return e.values.map(function(e,t){return{x:i(e,t),y:s(e,t)}})}),O=d.filter(function(e){return!e.disabled&&!e.bar}).map(function(e){return e.values.map(function(e,t){return{x:i(e,t),y:s(e,t)}})});h.domain(d3.extent(d3.merge(A.concat(O)),function(e){return e.x})).range([0,N]),l.width(N).height(C).color(d.map(function(e,t){return e.color||o[t%o.length]}).filter(function(e,t){return!d[t].disabled&&!d[t].bar})),c.width(N).height(C).color(d.map(function(e,t){return e.color||o[t%o.length]}).filter(function(e,t){return!d[t].disabled&&d[t].bar}));var M=d3.select(this).selectAll("g.wrap.linePlusBar").data([d]),_=M.enter().append("g").attr("class","wrap nvd3 linePlusBar").append("g");_.append("g").attr("class","x axis"),_.append("g").attr("class","y1 axis"),_.append("g").attr("class","y2 axis"),_.append("g").attr("class","barsWrap"),_.append("g").attr("class","linesWrap"),_.append("g").attr("class","legendWrap");var D=M.select("g");u&&(y.width(N),D.select(".legendWrap").datum(d.map(function(e){return e.key=e.key+(e.bar?" (left axis)":" (right axis)"),e})).call(y),t.top!=y.height()&&(t.top=y.height(),C=(r||parseInt(S.style("height"))||400)-t.top-t.bottom),D.select(".legendWrap").attr("transform","translate(0,"+ -t.top+")"));var P=D.select(".barsWrap").datum(k.length?k:[{values:[]}]),H=D.select(".linesWrap").datum(L.length?L:[{values:[]}]);d3.transition(P).call(c),d3.transition(H).call(l),D.attr("transform","translate("+t.left+","+t.top+")"),v.ticks(N/100).tickSize(-C,0),D.select(".x.axis").attr("transform","translate(0,"+p.range()[0]+")"),d3.transition(D.select(".x.axis")).call(v),m.ticks(C/36).tickSize(-N,0),d3.transition(D.select(".y1.axis")).call(m),g.ticks(C/36).tickSize(k.length?0:-N,0),D.select(".y2.axis").attr("transform","translate("+h.range()[1]+",0)"),d3.transition(D.select(".y2.axis")).call(g),y.dispatch.on("legendClick",function(e,t){e.disabled=!e.disabled,d.filter(function(e){return!e.disabled}).length||d.map(function(e){return e.disabled=!1,M.selectAll(".series").classed("disabled",!1),e}),f.transition().call(E)}),l.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],b.tooltipShow(e)}),a&&b.on("tooltipShow",function(e){w(e,T.parentNode)}),l.dispatch.on("elementMouseout.tooltip",function(e){b.tooltipHide(e)}),a&&b.on("tooltipHide",e.tooltip.cleanup),c.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],b.tooltipShow(e)}),a&&b.on("tooltipShow",function(e){w(e,T.parentNode)}),c.dispatch.on("elementMouseout.tooltip",function(e){b.tooltipHide(e)}),a&&b.on("tooltipHide",e.tooltip.cleanup),E.update=function(){f.transition().call(E)},E.container=this}),E}var t={top:30,right:60,bottom:50,left:60},n=null,r=null,i=function(e){return e.x},s=function(e){return e.y},o=d3.scale.category20().range(),u=!0,a=!0,f=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},l=e.models.line(),c=e.models.historicalBar(),h=d3.scale.linear(),p=c.yScale(),d=l.yScale(),v=e.models.axis().scale(h).orient("bottom").tickPadding(5),m=e.models.axis().scale(p).orient("left"),g=e.models.axis().scale(d).orient("right"),y=e.models.legend().height(30),b=d3.dispatch("tooltipShow","tooltipHide"),w=function(t,n){var r=t.pos[0]+(n.offsetLeft||0),i=t.pos[1]+(n.offsetTop||0),s=v.tickFormat()(l.x()(t.point)),o=m.tickFormat()(l.y()(t.point)),u=f(t.series.key,s,o,t,E);e.tooltip.show([r,i],u,t.value<0?"n":"s")};return E.dispatch=b,E.legend=y,E.lines=l,E.bars=c,E.xAxis=v,E.yAxis1=m,E.yAxis2=g,d3.rebind(E,l,"size","clipVoronoi"),E.x=function(e){return arguments.length?(i=e,l.x(e),c.x(e),E):i},E.y=function(e){return arguments.length?(s=e,l.y(e),c.y(e),E):s},E.margin=function(e){return arguments.length?(t=e,E):t},E.width=function(e){return arguments.length?(n=e,E):n},E.height=function(e){return arguments.length?(r=e,E):r},E.color=function(e){return arguments.length?(o=e,y.color(e),E):o},E.showLegend=function(e){return arguments.length?(u=e,E):u},E.tooltips=function(e){return arguments.length?(a=e,E):a},E.tooltipContent=function(e){return arguments.length?(f=e,E):f},E},e.models.lineWithFocusChart=function(){function T(f){return f.each(function(N){function F(e){var t=+(e=="e"),n=t?1:-1,r=O/3;return"M"+.5*n+","+r+"A6,6 0 0 "+t+" "+6.5*n+","+(r+6)+"V"+(2*r-6)+"A6,6 0 0 "+t+" "+.5*n+","+2*r+"Z"+"M"+2.5*n+","+(r+8)+"V"+(2*r-8)+"M"+4.5*n+","+(r+8)+"V"+(2*r-8)}function I(){q(),B.call(l),H.select(".focus .x.axis").call(m),H.select(".focus .y.axis").call(g)}function q(){var e=S.empty()?v.domain():d3.extent(d3.merge(N.filter(function(e){return!e.disabled}).map(function(e){return e.values})).filter(function(e){return l.x()(e)>=S.extent()[0]&&l.x()(e)<=S.extent()[1]}),l.y());typeof e[0]=="undefined"&&(e=v.domain()),h.domain(S.empty()?d.domain():S.extent()),p.domain(e),l.xDomain(h.domain()),l.yDomain(p.domain())}var C=d3.select(this),k=this,L=(i||parseInt(C.style("width"))||960)-t.left-t.right,A=(s||parseInt(C.style("height"))||400)-t.top-t.bottom-o,O=o-n.top-n.bottom;S.on("brush",I);var M=C.selectAll("g.wrap.lineWithFocusChart").data([N]),_=M.enter().append("g").attr("class","wrap nvd3 lineWithFocusChart").append("g"),D=_.append("g").attr("class","focus");D.append("g").attr("class","x axis"),D.append("g").attr("class","y axis"),D.append("g").attr("class","linesWrap");var P=_.append("g").attr("class","context");P.append("g").attr("class","x axis"),P.append("g").attr("class","y axis"),P.append("g").attr("class","linesWrap"),P.append("g").attr("class","x brush"),_.append("g").attr("class","legendWrap");var H=M.select("g");u&&(w.width(L),H.select(".legendWrap").datum(N).call(w),t.top!=w.height()&&(t.top=w.height(),A=(s||parseInt(C.style("height"))||400)-t.top-t.bottom),H.select(".legendWrap").attr("transform","translate(0,"+ -t.top+")")),l.width(L).height(A).color(N.map(function(e,t){return e.color||r[t%r.length]}).filter(function(e,t){return!N[t].disabled})),c.width(L).height(O).color(N.map(function(e,t){return e.color||r[t%r.length]}).filter(function(e,t){return!N[t].disabled})),H.attr("transform","translate("+t.left+","+t.top+")");var B=H.select(".focus .linesWrap").datum(N.filter(function(e){return!e.disabled}));d3.transition(B).call(l),m.ticks(L/100).tickSize(-A,0),H.select(".focus .x.axis").attr("transform","translate(0,"+p.range()[0]+")"),d3.transition(H.select(".focus .x.axis")).call(m),g.ticks(A/36).tickSize(-L,0),d3.transition(H.select(".focus .y.axis")).call(g),H.select(".context").attr("transform","translate(0,"+(A+t.bottom+n.top)+")");var j=H.select(".context .linesWrap").datum(N.filter(function(e){return!e.disabled}));d3.transition(j).call(c),gBrush=H.select(".x.brush").call(S),gBrush.selectAll("rect").attr("height",O),gBrush.selectAll(".resize").append("path").attr("d",F),y.tickFormat(m.tickFormat()).ticks(L/100).tickSize(-O,0),H.select(".context .x.axis").attr("transform","translate(0,"+v.range()[0]+")"),d3.transition(H.select(".context .x.axis")).call(y),b.tickFormat(g.tickFormat()).ticks(O/36).tickSize(-L,0),d3.transition(H.select(".context .y.axis")).call(b),q(),w.dispatch.on("legendClick",function(e,t){e.disabled=!e.disabled,N.filter(function(e){return!e.disabled}).length||N.map(function(e){return e.disabled=!1,M.selectAll(".series").classed("disabled",!1),e}),f.transition().call(T)}),l.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],E.tooltipShow(e)}),a&&E.on("tooltipShow",function(e){x(e,k.parentNode)}),l.dispatch.on("elementMouseout.tooltip",function(e){E.tooltipHide(e)}),a&&E.on("tooltipHide",e.tooltip.cleanup)}),T.update=function(){T(f)},T.container=this,T}var t={top:30,right:20,bottom:50,left:60},n={top:0,right:20,bottom:20,left:60},r=d3.scale.category20().range(),i=null,s=null,o=100,u=!0,a=!0,f=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},l=e.models.line().clipEdge(!0),c=e.models.line().interactive(!1),h=l.xScale(),p=l.yScale(),d=c.xScale(),v=c.yScale(),m=e.models.axis().scale(h).orient("bottom").tickPadding(5),g=e.models.axis().scale(p).orient("left"),y=e.models.axis().scale(h).orient("bottom").tickPadding(5),b=e.models.axis().scale(v).orient("left"),w=e.models.legend().height(30),E=d3.dispatch("tooltipShow","tooltipHide"),S=d3.svg.brush().x(d),x=function(t,n){var r=t.pos[0]+(n.offsetLeft||0),i=t.pos[1]+(n.offsetTop||0),s=m.tickFormat()(l.x()(t.point)),o=g.tickFormat()(l.y()(t.point)),u=f(t.series.key,s,o,t,T);e.tooltip.show([r,i],u)};return T.dispatch=E,T.legend=w,T.xAxis=m,T.yAxis=g,d3.rebind(T,l,"x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),T.margin=function(e){return arguments.length?(t=e,T):t},T.width=function(e){return arguments.length?(i=e,T):i},T.height=function(e){return arguments.length?(s=e,T):s},T.color=function(e){return arguments.length?(r=e,w.color(e),T):r},T.showLegend=function(e){return arguments.length?(u=e,T):u},T.tooltips=function(e){return arguments.length?(a=e,T):a},T.tooltipContent=function(e){return arguments.length?(f=e,T):f},T},e.models.multiBar=function(){function y(b){return b.each(function(w){var E=t-e.left-e.right,S=n-e.top-e.bottom;p=p||v,d=d||m,a&&(w=d3.layout.stack().offset("zero").values(function(e){return e.values}).y(s)(w)),w=w.map(function(e,t){return e.values=e.values.map(function(e){return e.series=t,e}),e});var T=c&&h?[]:w.map(function(e){return e.values.map(function(e,t){return{x:i(e,t),y:s(e,t),y0:e.y0}})});v.domain(d3.merge(T).map(function(e){return e.x})).rangeBands([0,E],.1),m.domain(h||d3.extent(d3.merge(T).map(function(e){return e.y+(a?e.y0:0)}).concat(o))).range([S,0]);var N=d3.select(this).selectAll("g.wrap.multibar").data([w]),C=N.enter().append("g").attr("class","wrap nvd3 multibar"),k=C.append("defs"),L=C.append("g");L.append("g").attr("class","groups");var A=N.select("g");N.attr("transform","translate("+e.left+","+e.top+")"),k.append("clipPath").attr("id","edge-clip-"+r).append("rect"),N.select("#edge-clip-"+r+" rect").attr("width",E).attr("height",S),A.attr("clip-path",u?"url(#edge-clip-"+r+")":"");var O=N.select(".groups").selectAll(".group").data(function(e){return e},function(e){return e.key});O.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(O.exit()).selectAll("rect.bar").delay(function(e,t){return t*l/w[0].values.length}).attr("y",function(e){return a?d(e.y0):d(0)}).attr("height",0).remove(),O.attr("class",function(e,t){return"group series-"+t}).classed("hover",function(e){return e.hover}).style("fill",function(e,t){return f[t%f.length]}).style("stroke",function(e,t){return f[t%f.length]}),d3.transition(O).style("stroke-opacity",1).style("fill-opacity",.75);var M=O.selectAll("rect.bar").data(function(e){return e.values});M.exit().remove();var _=M.enter().append("rect").attr("class",function(e,t){return s(e,t)<0?"bar negative":"bar positive"}).attr("x",function(e,t,n){return a?0:n*v.rangeBand()/w.length}).attr("y",function(e){return d(a?e.y0:0)}).attr("height",0).attr("width",v.rangeBand()/(a?1:w.length)).on("mouseover",function(e,t){d3.select(this).classed("hover",!0),g.elementMouseover({value:s(e,t),point:e,series:w[e.series],pos:[v(i(e,t))+v.rangeBand()*(a?w.length/2:e.series+.5)/w.length,m(s(e,t)+(a?e.y0:0))],pointIndex:t,seriesIndex:e.series,e:d3.event})}).on("mouseout",function(e,t){d3.select(this).classed("hover",!1),g.elementMouseout({value:s(e,t),point:e,series:w[e.series],pointIndex:t,seriesIndex:e.series,e:d3.event})}).on("click",function(e,t){g.elementClick({value:s(e,t),point:e,series:w[e.series],pos:[v(i(e,t))+v.rangeBand()*(a?w.length/2:e.series+.5)/w.length,m(s(e,t)+(a?e.y0:0))],pointIndex:t,seriesIndex:e.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(e,t){g.elementDblClick({value:s(e,t),point:e,series:w[e.series],pos:[v(i(e,t))+v.rangeBand()*(a?w.length/2:e.series+.5)/w.length,m(s(e,t)+(a?e.y0:0))],pointIndex:t,seriesIndex:e.series,e:d3.event}),d3.event.stopPropagation()});M.attr("class",function(e,t){return s(e,t)<0?"bar negative":"bar positive"}).attr("transform",function(e,t){return"translate("+v(i(e,t))+",0)"}),a?d3.transition(M).delay(function(e,t){return t*l/w[0].values.length}).attr("y",function(e,t){return m(s(e,t)+(a?e.y0:0))}).attr("height",function(e,t){return Math.abs(m(e.y+(a?e.y0:0))-m(a?e.y0:0))}).each("end",function(){d3.transition(d3.select(this)).attr("x",function(e,t){return a?0:e.series*v.rangeBand()/w.length}).attr("width",v.rangeBand()/(a?1:w.length))}):d3.transition(M).delay(function(e,t){return t*l/w[0].values.length}).attr("x",function(e,t){return e.series*v.rangeBand()/w.length}).attr("width",v.rangeBand()/w.length).each("end",function(){d3.transition(d3.select(this)).attr("y",function(e,t){return s(e,t)<0?m(0):m(s(e,t))}).attr("height",function(e,t){return Math.abs(m(s(e,t))-m(0))})}),y.update=function(){b.transition().call(y)},p=v.copy(),d=m.copy()}),y}var e={top:0,right:0,bottom:0,left:0},t=960,n=500,r=Math.floor(Math.random()*1e4),i=function(e){return e.x},s=function(e){return e.y},o=[0],u=!0,a=!1,f=d3.scale.category20().range(),l=1200,c,h,p,d,v=d3.scale.ordinal(),m=d3.scale.linear(),g=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return y.dispatch=g,y.x=function(e){return arguments.length?(i=e,y):i},y.y=function(e){return arguments.length?(s=e,y):s},y.margin=function(t){return arguments.length?(e=t,y):e},y.width=function(e){return arguments.length?(t=e,y):t},y.height=function(e){return arguments.length?(n=e,y):n},y.xScale=function(e){return arguments.length?(v=e,y):v},y.yScale=function(e){return arguments.length?(m=e,y):m},y.xDomain=function(e){return arguments.length?(c=e,y):c},y.yDomain=function(e){return arguments.length?(h=e,y):h},y.forceY=function(e){return arguments.length?(o=e,y):o},y.stacked=function(e){return arguments.length?(a=e,y):a},y.clipEdge=function(e){return arguments.length?(u=e,y):u},y.color=function(e){return arguments.length?(f=e,y):f},y.id=function(e){return arguments.length?(r=e,y):r},y.delay=function(e){return arguments.length?(l=e,y):l},y},e.models.multiBarChart=function(){function b(a){return a.each(function(l){var w=d3.select(this),E=this,S=(n||parseInt(w.style("width"))||960)-t.left-t.right,x=(r||parseInt(w.style("height"))||400)-t.top-t.bottom,T=w.selectAll("g.wrap.multiBarWithLegend").data([l]),N=T.enter().append("g").attr("class","wrap nvd3 multiBarWithLegend").append("g");N.append("g").attr("class","x axis"),N.append("g").attr("class","y axis"),N.append("g").attr("class","barsWrap"),N.append("g").attr("class","legendWrap"),N.append("g").attr("class","controlsWrap");var C=T.select("g");o&&(d.width(S/2),C.select(".legendWrap").datum(l).call(d),t.top!=d.height()&&(t.top=d.height(),x=(r||parseInt(w.style("height"))||400)-t.top-t.bottom),C.select(".legendWrap").attr("transform","translate("+S/2+","+ -t.top+")")),f.width(S).height(x).color(l.map(function(e,t){return e.color||i[t%i.length]}).filter(function(e,t){return!l[t].disabled})),s&&(v.width(180).color(["#444","#444","#444"]),C.select(".controlsWrap").datum(y).attr("transform","translate(0,"+ -t.top+")").call(v)),C.attr("transform","translate("+t.left+","+t.top+")");var k=C.select(".barsWrap").datum(l.filter(function(e){return!e.disabled}));d3.transition(k).call(f),h.ticks(S/100).tickSize(-x,0),C.select(".x.axis").attr("transform","translate(0,"+c.range()[0]+")"),d3.transition(C.select(".x.axis")).call(h);var L=C.select(".x.axis").selectAll("g");L.selectAll("line, text").style("opacity",1),L.filter(function(e,t){return t%Math.ceil(l[0].values.length/(S/100))!==0}).selectAll("line, text").style("opacity",0),p.ticks(x/36).tickSize(-S,0),d3.transition(C.select(".y.axis")).call(p),d.dispatch.on("legendClick",function(e,t){e.disabled=!e.disabled,l.filter(function(e){return!e.disabled}).length||l.map(function(e){return e.disabled=!1,T.selectAll(".series").classed("disabled",!1),e}),a.transition().call(b)}),v.dispatch.on("legendClick",function(e,t){if(!e.disabled)return;y=y.map(function(e){return e.disabled=!0,e}),e.disabled=!1;switch(e.key){case"Grouped":f.stacked(!1);break;case"Stacked":f.stacked(!0)}a.transition().call(b)}),f.dispatch.on("elementMouseover.tooltip2",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],m.tooltipShow(e)}),u&&m.on("tooltipShow",function(e){g(e,E.parentNode)}),f.dispatch.on("elementMouseout.tooltip",function(e){m.tooltipHide(e)}),u&&m.on("tooltipHide",e.tooltip.cleanup),b.update=function(){a.transition().call(b)},b.container=this}),b}var t={top:30,right:20,bottom:50,left:60},n=null,r=null,i=d3.scale.category20().range(),s=!0,o=!0,u=!0,a=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" on "+t+"

"},f=e.models.multiBar().stacked(!1),l=f.xScale(),c=f.yScale(),h=e.models.axis().scale(l).orient("bottom").highlightZero(!1),p=e.models.axis().scale(c).orient("left"),d=e.models.legend().height(30),v=e.models.legend().height(30),m=d3.dispatch("tooltipShow","tooltipHide");h.tickFormat(function(e){return e}),p.tickFormat(d3.format(",.1f"));var g=function(t,n){var r=t.pos[0]+(n.offsetLeft||0),i=t.pos[1]+(n.offsetTop||0),s=h.tickFormat()(f.x()(t.point)),o=p.tickFormat()(f.y()(t.point)),u=a(t.series.key,s,o,t,b);e.tooltip.show([r,i],u,t.value<0?"n":"s",null,n)},y=[{key:"Grouped"},{key:"Stacked",disabled:!0}];return b.dispatch=m,b.legend=d,b.xAxis=h,b.yAxis=p,d3.rebind(b,f,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id","stacked"),b.margin=function(e){return arguments.length?(t=e,b):t},b.width=function(e){return arguments.length?(n=e,b):n},b.height=function(e){return arguments.length?(r=e,b):r},b.color=function(e){return arguments.length?(i=e,d.color(e),b):i},b.showControls=function(e){return arguments.length?(s=e,b):s},b.showLegend=function(e){return arguments.length?(o=e,b):o},b},e.models.multiBarHorizontal=function(){function w(r){return r.each(function(d){var E=t-e.left-e.right,S=n-e.top-e.bottom;l&&(d=d3.layout.stack().offset("zero").values(function(e){return e.values}).y(u)(d)),d=d.map(function(e,t){return e.values=e.values.map(function(e){return e.series=t,e}),e});var T=v&&m?[]:d.map(function(e){return e.values.map(function(e,t){return{x:o(e,t),y:u(e,t),y0:e.y0}})});i.domain(v||d3.merge(T).map(function(e){return e.x})).rangeBands([0,S],.1),s.domain(m||d3.extent(d3.merge(T).map(function(e){return e.y+(l?e.y0:0)}).concat(a))),c&&!l?s.range([s.domain()[0]<0?h:0,E-(s.domain()[1]>0?h:0)]):s.range([0,E]),g=g||i,y=y||d3.scale.linear().domain(s.domain()).range([s(0),s(0)]);var N=d3.select(this).selectAll("g.wrap.multibarHorizontal").data([d]),C=N.enter().append("g").attr("class","wrap nvd3 multibarHorizontal"),k=C.append("defs"),L=C.append("g");L.append("g").attr("class","groups");var A=N.select("g");N.attr("transform","translate("+e.left+","+e.top+")");var O=N.select(".groups").selectAll(".group").data(function(e){return e},function(e){return e.key});O.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(O.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),O.attr("class",function(e,t){return"group series-"+t}).classed("hover",function(e){return e.hover}).style("fill",function(e,t){return f[t%f.length]}).style("stroke",function(e,t){return f[t%f.length]}),d3.transition(O).style("stroke-opacity",1).style("fill-opacity",.75);var M=O.selectAll("g.bar").data(function(e){return e.values});M.exit().remove();var _=M.enter().append("g").attr("transform",function(e,t,n){return"translate("+y(l?e.y0:0)+","+(l?0:n*i.rangeBand()/d.length+i(o(e,t)))+")"}).on("mouseover",function(e,t){d3.select(this).classed("hover",!0),b.elementMouseover({value:u(e,t),point:e,series:d[e.series],pos:[s(u(e,t)+(l?e.y0:0)),i(o(e,t))+i.rangeBand()*(l?d.length/2:e.series+.5)/d.length],pointIndex:t,seriesIndex:e.series,e:d3.event})}).on("mouseout",function(e,t){d3.select(this).classed("hover",!1),b.elementMouseout({value:u(e,t),point:e,series:d[e.series],pointIndex:t,seriesIndex:e.series,e:d3.event})}).on("click",function(e,t){b.elementClick({value:u(e,t),point:e,series:d[e.series],pos:[i(o(e,t))+i.rangeBand()*(l?d.length/2:e.series+.5)/d.length,s(u(e,t)+(l?e.y0:0))],pointIndex:t,seriesIndex:e.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(e,t){b.elementDblClick({value:u(e,t),point:e,series:d[e.series],pos:[i(o(e,t))+i.rangeBand()*(l?d.length/2:e.series+.5)/d.length,s(u(e,t)+(l?e.y0:0))],pointIndex:t,seriesIndex:e.series,e:d3.event}),d3.event.stopPropagation()});_.append("rect").attr("width",0).attr("height",i.rangeBand()/(l?1:d.length)),c&&!l?(_.append("text").attr("text-anchor",function(e,t){return u(e,t)<0?"end":"start"}),M.selectAll("text").attr("y",i.rangeBand()/2).attr("dy","-.5em").text(function(e,t){return p(u(e,t))}),d3.transition(M).selectAll("text").attr("dx",function(e,t){return u(e,t)<0?-4:s(u(e,t))-s(0)+4})):M.selectAll("text").remove(),M.attr("class",function(e,t){return u(e,t)<0?"bar negative":"bar positive"}),l?d3.transition(M).attr("transform",function(e,t){return"translate("+s(e.y0)+","+(l?0:j*i.rangeBand()/d.length)+")"}).selectAll("rect").attr("width",function(e,t){return Math.abs(s(u(e,t)+e.y0)-s(e.y0))}).attr("height",i.rangeBand()):d3.transition(M).attr("transform",function(e,t){return"translate("+(u(e,t)<0?s(u(e,t)):s(0))+","+(e.series*i.rangeBand()/d.length+i(o(e,t)))+")"}).selectAll("rect").attr("height",i.rangeBand()/d.length).attr("width",function(e,t){return Math.abs(s(u(e,t))-s(0))}),w.update=function(){r.transition().call(w)},g=i.copy(),y=s.copy()}),w}var e={top:0,right:0,bottom:0,left:0},t=960,n=500,r=Math.floor(Math.random()*1e4),i=d3.scale.ordinal(),s=d3.scale.linear(),o=function(e){return e.x},u=function(e){return e.y},a=[0],f=d3.scale.category20().range(),l=!1,c=!1,h=60,p=d3.format(",.2f"),d=1200,v,m,g,y,b=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return w.dispatch=b,w.x=function(e){return arguments.length?(o=e,w):o},w.y=function(e){return arguments.length?(u=e,w):u},w.margin=function(t){return arguments.length?(e=t,w):e},w.width=function(e){return arguments.length?(t=e,w):t},w.height=function(e){return arguments.length?(n=e,w):n},w.xScale=function(e){return arguments.length?(i=e,w):i},w.yScale=function(e){return arguments.length?(s=e,w):s},w.xDomain=function(e){return arguments.length?(v=e,w):v},w.yDomain=function(e){return arguments.length?(m=e,w):m},w.forceY=function(e){return arguments.length?(a=e,w):a},w.stacked=function(e){return arguments.length?(l=e,w):l},w.color=function(e){return arguments +.length?(f=e,w):f},w.id=function(e){return arguments.length?(r=e,w):r},w.delay=function(e){return arguments.length?(d=e,w):d},w.showValues=function(e){return arguments.length?(c=e,w):c},w.valueFormat=function(e){return arguments.length?(p=e,w):p},w.valuePadding=function(e){return arguments.length?(h=e,w):h},w},e.models.multiBarHorizontalChart=function(){function b(a){return a.each(function(l){var c=d3.select(this),w=this,E=(n||parseInt(c.style("width"))||960)-t.left-t.right,S=(r||parseInt(c.style("height"))||400)-t.top-t.bottom,x=c.selectAll("g.wrap.multiBarHorizontalChart").data([l]),T=x.enter().append("g").attr("class","wrap nvd3 multiBarHorizontalChart").append("g");T.append("g").attr("class","x axis"),T.append("g").attr("class","y axis"),T.append("g").attr("class","barsWrap"),T.append("g").attr("class","legendWrap"),T.append("g").attr("class","controlsWrap"),t.top=d.height();var N=x.select("g");o&&(d.width(E/2),N.select(".legendWrap").datum(l).call(d),t.top!=d.height()&&(t.top=d.height(),S=(r||parseInt(c.style("height"))||400)-t.top-t.bottom),N.select(".legendWrap").attr("transform","translate("+E/2+","+ -t.top+")")),f.width(E).height(S).color(l.map(function(e,t){return e.color||i[t%i.length]}).filter(function(e,t){return!l[t].disabled})),s&&(v.width(180).color(["#444","#444","#444"]),N.select(".controlsWrap").datum(y).attr("transform","translate(0,"+ -t.top+")").call(v)),N.attr("transform","translate("+t.left+","+t.top+")");var C=N.select(".barsWrap").datum(l.filter(function(e){return!e.disabled}));d3.transition(C).call(f),h.ticks(S/24).tickSize(-E,0),N.select(".x.axis").transition().duration(0).call(h);var k=N.select(".x.axis").selectAll("g");k.selectAll("line, text").style("opacity",1),p.ticks(E/100).tickSize(-S,0),N.select(".y.axis").attr("transform","translate(0,"+S+")"),d3.transition(N.select(".y.axis")).call(p),d.dispatch.on("legendClick",function(e,t){e.disabled=!e.disabled,l.filter(function(e){return!e.disabled}).length||l.map(function(e){return e.disabled=!1,x.selectAll(".series").classed("disabled",!1),e}),a.transition().call(b)}),v.dispatch.on("legendClick",function(e,t){if(!e.disabled)return;y=y.map(function(e){return e.disabled=!0,e}),e.disabled=!1;switch(e.key){case"Grouped":f.stacked(!1);break;case"Stacked":f.stacked(!0)}a.transition().call(b)}),f.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],m.tooltipShow(e)}),u&&m.on("tooltipShow",function(e){g(e,w.parentNode)}),f.dispatch.on("elementMouseout.tooltip",function(e){m.tooltipHide(e)}),u&&m.on("tooltipHide",e.tooltip.cleanup),b.update=function(){a.transition().call(b)},b.container=this}),b}var t={top:30,right:20,bottom:50,left:60},n=null,r=null,i=d3.scale.category20().range(),s=!0,o=!0,u=!0,a=function(e,t,n,r,i){return"

"+t+"

"+"

"+n+"

"},f=e.models.multiBarHorizontal().stacked(!1),l=f.xScale(),c=f.yScale(),h=e.models.axis().scale(l).orient("left").highlightZero(!1).showMaxMin(!1),p=e.models.axis().scale(c).orient("bottom"),d=e.models.legend().height(30),v=e.models.legend().height(30),m=d3.dispatch("tooltipShow","tooltipHide");h.tickFormat(function(e){return e}),p.tickFormat(d3.format(",.1f"));var g=function(t,n){var r=t.pos[0]+(n.offsetLeft||0),i=t.pos[1]+(n.offsetTop||0),s=h.tickFormat()(f.x()(t.point)),o=p.tickFormat()(f.y()(t.point)),u=a(t.series.key,s,o,t,b);e.tooltip.show([r,i],u,t.value<0?"e":"w")},y=[{key:"Grouped"},{key:"Stacked",disabled:!0}];return b.dispatch=m,b.multibar=f,b.legend=d,b.xAxis=h,b.yAxis=p,d3.rebind(b,f,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id","delay","showValues","valueFormat"),b.margin=function(e){return arguments.length?(t=e,b):t},b.width=function(e){return arguments.length?(n=e,b):n},b.height=function(e){return arguments.length?(r=e,b):r},b.color=function(e){return arguments.length?(i=e,d.color(e),b):i},b.showControls=function(e){return arguments.length?(s=e,b):s},b.showLegend=function(e){return arguments.length?(o=e,b):o},b.tooltips=function(e){return arguments.length?(u=e,b):u},b.tooltipContent=function(e){return arguments.length?(a=e,b):a},b},e.models.pie=function(){function v(h){return h.each(function(h){function T(e){var t=(e.startAngle+e.endAngle)*90/Math.PI-90;return t>90?t-180:t}function N(e){e.innerRadius=0;var t=d3.interpolate({startAngle:0,endAngle:0},e);return function(e){return b(t(e))}}var p=d3.select(this).on("click",function(e,t){d.chartClick({data:e,index:t,pos:d3.event,id:u})}),v=p.selectAll("svg.margin").data([h]),m=v.enter();m.append("text").attr("class","title").attr("dy",".91em").attr("text-anchor","start").text(c),m.append("svg").attr("class","margin").attr("x",e.left).attr("y",e.top).style("overflow","visible");var g=v.selectAll("g.wrap").data([h]);g.exit().remove();var y=g.enter();y.append("g").attr("class","wrap").attr("id","wrap-"+u).append("g").attr("class","pie"),g.attr("width",t).attr("height",n).attr("transform","translate("+i+","+i+")");var b=d3.svg.arc().outerRadius(i-i/5);l&&b.innerRadius(i/2);var w=d3.layout.pie().value(function(e){return e[o]}),E=v.select(".pie").selectAll(".slice").data(w);E.exit().remove();var S=E.enter().append("svg:g").attr("class","slice").on("mouseover",function(e,t){d3.select(this).classed("hover",!0),d.tooltipShow({label:e.data[s],value:e.data[o],data:e.data,index:t,pos:[d3.event.pageX,d3.event.pageY],id:u})}).on("mouseout",function(e,t){d3.select(this).classed("hover",!1),d.tooltipHide({label:e.data[s],value:e.data[o],data:e.data,index:t,id:u})}).on("click",function(e,t){d.elementClick({label:e.data[s],value:e.data[o],data:e.data,index:t,pos:d3.event,id:u}),d3.event.stopPropagation()}).on("dblclick",function(e,t){d.elementDblClick({label:e.data[s],value:e.data[o],data:e.data,index:t,pos:d3.event,id:u}),d3.event.stopPropagation()}),x=S.append("svg:path").attr("class","path").attr("fill",function(e,t){return a(t)});E.select(".path").attr("d",b).transition().ease("bounce").duration(r).attrTween("d",N),f&&(S.append("text"),E.select("text").transition().duration(r).ease("bounce").attr("transform",function(e){return e.outerRadius=i+10,e.innerRadius=i+15,"translate("+b.centroid(e)+")"}).attr("text-anchor","middle").style("font","bold 12px Arial").text(function(e,t){return e.data[s]}))}),v}var e={top:20,right:20,bottom:20,left:20},t=500,n=500,r=2e3,i=Math.min(t-(e.right+e.left),n-(e.top+e.bottom))/2,s="label",o="y",u=Math.floor(Math.random()*1e4),a=d3.scale.category20(),f=!0,l=!1,c="",h=0,p=0,d=d3.dispatch("chartClick","elementClick","elementDblClick","tooltipShow","tooltipHide");return v.margin=function(t){return arguments.length?(e=t,v):e},v.width=function(r){return arguments.length?(e.left+e.right+20>r?t=e.left+e.right+20:t=r,i=Math.min(t-(e.left+e.right),n-(e.top+e.bottom))/2,v):t},v.height=function(r){return arguments.length?(e.top+e.bottom+20>r?n=e.top+e.bottom+20:n=r,i=Math.min(t-(e.left+e.right),n-(e.top+e.bottom))/2,v):n},v.animate=function(e){return arguments.length?(r=e,v):r},v.labelField=function(e){return arguments.length?(s=e,v):s},v.dataField=function(e){return arguments.length?(o=e,v):o},v.showLabels=function(e){return arguments.length?(f=e,v):f},v.donut=function(e){return arguments.length?(l=e,v):l},v.title=function(e){return arguments.length?(c=e,v):c},v.id=function(e){return arguments.length?(u=e,v):u},v.dispatch=d,v},e.models.scatter=function(){function k(L){return L.each(function(k){function j(){if(!v)return!1;H.append("g").attr("class","point-paths");var t=d3.merge(k.map(function(e,t){return e.values.map(function(e,n){return[o(f(e,n))*(Math.random()/1e12+1),u(l(e,n))*(Math.random()/1e12+1),t,n]})}));if(g){P.append("clipPath").attr("id","points-clip-"+s);var n=_.select("#points-clip-"+s).selectAll("circle").data(t);n.enter().append("circle").attr("r",y),n.exit().remove(),n.attr("cx",function(e){return e[0]}).attr("cy",function(e){return e[1]}),_.select(".point-paths").attr("clip-path","url(#points-clip-"+s+")")}var r=d3.geom.voronoi(t).map(function(e,n){return{data:e,series:t[n][2],point:t[n][3]}}),i=_.select(".point-paths").selectAll("path").data(r);i.enter().append("path").attr("class",function(e,t){return"path-"+t}),i.exit().remove(),i.attr("d",function(e){return"M"+e.data.join(",")+"Z"}).on("click",function(t){var n=k[t.series],r=n.values[t.point];S.elementClick({point:r,series:n,pos:[o(f(r,t.point))+e.left,u(l(r,t.point))+e.top],seriesIndex:t.series,pointIndex:t.point})}).on("mouseover",function(t){var n=k[t.series],r=n.values[t.point];S.elementMouseover({point:r,series:n,pos:[o(f(r,t.point))+e.left,u(l(r,t.point))+e.top],seriesIndex:t.series,pointIndex:t.point})}).on("mouseout",function(e,t){S.elementMouseout({point:k[e.series].values[e.point],series:k[e.series],seriesIndex:e.series,pointIndex:e.point})}),S.on("elementMouseover.point",function(e){d3.select(".chart-"+s+" .series-"+e.seriesIndex+" .point-"+e.pointIndex).classed("hover",!0)}),S.on("elementMouseout.point",function(e){d3.select(".chart-"+s+" .series-"+e.seriesIndex+" .point-"+e.pointIndex).classed("hover",!1)})}var L=t-e.left-e.right,A=n-e.top-e.bottom,O=d3.select(this);x=x||o,T=T||u,N=N||a,k=k.map(function(e,t){return e.values=e.values.map(function(e){return e.series=t,e}),e});var M=b&&w&&E?[]:k.map(function(e){return e.values.map(function(e,t){return{x:f(e,t),y:l(e,t),size:c(e,t)}})});o.domain(b||d3.extent(d3.merge(M).map(function(e){return e.x}).concat(h))).range([0,L]),u.domain(w||d3.extent(d3.merge(M).map(function(e){return e.y}).concat(p))).range([A,0]),a.domain(E||d3.extent(d3.merge(M).map(function(e){return e.size}).concat(d))).range([16,256]);var _=O.selectAll("g.wrap.scatter").data([k]),D=_.enter().append("g").attr("class","wrap nvd3 scatter chart-"+s),P=D.append("defs"),H=D.append("g"),B=_.select("g");H.append("g").attr("class","groups"),_.attr("transform","translate("+e.left+","+e.top+")"),P.append("clipPath").attr("id","edge-clip-"+s).append("rect"),_.select("#edge-clip-"+s+" rect").attr("width",L).attr("height",A),B.attr("clip-path",m?"url(#edge-clip-"+s+")":"");var F=_.select(".groups").selectAll(".group").data(function(e){return e},function(e){return e.key});F.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(F.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),F.attr("class",function(e,t){return"group series-"+t}).classed("hover",function(e){return e.hover}),d3.transition(F).style("fill",function(e,t){return r[t%r.length]}).style("stroke",function(e,t){return r[t%r.length]}).style("stroke-opacity",1).style("fill-opacity",.5);var I=F.selectAll("path.point").data(function(e){return e.values});I.enter().append("path").attr("transform",function(e,t){return"translate("+x(f(e,t))+","+T(l(e,t))+")"}).attr("d",d3.svg.symbol().type(function(e,t){return e.shape||i}).size(function(e,t){return a(c(e,t))})),d3.transition(F.exit().selectAll("path.point")).attr("transform",function(e,t){return"translate("+o(f(e,t))+","+u(l(e,t))+")"}).remove(),I.attr("class",function(e,t){return"point point-"+t}),d3.transition(I).attr("transform",function(e,t){return"translate("+o(f(e,t))+","+u(l(e,t))+")"}).attr("d",d3.svg.symbol().type(function(e,t){return e.shape||i}).size(function(e,t){return a(c(e,t))})),clearTimeout(C),C=setTimeout(j,750),x=o.copy(),T=u.copy(),N=a.copy()}),k}var e={top:0,right:0,bottom:0,left:0},t=960,n=500,r=d3.scale.category20().range(),i="circle",s=Math.floor(Math.random()*1e5),o=d3.scale.linear(),u=d3.scale.linear(),a=d3.scale.linear(),f=function(e){return e.x},l=function(e){return e.y},c=function(e){return e.size},h=[],p=[],d=[],v=!0,m=!1,g=!0,y=function(){return 25},b,w,E,S=d3.dispatch("elementClick","elementMouseover","elementMouseout"),x,T,N,C;return k.dispatch=S,k.x=function(e){return arguments.length?(f=d3.functor(e),k):f},k.y=function(e){return arguments.length?(l=d3.functor(e),k):l},k.size=function(e){return arguments.length?(c=d3.functor(e),k):c},k.margin=function(t){return arguments.length?(e=t,k):e},k.width=function(e){return arguments.length?(t=e,k):t},k.height=function(e){return arguments.length?(n=e,k):n},k.xScale=function(e){return arguments.length?(o=e,k):o},k.yScale=function(e){return arguments.length?(u=e,k):u},k.zScale=function(e){return arguments.length?(a=e,k):a},k.xDomain=function(e){return arguments.length?(b=e,k):b},k.yDomain=function(e){return arguments.length?(w=e,k):w},k.sizeDomain=function(e){return arguments.length?(E=e,k):E},k.forceX=function(e){return arguments.length?(h=e,k):h},k.forceY=function(e){return arguments.length?(p=e,k):p},k.forceSize=function(e){return arguments.length?(d=e,k):d},k.interactive=function(e){return arguments.length?(v=e,k):v},k.clipEdge=function(e){return arguments.length?(m=e,k):m},k.clipVoronoi=function(e){return arguments.length?(g=e,k):g},k.clipRadius=function(e){return arguments.length?(y=e,k):y},k.color=function(e){return arguments.length?(r=e,k):r},k.shape=function(e){return arguments.length?(i=e,k):i},k.id=function(e){return arguments.length?(s=e,k):s},k},e.models.scatterChart=function(){function A(s){return s.each(function(o){function H(){if(l)return D.select(".point-paths").style("pointer-events","all"),!1;D.select(".background").style("pointer-events","all"),D.select(".point-paths").style("pointer-events","none");var e=d3.mouse(this);v.distortion(f).focus(e[0]),m.distortion(f).focus(e[1]),P.call(g),D.select(".x.axis").call(y),D.select(".y.axis").call(b),D.select(".distributionX").datum(o.filter(function(e){return!e.disabled})).call(S),D.select(".distributionY").datum(o.filter(function(e){return!e.disabled})).call(x)}var h=d3.select(this),p=this,d=(n||parseInt(h.style("width"))||960)-t.left-t.right,O=(r||parseInt(h.style("height"))||400)-t.top-t.bottom;N=N||g.xScale(),C=C||g.yScale();var M=h.selectAll("g.wrap.scatterChart").data([o]),_=M.enter().append("g").attr("class","wrap nvd3 scatterChart chart-"+g.id()).append("g");_.append("rect").attr("class","nvd3 background").attr("width",d).attr("height",O),_.append("g").attr("class","x axis"),_.append("g").attr("class","y axis"),_.append("g").attr("class","scatterWrap"),_.append("g").attr("class","distWrap"),_.append("g").attr("class","legendWrap"),_.append("g").attr("class","controlsWrap");var D=M.select("g");u&&(w.width(d/2),M.select(".legendWrap").datum(o).call(w),t.top!=w.height()&&(t.top=w.height(),O=(r||parseInt(h.style("height"))||400)-t.top-t.bottom),M.select(".legendWrap").attr("transform","translate("+d/2+","+ -t.top+")")),a&&(E.width(180).color(["#444"]),D.select(".controlsWrap").datum(L).attr("transform","translate(0,"+ -t.top+")").call(E)),g.width(d).height(O).color(o.map(function(e,t){return e.color||i[t%i.length]}).filter(function(e,t){return!o[t].disabled})),D.attr("transform","translate("+t.left+","+t.top+")");var P=M.select(".scatterWrap").datum(o.filter(function(e){return!e.disabled}));d3.transition(P).call(g),y.ticks(d/100).tickSize(-O,0),D.select(".x.axis").attr("transform","translate(0,"+m.range()[0]+")"),d3.transition(D.select(".x.axis")).call(y),b.ticks(O/36).tickSize(-d,0),d3.transition(D.select(".y.axis")).call(b),S.width(d).color(o.map(function(e,t){return e.color||i[t%i.length]}).filter(function(e,t){return!o[t].disabled})),_.select(".distWrap").append("g").attr("class","distributionX").attr("transform","translate(0,"+m.range()[0]+")"),D.select(".distributionX").datum(o.filter(function(e){return!e.disabled})).call(S),x.width(O).color(o.map(function(e,t){return e.color||i[t%i.length]}).filter(function(e,t){return!o[t].disabled})),_.select(".distWrap").append("g").attr("class","distributionY").attr("transform","translate(-"+x.size()+",0)"),D.select(".distributionY").datum(o.filter(function(e){return!e.disabled})).call(x),D.select(".background").on("mousemove",H),D.select(".background").on("click",function(){l=!l}),E.dispatch.on("legendClick",function(e,t){e.disabled=!e.disabled,f=e.disabled?0:2.5,D.select(".background").style("pointer-events",e.disabled?"none":"all"),D.select(".point-paths").style("pointer-events",e.disabled?"all":"none"),e.disabled?(v.distortion(f).focus(0),m.distortion(f).focus(0),P.call(g),D.select(".x.axis").call(y),D.select(".y.axis").call(b)):l=!1,s.transition().call(A)}),w.dispatch.on("legendClick",function(e,t,n){e.disabled=!e.disabled,o.filter(function(e){return!e.disabled}).length||o.map(function(e){return e.disabled=!1,M.selectAll(".series").classed("disabled",!1),e}),s.transition().call(A)}),g.dispatch.on("elementMouseover.tooltip",function(e){d3.select(".chart-"+g.id()+" .series-"+e.seriesIndex+" .distx-"+e.pointIndex).attr("y1",e.pos[1]-O),d3.select(".chart-"+g.id()+" .series-"+e.seriesIndex+" .disty-"+e.pointIndex).attr("x2",e.pos[0]+S.size()),e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],T.tooltipShow(e)}),c&&T.on("tooltipShow",function(e){k(e,p.parentNode)}),g.dispatch.on("elementMouseout.tooltip",function(e){T.tooltipHide(e),d3.select(".chart-"+g.id()+" .series-"+e.seriesIndex+" .distx-"+e.pointIndex).attr("y1",0),d3.select(".chart-"+g.id()+" .series-"+e.seriesIndex+" .disty-"+e.pointIndex).attr("x2",x.size())}),c&&T.on("tooltipHide",e.tooltip.cleanup),N=v.copy(),C=m.copy(),A.update=function(){s.transition().call(A)},A.container=this}),A}var t={top:30,right:20,bottom:50,left:60},n=null,r=null,i=d3.scale.category20().range(),s=!1,o=!1,u=!0,a=!0,f=0,l=!1,c=!0,h=function(e,t,n){return""+t+""},p=function(e,t,n){return""+n+""},d=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},v=d3.fisheye.scale(d3.scale.linear).distortion(0),m=d3.fisheye.scale(d3.scale.linear).distortion(0),g=e.models.scatter().xScale(v).yScale(m),y=e.models.axis().orient("bottom").scale(v).tickPadding(10),b=e.models.axis().orient("left").scale(m).tickPadding(10),w=e.models.legend().height(30),E=e.models.legend().height(30),S=e.models.distribution().axis("x").scale(v),x=e.models.distribution().axis("y").scale(m),T=d3.dispatch("tooltipShow","tooltipHide"),N,C,k=function(n,r){var i=n.pos[0]+(r.offsetLeft||0),s=m.range()[0]+t.top+(r.offsetTop||0),o=v.range()[0]+t.left+(r.offsetLeft||0),u=n.pos[1]+(r.offsetTop||0),a=y.tickFormat()(g.x()(n.point)),f=b.tickFormat()(g.y()(n.point)),l=h(n.series.key,a,f,n,A),c=p(n.series.key,a,f,n,A);e.tooltip.show([i,s],l,"n",1),e.tooltip.show([o,u],c,"e",1)},L=[{key:"Magnify",disabled:!0}];return A.dispatch=T,A.legend=w,A.xAxis=y,A.yAxis=b,d3.rebind(A,g,"interactive","shape","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius","fisheye","fisheyeRadius"),A.margin=function(e){return arguments.length?(t=e,A):t},A.width=function(e){return arguments.length?(n=e,A):n},A.height=function(e){return arguments.length?(r=e,A):r},A.color=function(e){return arguments.length?(i=e,w.color(e),S.color(e),x.color(e),A):i},A.showDistX=function(e){return arguments.length?(s=e,A):s},A.showDistY=function(e){return arguments.length?(o=e,A):o},A.showControls=function(e){return arguments.length?(a=e,A):a},A.showLegend=function(e){return arguments.length?(u=e,A):u},A.fisheye=function(e){return arguments.length?(f=e,A):f},A.tooltips=function(e){return arguments.length?(c=e,A):c},A.tooltipContent=function(e){return arguments.length?(d=e,A):d},A},e.models.sparkline=function(){function c(r){return r.each(function(r){var c=t-e.left-e.right,h=n-e.top-e.bottom;f.domain(u||d3.extent(r,i)).range([0,c]),l.domain(a||d3.extent(r,s)).range([h,0]);var p=d3.select(this).selectAll("g.sparkline").data([r]),d=p.enter().append("g").attr("class","nvd3 sparkline");d.attr("transform","translate("+e.left+","+e.top+")").style("stroke",function(e,t){return e.color||o[t*o.length]});var v=d.selectAll("path").data(function(e){return[e]});v.enter().append("path"),v.exit().remove(),v.attr("d",d3.svg.line().x(function(e,t){return f(i(e,t))}).y(function(e,t){return l(s(e,t))}));var m=d.selectAll("circle.point").data(function(e){return e.filter(function(e,t){return l.domain().indexOf(s(e,t))!=-1||i(e,t)==f.domain()[1]})});m.enter().append("circle").attr("class","point"),m.exit().remove(),m.attr("cx",function(e,t){return f(i(e,t))}).attr("cy",function(e,t){return l(s(e,t))}).attr("r",2).style("stroke",function(e,t){return e.x==f.domain()[1]?"#444":e.y==l.domain()[0]?"#d62728":"#2ca02c"}).style("fill",function(e,t){return e.x==f.domain()[1]?"#444":e.y==l.domain()[0]?"#d62728":"#2ca02c"})}),c}var e={top:0,right:0,bottom:0,left:0},t=400,n=32,r=!0,i=function(e){return e.x},s=function(e){return e.y},o=d3.scale.category20().range(),u,a,f=d3.scale.linear(),l=d3.scale.linear();return c.margin=function(t){return arguments.length?(e=t,c):e},c.width=function(e){return arguments.length?(t=e,c):t},c.height=function(e){return arguments.length?(n=e,c):n},c.x=function(e){return arguments.length?(i=d3.functor(e),c):i},c.y=function(e){return arguments.length?(s=d3.functor(e),c):s},c.xDomain=function(e){return arguments.length?(u=e,c):u},c.yDomain=function(e){return arguments.length?(a=e,c):a},c.animate=function(e){return arguments.length?(r=e,c):r},c},e.models.sparklinePlus=function(){function d(e){return e.each(function(e){function T(){var n=d3.event.offsetX-t.left;w.attr("x1",n).attr("x2",n),E.attr("transform",function(e){return"translate("+(n-6)+","+ -t.top+")"}).text(f(Math.round(c.invert(n)))),S.attr("transform",function(e){return"translate("+(n+6)+","+ -t.top+")"}).text(l(o(e[Math.round(c.invert(n))])))}var i=n-t.left-t.right,a=r-t.top-t.bottom;c.domain(d3.extent(e,s)).range([0,i]),h.domain(d3.extent(e,o)).range([a,0]);var d=d3.select(this).selectAll("g.sparklineplus").data([e]),v=d.enter().append("g"),m=v.append("g").attr("class","nvd3 sparklineplus").attr("transform","translate("+t.left+","+t.top+")").style("stroke",function(e,t){return e.color||u[t%u.length]});p.xDomain(c.domain()).yDomain(h.domain()),m.call(p);var g=m.append("g").attr("class","hoverValue"),b=m.append("g").attr("class","hoverArea");g.attr("transform",function(e){return"translate("+c(e)+",0)"});var w=g.append("line").attr("x1",c.range()[1]).attr("y1",-t.top).attr("x2",c.range()[1]).attr("y2",r),E=g.append("text").attr("class","xValue").attr("text-anchor","end").attr("dy",".9em"),S=g.append("text").attr("class","yValue").attr("text-anchor","start").attr("dy",".9em");b.append("rect").attr("width",i).attr("height",a).on("mousemove",T)}),d}var t={top:15,right:40,bottom:3,left:40},n=400,r=50,i=!0,s=function(e){return e.x},o=function(e){return e.y},u=d3.scale.category20().range(),a=Math.floor(Math.random()*1e5),f=d3.format(",r"),l=d3.format(",.2f"),c=d3.scale.linear(),h=d3.scale.linear(),p=e.models.sparkline();return d.margin=function(e){return arguments.length?(t=e,d):t},d.width=function(e){return arguments.length?(n=e,p.width(e-t.left-t.right),d):n},d.height=function(e){return arguments.length?(r=e,p.height(e-t.top-t.bottom),d):r},d.x=function(e){return arguments.length?(s=d3.functor(e),p.x(e),d):s},d.y=function(e){return arguments.length?(o=d3.functor(e),p.y(e),d):o},d.id=function(e){return arguments.length?(a=e,d):a},d.animate=function(e){return arguments.length?(i=e,d):i},d},e.models.stackedArea=function(){function g(e){return e.each(function(e){var a=n-t.left-t.right,h=r-t.top-t.bottom;e=e.map(function(e,t){return e.values=e.values.map(function(t,n){return t.index=n,t.stackedY=e.disabled?0:u(t,n),t}),e}),e=d3.layout.stack().order(l).offset(f).values(function(e){return e.values}).x(o).y(function(e){return e.stackedY}).out(function(e,t,n){e.display={y:n,y0:t}})(e);var g=d3.select(this).selectAll("g.wrap.stackedarea").data([e]),b=g.enter().append("g").attr("class","wrap nvd3 stackedarea"),w=b.append("defs"),E=b.append("g"),S=g.select("g");E.append("g").attr("class","areaWrap"),p.width(a).height(h).x(o).y(function(e){return e.display.y+e.display.y0}).forceY([0]).color(e.map(function(e,t){return e.color||i[t%i.length]}).filter(function(t,n){return!e[n].disabled})),E.append("g").attr("class","scatterWrap");var T=S.select(".scatterWrap").datum(e.filter(function(e){return!e.disabled}));d3.transition(T).call(p),g.attr("transform","translate("+t.left+","+t.top+")"),w.append("clipPath").attr("id","edge-clip-"+s).append("rect"),g.select("#edge-clip-"+s+" rect").attr("width",a).attr("height",h),S.attr("clip-path",c?"url(#edge-clip-"+s+")":"");var N=d3.svg.area().x(function(e,t){return d(o(e,t))}).y0(function(e){return v(e.display.y0)}).y1(function(e){return v(e.display.y+e.display.y0)}),C=d3.svg.area().x(function(e,t){return d(o(e,t))}).y0(function(e){return v(e.display.y0)}).y1(function(e){return v(e.display.y0)}),k=S.select(".areaWrap").selectAll("path.area").data(function(e){return e});k.enter().append("path").attr("class",function(e,t){return"area area-"+t}).on("mouseover",function(e,t){d3.select(this).classed("hover",!0),m.areaMouseover({point:e,series:e.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:t})}).on("mouseout",function(e,t){d3.select(this).classed("hover",!1),m.areaMouseout({point:e,series:e.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:t})}).on("click",function(e,t){d3.select(this).classed("hover",!1),m.areaClick({point:e,series:e.key,pos:[d3.event.pageX,d3.event.pageY],seriesIndex:t})}),d3.transition(k.exit()).attr("d",function(e,t){return C(e.values,t)}).remove(),k.style("fill",function(e,t){return e.color||i[t%i.length]}).style("stroke",function(e,t){return e.color||i[t%i.length]}),d3.transition(k).attr("d",function(e,t){return N(e.values,t)}),p.dispatch.on("elementClick.area",function(e){m.areaClick(e)}),p.dispatch.on("elementMouseover.area",function(e){S.select(".area-"+e.seriesIndex).classed("hover",!0)}),p.dispatch.on("elementMouseout.area",function(e){S.select(".area-"+e.seriesIndex).classed("hover",!1)})}),g}var t={top:0,right:0,bottom:0,left:0},n=960,r=500,i=d3.scale.category20().range(),s=Math.floor(Math.random()*1e5),o=function(e){return e.x},u=function(e){return e.y},a="stack",f="zero",l="default",c=!1,h=d3.layout.stack().values(function(e){return e.values}).x(o).y(function(e){return e.stackedY}).out(function(e,t,n){e.display={y:n,y0:t}}),p=e.models.scatter().size(2.2).sizeDomain([2.5]),d=p.xScale(),v=p.yScale(),m=d3.dispatch("tooltipShow","tooltipHide","areaClick","areaMouseover","areaMouseout");return g.dispatch=m,g.scatter=p,d3.rebind(g,p,"interactive","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius"),g.x=function(e){return arguments.length?(o=d3.functor(e),g):o},g.y=function(e){return arguments.length?(u=d3.functor(e),g):u},g.margin=function(e){return arguments.length?(t=e,g):t},g.width=function(e){return arguments.length?(n=e,g):n},g.height=function(e){return arguments.length?(r=e,g):r},g.clipEdge=function(e){return arguments.length?(c=e,g):c},g.color=function(e){return arguments.length?(i=e,g):i},g.offset=function(e){return arguments.length?(f=e,g):f},g.order=function(e){return arguments.length?(l=e,g):l},g.style=function(e){if(!arguments.length)return a;a=e;switch(a){case"stack":g.offset("zero"),g.order("default");break;case"stream":g.offset("wiggle"),g.order("inside-out");break;case"expand":g.offset("expand"),g.order("default")}return g},p.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],m.tooltipShow(e)}),p.dispatch.on("elementMouseout.tooltip",function(e){m.tooltipHide(e)}),g},e.models.stackedAreaChart=function(){function b(i){return i.each(function(a){var l=d3.select(this),c=this,w=(n||parseInt(l.style("width"))||960)-t.left-t.right,E=(r||parseInt(l.style("height"))||400)-t.top-t.bottom,S=l.selectAll("g.wrap.stackedAreaChart").data([a]),x=S.enter().append("g").attr("class","wrap nvd3 stackedAreaChart").append("g");x.append("g").attr("class","x axis"),x.append("g").attr("class","y axis"),x.append("g").attr("class","stackedWrap"),x.append("g").attr("class","legendWrap"),x.append("g").attr("class","controlsWrap");var T=S.select("g");o&&(d.width(w/2),T.select(".legendWrap").datum(a).call(d),t.top!=d.height()&&(t.top=d.height(),E=(r||parseInt(l.style("height"))||400)-t.top-t.bottom),T.select(".legendWrap").attr("transform","translate("+(w/2-t.left)+","+ -t.top+")")),f.width(w).height(E),s&&(v.width(280).color(["#444","#444","#444"]),T.select(".controlsWrap").datum(g).attr("transform","translate(0,"+ -t.top+")").call(v)),T.attr("transform","translate("+t.left+","+t.top+")");var N=T.select(".stackedWrap").datum(a);d3.transition(N).call(f),h.ticks(w/100).tickSize(-E,0),T.select(".x.axis").attr("transform","translate(0,"+E+")"),d3.transition(T.select(".x.axis")).call(h),p.ticks(f.offset()=="wiggle"?0:E/36).tickSize(-w,0).tickFormat(f.offset()=="expand"?d3.format("%"):d3.format(",.2f")),d3.transition(T.select(".y.axis")).call(p),f.dispatch.on("areaClick.toggle",function(e){a.filter(function(e){return!e.disabled}).length===1?a=a.map(function(e){return e.disabled=!1,e}):a=a.map(function(t,n){return t.disabled=n!=e.seriesIndex,t}),i.transition().call(b)}),d.dispatch.on("legendClick",function(e,t){e.disabled=!e.disabled,a.filter(function(e){return!e.disabled}).length||a.map(function(e){return e.disabled=!1,e}),i.transition().call(b)}),v.dispatch.on("legendClick",function(e,t){if(!e.disabled)return;g=g.map(function(e){return e.disabled=!0,e}),e.disabled=!1;switch(e.key){case"Stacked":f.style("stack");break;case"Stream":f.style("stream");break;case"Expanded":f.style("expand")}i.transition().call(b)}),f.dispatch.on("tooltipShow",function(e){if(!Math.round(f.y()(e.point)*100))return setTimeout(function(){d3.selectAll(".point.hover").classed("hover",!1)},0),!1;e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],m.tooltipShow(e)}),u&&m.on("tooltipShow",function(e){y(e,c.parentNode)}),f.dispatch.on("tooltipHide",function(e){m.tooltipHide(e)}),u&&m.on("tooltipHide",e.tooltip.cleanup),b.update=function(){i.transition().call(b)},b.container=this}),b}var t={top:30,right:25,bottom:50,left:60},n=null,r=null,i=d3.scale.category20().range(),s=!0,o=!0,u=!0,a=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" on "+t+"

"},f=e.models.stackedArea(),l=f.xScale(),c=f.yScale(),h=e.models.axis().scale(l).orient("bottom").tickPadding(5),p=e.models.axis().scale(c).orient("left"),d=e.models.legend().height(30),v=e.models.legend().height(30),m=d3.dispatch("tooltipShow","tooltipHide"),g=[{key:"Stacked"},{key:"Stream",disabled:!0},{key:"Expanded",disabled:!0}],y=function(t,n){var r=t.pos[0]+(n.offsetLeft||0),i=t.pos[1]+(n.offsetTop||0),s=h.tickFormat()(f.x()(t.point)),o=p.tickFormat()(f.y()(t.point)),u=a(t.series.key,s,o,t,b);e.tooltip.show([r,i],u,t.value<0?"n":"s")};return b.dispatch=m,b.stacked=f,b.xAxis=h,b.yAxis=p,d3.rebind(b,f,"x","y","interactive","offset","order","style","clipEdge","size","forceX","forceY","forceSize"),b.margin=function(e){return arguments.length?(t=e,b):t},b.width=function(e){return arguments.length?(n=e,b):getWidth},b.height=function(e){return arguments.length?(r=e,b):getHeight},b.color=function(e){return arguments.length?(i=e,d.color(e),b):i},b.showControls=function(e){return arguments.length?(s=e,b):s},b.showLegend=function(e){return arguments.length?(o=e,b):o},b.tooltips=function(e){return arguments.length?(u=e,b):u},b.tooltipContent=function(e){return arguments.length?(a=e,b):a},b}})(); \ No newline at end of file diff --git a/src/models/discreteBarChartWithEnabledTooltip.js b/src/models/discreteBarChartWithEnabledTooltip.js new file mode 100644 index 0000000..d4465ca --- /dev/null +++ b/src/models/discreteBarChartWithEnabledTooltip.js @@ -0,0 +1,222 @@ + +nv.models.discreteBarChart = function() { + var margin = {top: 30, right: 20, bottom: 50, left: 60}, + width = null, + height = null, + color = d3.scale.category20().range(), + staggerLabels = false, + tooltips = true, + tooltip = function(key, x, y, e, graph) { + return '

' + x + '

' + + '

' + y + '

' + }; + + + var discretebar = nv.models.discreteBar(), + x = discretebar.xScale(), + y = discretebar.yScale(), + xAxis = nv.models.axis().scale(x).orient('bottom').highlightZero(false).showMaxMin(false), + yAxis = nv.models.axis().scale(y).orient('left'), + dispatch = d3.dispatch('tooltipShow', 'tooltipHide'); + + xAxis.tickFormat(function(d) { return d }); + yAxis.tickFormat(d3.format(',.1f')); + + + var showTooltip = function(e, offsetElement) { + var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), + top = e.pos[1] + ( offsetElement.offsetTop || 0), + x = xAxis.tickFormat()(discretebar.x()(e.point)), + y = yAxis.tickFormat()(discretebar.y()(e.point)), + content = tooltip(e.series.key, x, y, e, chart); + + nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); + }; + + + //TODO: let user select default + var controlsData = [ + { key: 'Grouped' }, + { key: 'Stacked', disabled: true } + ]; + + function chart(selection) { + selection.each(function(data) { + var container = d3.select(this), + that = this; + + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right, + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + + + discretebar + .width(availableWidth) + .height(availableHeight); + + + 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'); + gEnter.append('g').attr('class', 'barsWrap'); + + + + var g = wrap.select('g'); + + + g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + var barsWrap = g.select('.barsWrap') + .datum(data.filter(function(d) { return !d.disabled })) + + + 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 + .ticks( availableWidth / 100 ) + .tickSize(-availableHeight, 0); + + g.select('.x.axis') + .attr('transform', 'translate(0,' + (y.range()[0] + (discretebar.showValues() ? 16 : 0)) + ')') + //d3.transition(g.select('.x.axis')) + g.select('.x.axis').transition().duration(0) + .call(xAxis); + + + var xTicks = g.select('.x.axis').selectAll('g'); + + if (staggerLabels) + xTicks + .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 + .ticks( availableHeight / 36 ) + .tickSize( -availableWidth, 0); + + d3.transition(g.select('.y.axis')) + .call(yAxis); + + + discretebar.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + if (tooltips) dispatch.on('tooltipShow', function(e) { showTooltip(e, that.parentNode) } ); // TODO: maybe merge with above? + + discretebar.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + 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); }; + chart.container = this; // I need a reference to the container in order to have outside code check if the chart is visible or not + + }); + + return chart; + } + + + chart.dispatch = dispatch; + chart.discretebar = discretebar; // really just makign the accessible for discretebar.dispatch, may rethink slightly + chart.xAxis = xAxis; + chart.yAxis = yAxis; + + d3.rebind(chart, discretebar, 'x', 'y', 'xDomain', 'yDomain', 'forceX', 'forceY', 'id', 'showValues', 'valueFormat'); + + + chart.margin = function(_) { + if (!arguments.length) return margin; + margin = _; + return chart; + }; + + chart.width = function(_) { + if (!arguments.length) return width; + width = _; + return chart; + }; + + chart.height = function(_) { + if (!arguments.length) return height; + height = _; + return chart; + }; + + chart.color = function(_) { + if (!arguments.length) return color; + color = _; + discretebar.color(_); + return chart; + }; + + chart.staggerLabels = function(_) { + if (!arguments.length) return staggerLabels; + staggerLabels = _; + return chart; + }; + + chart.tooltips = function(_) { + if (!arguments.length) return tooltips; + tooltips = _; + return chart; + }; + + chart.tooltipContent = function(_) { + if (!arguments.length) return tooltip; + tooltip = _; + return chart; + }; + + + return chart; +} diff --git a/src/models/multiBarChart.js b/src/models/multiBarChart.js index 1e5c83d..64a2198 100644 --- a/src/models/multiBarChart.js +++ b/src/models/multiBarChart.js @@ -31,7 +31,7 @@ nv.models.multiBarChart = function() { y = yAxis.tickFormat()(multibar.y()(e.point)), content = tooltip(e.series.key, x, y, e, chart); - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's'); + nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); }; //TODO: let user select default diff --git a/src/tooltip.js b/src/tooltip.js index 953624d..5225791 100644 --- a/src/tooltip.js +++ b/src/tooltip.js @@ -9,8 +9,8 @@ var nvtooltip = window.nv.tooltip = {}; nvtooltip.show = function() { - var args = arguments; - var pos = args[0], content = args[1], gravity = args[2], dist = args[3], parentId = args[4]; + var args = Array.prototype.slice.call(arguments), + pos = args[0], content = args[1], gravity = args[2], dist = args[3], parentId = args[4]; var container = document.createElement("div"); container.className = "nvtooltip"; @@ -18,7 +18,7 @@ gravity = gravity || 's'; dist = dist || 20; - var body = parentId ? document.getElementById(parentId) : document.getElementsByTagName("body")[0]; + var body = parentId ? parentId : document.getElementsByTagName("body")[0]; container.innerHTML = content; container.style.left = 1;