From 8d9f496286410df8d7be917da70e5852c5eefffe Mon Sep 17 00:00:00 2001 From: Bob Monteverde Date: Mon, 18 Jun 2012 15:42:45 -0400 Subject: [PATCH] LinePlusFocus now rescales when series are removed. Also moved a couple more files to deprecated, and removed from Makefile --- Makefile | 3 - {src/models => deprecated}/bar.js | 0 {examples => deprecated}/linePlusBar.html | 0 {src/models => deprecated}/linePlusBar.js | 0 {examples => deprecated}/lineWithFocus.html | 0 {src/models => deprecated}/lineWithFocus.js | 0 nv.d3.js | 1136 +++---------------- nv.d3.min.js | 7 +- src/models/lineWithFocusChart.js | 2 +- 9 files changed, 145 insertions(+), 1003 deletions(-) rename {src/models => deprecated}/bar.js (100%) rename {examples => deprecated}/linePlusBar.html (100%) rename {src/models => deprecated}/linePlusBar.js (100%) rename {examples => deprecated}/lineWithFocus.html (100%) rename {src/models => deprecated}/lineWithFocus.js (100%) diff --git a/Makefile b/Makefile index cea87c9..7c6d69a 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,6 @@ JS_FILES = \ src/tooltip.js \ src/utils.js \ src/models/axis.js \ - src/models/bar.js \ src/models/historicalBar.js \ src/models/bullet.js \ src/models/cumulativeLine.js \ @@ -14,9 +13,7 @@ JS_FILES = \ src/models/legend.js \ src/models/line.js \ src/models/lineChart.js \ - src/models/linePlusBar.js \ src/models/linePlusBarChart.js \ - src/models/lineWithFocus.js \ src/models/lineWithFocusChart.js \ src/models/multiBar.js \ src/models/multiBarChart.js \ diff --git a/src/models/bar.js b/deprecated/bar.js similarity index 100% rename from src/models/bar.js rename to deprecated/bar.js diff --git a/examples/linePlusBar.html b/deprecated/linePlusBar.html similarity index 100% rename from examples/linePlusBar.html rename to deprecated/linePlusBar.html diff --git a/src/models/linePlusBar.js b/deprecated/linePlusBar.js similarity index 100% rename from src/models/linePlusBar.js rename to deprecated/linePlusBar.js diff --git a/examples/lineWithFocus.html b/deprecated/lineWithFocus.html similarity index 100% rename from examples/lineWithFocus.html rename to deprecated/lineWithFocus.html diff --git a/src/models/lineWithFocus.js b/deprecated/lineWithFocus.js similarity index 100% rename from src/models/lineWithFocus.js rename to deprecated/lineWithFocus.js diff --git a/nv.d3.js b/nv.d3.js index 1590edd..2ec0e74 100644 --- a/nv.d3.js +++ b/nv.d3.js @@ -362,256 +362,6 @@ nv.models.axis = function() { return chart; } -nv.models.bar = function() { - var margin = {top: 20, right: 10, bottom: 80, left: 60}, - width = 960, - height = 500, - animate = 500, - label ='label', - rotatedLabel = true, - showLabels = true, - id = Math.floor(Math.random() * 10000), //Create semi-unique ID in case user doesn't select one - color = d3.scale.category20(), - field ='y', - title = ''; - - var x = d3.scale.ordinal(), - y = d3.scale.linear(), - xAxis = d3.svg.axis().scale(x).orient('bottom'), - yAxis = d3.svg.axis().scale(y).orient('left'), - dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'tooltipShow', 'tooltipHide'); - - - function chart(selection) { - selection.each(function(data) { - x .domain(data.map(function(d,i) { return d[label]; })) - .rangeRoundBands([0, width - margin.left - margin.right], .1); - - - var min = d3.min(data, function(d) { return d[field] }); - var max = d3.max(data, function(d) { return d[field] }); - var x0 = Math.max(-min, max); - var x1 = -x0; - - // If we have no negative values, then lets stack this with just positive bars - if (min >= 0) x1 = 0; - - y .domain([x1, x0]) - .range([height - margin.top - margin.bottom, 0]) - .nice(); - - xAxis.ticks( width / 100 ); - yAxis.ticks( height / 36 ).tickSize(-(width - margin.right - margin.left), 0); - - var parent = d3.select(this) - .on("click", function(d,i) { - dispatch.chartClick({ - data: d, - index: i, - pos: d3.event, - id: id - }); - }); - - - var wrap = parent.selectAll('g.wrap').data([data]); - var gEnter = wrap.enter(); - gEnter.append("text") - .attr("class", "title") - .attr("dy", ".91em") - .attr("text-anchor", "start") - .text(title); - gEnter = gEnter.append('g').attr('class', 'nvd3 wrap').attr('id','wrap-'+id).append('g'); - - - - gEnter.append('g').attr('class', 'x axis'); - gEnter.append('g').attr('class', 'y axis'); - gEnter.append('g').attr('class', 'bars'); - - - wrap.attr('width', width) - .attr('height', height); - - var g = wrap.select('g') - .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - var bars = wrap.select('.bars').selectAll('.bar') - .data(function(d) { return d; }); - - bars.exit().remove(); - - - var barsEnter = bars.enter().append('svg:rect') - .attr('class', function(d) { return d[field] < 0 ? "bar negative" : "bar positive"}) - .attr("fill", function(d, i) { return color(i); }) - .attr('x', 0 ) - .on('mouseover', function(d,i){ - d3.select(this).classed('hover', true); - dispatch.tooltipShow({ - label: d[label], - value: d[field], - data: d, - index: i, - // TODO: Calculate the center to the bar - pos: [d3.event.pageX, d3.event.pageY], - id: id - }); - - }) - .on('mouseout', function(d,i){ - d3.select(this).classed('hover', false); - dispatch.tooltipHide({ - label: d[label], - value: d[field], - data: d, - index: i, - id: id - }); - }) - .on('click', function(d,i) { - dispatch.elementClick({ - label: d[label], - value: d[field], - data: d, - index: i, - pos: d3.event, - id: id - }); - d3.event.stopPropagation(); - }) - .on('dblclick', function(d,i) { - dispatch.elementDblClick({ - label: d[label], - value: d[field], - data: d, - index: i, - pos: d3.event, - id: id - }); - d3.event.stopPropagation(); - }); - - - bars - .attr('class', function(d) { return d[field] < 0 ? "bar negative" : "bar positive"}) - .attr('transform', function(d,i) { return 'translate(' + x(d[label]) + ',0)'; }) - .attr('width', x.rangeBand ) - .order() - .transition() - .duration(animate) - .attr('y', function(d) { return y(Math.max(0, d[field])); }) - .attr('height', function(d) { return Math.abs(y(d[field]) - y(0)); }); - - - g.select('.x.axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')') - .call(xAxis); - - - if (rotatedLabel) { - g.select('.x.axis').selectAll('text').attr('text-anchor','start').attr("transform", function(d) { - return "rotate(35)translate(" + this.getBBox().height/2 + "," + '0' + ")"; - }); - } - if (!showLabels) { - g.select('.x.axis').selectAll('text').attr('fill', 'rgba(0,0,0,0)'); - g.select('.x.axis').selectAll('line').attr('style', 'opacity: 0'); - } - /*else { - g.select('.x.axis').selectAll('text').attr('fill', 'rgba(0,0,0,1)'); - g.select('.x.axis').selectAll('line').attr('style', 'opacity: 1'); - }*/ - - - - g.select('.y.axis') - .call(yAxis); - }); - - return chart; - } - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - if (margin.left + margin.right + 20 > _) - width = margin.left + margin.right + 20; // Min width - else - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - if (margin.top + margin.bottom + 20 > _) - height = margin.top + margin.bottom + 20; // Min height - else - height = _; - return chart; - }; - - chart.animate = function(_) { - if (!arguments.length) return animate; - animate = _; - return chart; - }; - - chart.labelField = function(_) { - if (!arguments.length) return (label); - label = _; - return chart; - }; - - chart.dataField = function(_) { - if (!arguments.length) return (field); - field = _; - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - chart.rotatedLabel = function(_) { - if (!arguments.length) return rotatedLabel; - rotatedLabel = _; - return chart; - }; - - chart.showLabels = function(_) { - if (!arguments.length) return (showLabels); - showLabels = _; - return chart; - }; - - chart.title = function(_) { - if (!arguments.length) return (title); - title = _; - return chart; - }; - - chart.xaxis = {}; - // Expose the x-axis' tickFormat method. - d3.rebind(chart.xaxis, xAxis, 'tickFormat'); - - chart.yaxis = {}; - // Expose the y-axis' tickFormat method. - d3.rebind(chart.yaxis, yAxis, 'tickFormat'); - - chart.dispatch = dispatch; - - return chart; -} - nv.models.historicalBar = function() { var margin = {top: 0, right: 0, bottom: 0, left: 0}, width = 960, @@ -2828,33 +2578,67 @@ nv.models.lineChart = function() { return chart; } -nv.models.linePlusBar = function() { +nv.models.linePlusBarChart = function() { var margin = {top: 30, right: 60, bottom: 50, left: 60}, - getWidth = function() { return 960 }, - getHeight = function() { return 500 }, + width = null, + height = null, dotRadius = function() { return 2.5 }, getX = function(d) { return d.x }, getY = function(d) { return d.y }, color = d3.scale.category20().range(), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'); + showLegend = true, + tooltips = true, + tooltip = function(key, x, y, e, graph) { + return '

' + key + '

' + + '

' + y + ' at ' + x + '

' + }; - var x = d3.scale.linear(), - y1 = d3.scale.linear(), - y2 = d3.scale.linear(), + + var lines = nv.models.line(), + bars = nv.models.historicalBar(), + x = d3.scale.linear(), // needs to be both line and historicalBar x Axis + y1 = bars.yScale(), + y2 = lines.yScale(), xAxis = nv.models.axis().scale(x).orient('bottom'), yAxis1 = nv.models.axis().scale(y1).orient('left'), yAxis2 = nv.models.axis().scale(y2).orient('right'), legend = nv.models.legend().height(30), - lines = nv.models.line(), - bars = nv.models.historicalBar(); + dispatch = d3.dispatch('tooltipShow', 'tooltipHide'); + + var showTooltip = function(e, offsetElement) { + //console.log('left: ' + offsetElement.offsetLeft); + //console.log('top: ' + offsetElement.offsetLeft); + + //TODO: FIX offsetLeft and offSet top do not work if container is shifted anywhere + //var offsetElement = document.getElementById(selector.substr(1)), + var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), + top = e.pos[1] + ( offsetElement.offsetTop || 0), + x = xAxis.tickFormat()(lines.x()(e.point)), + y = yAxis1.tickFormat()(lines.y()(e.point)), + content = tooltip(e.series.key, x, y, e, chart); + + nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's'); + }; + function chart(selection) { selection.each(function(data) { - var width = getWidth(), - height = getHeight(), - availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom; + var container = d3.select(this); + + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right, + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + + + var dataBars = data.filter(function(d) { return !d.disabled && d.bar }); + + var dataLines = data.filter(function(d) { return !d.disabled && !d.bar }); + + + + //TODO: try to remove x scale computation from this layer var series1 = data.filter(function(d) { return !d.disabled && d.bar }) .map(function(d) { @@ -2873,11 +2657,19 @@ nv.models.linePlusBar = function() { x .domain(d3.extent(d3.merge(series1.concat(series2)), function(d) { return d.x } )) .range([0, availableWidth]); - y1 .domain(d3.extent(d3.merge(series1), function(d) { return d.y } )) + + + /* + x .domain(d3.extent(d3.merge(data.map(function(d) { return d.values })), getX )) + .range([0, availableWidth]); + + y1 .domain(d3.extent(d3.merge(dataBars), function(d) { return d.y } )) .range([availableHeight, 0]); - y2 .domain(d3.extent(d3.merge(series2), function(d) { return d.y } )) + y2 .domain(d3.extent(d3.merge(dataLines), function(d) { return d.y } )) .range([availableHeight, 0]); + */ + lines .width(availableWidth) @@ -2905,683 +2697,77 @@ nv.models.linePlusBar = function() { gEnter.append('g').attr('class', 'legendWrap'); - legend.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - if (!data.filter(function(d) { return !d.disabled }).length) { - data.map(function(d) { - d.disabled = false; - wrap.selectAll('.series').classed('disabled', false); - return d; - }); - } + var g = wrap.select('g'); - selection.transition().call(chart); - }); + if (showLegend) { + legend.width(availableWidth); - lines.dispatch.on('elementMouseover.tooltip', function(e) { - dispatch.tooltipShow({ - point: e.point, - series: e.series, - pos: [e.pos[0] + margin.left, e.pos[1] + margin.top], - seriesIndex: e.seriesIndex, - pointIndex: e.pointIndex - }); - }); - - lines.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - - - bars.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - bars.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - - - //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend - margin.top = legend.height(); - - var g = wrap.select('g') - .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - legend.width(width/2 - margin.right); - - g.select('.legendWrap') - .datum(data.map(function(series) { - series.key = series.key + (series.bar ? ' (left axis)' : ' (right axis)'); - return series; - })) - .attr('transform', 'translate(' + (width/2 - margin.left) + ',' + (-margin.top) +')') - .call(legend); - - - var barsData = data.filter(function(d) { return !d.disabled && d.bar }); - - var barsWrap = g.select('.barsWrap') - .datum(barsData.length ? barsData : [{values:[]}]) - //.datum(data.filter(function(d) { return !d.disabled && d.bar })) - - var linesWrap = g.select('.linesWrap') - .datum(data.filter(function(d) { return !d.disabled && !d.bar })) - - - d3.transition(barsWrap).call(bars); - d3.transition(linesWrap).call(lines); - - - xAxis - .domain(x.domain()) - .range(x.range()) - .ticks( width / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.x.axis') - .attr('transform', 'translate(0,' + y1.range()[0] + ')'); - d3.transition(g.select('.x.axis')) - .call(xAxis); - - yAxis1 - .domain(y1.domain()) - .range(y1.range()) - .ticks( height / 36 ) - .tickSize(-availableWidth, 0); - - d3.transition(g.select('.y1.axis')) - .call(yAxis1); - - yAxis2 - .domain(y2.domain()) - .range(y2.range()) - .ticks( height / 36 ) - .tickSize(series1.length ? 0 : -availableWidth, 0); // Show the y2 rules only if y1 has none - - g.select('.y2.axis') - .attr('transform', 'translate(' + x.range()[1] + ',0)'); - - d3.transition(g.select('.y2.axis')) - .call(yAxis2); - - }); - - return chart; - } - - chart.dispatch = dispatch; - chart.legend = legend; - chart.lines = lines; - chart.bars = bars; - chart.xAxis = xAxis; - chart.yAxis1 = yAxis1; - chart.yAxis2 = yAxis2; - - //d3.rebind(chart, lines, 'interactive'); - //consider rebinding x and y as well - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - lines.x(_); - bars.x(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - lines.y(_); - bars.y(_); - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return getWidth; - getWidth = d3.functor(_); - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return getHeight; - getHeight = d3.functor(_); - return chart; - }; - - chart.dotRadius = function(_) { - if (!arguments.length) return dotRadius; - dotRadius = d3.functor(_); - lines.dotRadius = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = _; - legend.color(_); - return chart; - }; - - return chart; -} - -nv.models.linePlusBarChart = function() { - var margin = {top: 30, right: 60, bottom: 50, left: 60}, - width = null, - height = null, - dotRadius = function() { return 2.5 }, - getX = function(d) { return d.x }, - getY = function(d) { return d.y }, - color = d3.scale.category20().range(), - showLegend = true, - tooltips = true, - tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' - }; - - - var lines = nv.models.line(), - bars = nv.models.historicalBar(), - x = d3.scale.linear(), // needs to be both line and historicalBar x Axis - y1 = bars.yScale(), - y2 = lines.yScale(), - xAxis = nv.models.axis().scale(x).orient('bottom'), - yAxis1 = nv.models.axis().scale(y1).orient('left'), - yAxis2 = nv.models.axis().scale(y2).orient('right'), - legend = nv.models.legend().height(30), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'); - - var showTooltip = function(e, offsetElement) { - //console.log('left: ' + offsetElement.offsetLeft); - //console.log('top: ' + offsetElement.offsetLeft); - - //TODO: FIX offsetLeft and offSet top do not work if container is shifted anywhere - //var offsetElement = document.getElementById(selector.substr(1)), - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines.x()(e.point)), - y = yAxis1.tickFormat()(lines.y()(e.point)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's'); - }; - - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this); - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - - var dataBars = data.filter(function(d) { return !d.disabled && d.bar }); - - var dataLines = data.filter(function(d) { return !d.disabled && !d.bar }); - - - - //TODO: try to remove x scale computation from this layer - - var series1 = data.filter(function(d) { return !d.disabled && d.bar }) - .map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i) } - }) - }); - - var series2 = data.filter(function(d) { return !d.disabled && !d.bar }) - .map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i) } - }) - }); - - x .domain(d3.extent(d3.merge(series1.concat(series2)), function(d) { return d.x } )) - .range([0, availableWidth]); - - - - /* - x .domain(d3.extent(d3.merge(data.map(function(d) { return d.values })), getX )) - .range([0, availableWidth]); - - y1 .domain(d3.extent(d3.merge(dataBars), function(d) { return d.y } )) - .range([availableHeight, 0]); - - y2 .domain(d3.extent(d3.merge(dataLines), function(d) { return d.y } )) - .range([availableHeight, 0]); - */ - - - lines - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color[i % 10]; - }).filter(function(d,i) { return !data[i].disabled && !data[i].bar })) - - bars - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color[i % 10]; - }).filter(function(d,i) { return !data[i].disabled && data[i].bar })) - - - var wrap = d3.select(this).selectAll('g.wrap.linePlusBar').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 linePlusBar').append('g'); - - gEnter.append('g').attr('class', 'x axis'); - gEnter.append('g').attr('class', 'y1 axis'); - gEnter.append('g').attr('class', 'y2 axis'); - gEnter.append('g').attr('class', 'barsWrap'); - gEnter.append('g').attr('class', 'linesWrap'); - gEnter.append('g').attr('class', 'legendWrap'); - - - - var g = wrap.select('g'); - - - if (showLegend) { - legend.width(availableWidth); - - g.select('.legendWrap') - .datum(data.map(function(series) { - series.key = series.key + (series.bar ? ' (left axis)' : ' (right axis)'); - return series; - })) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - g.select('.legendWrap') - .attr('transform', 'translate(0,' + (-margin.top) +')'); - } - - - - var barsWrap = g.select('.barsWrap') - .datum(dataBars.length ? dataBars : [{values:[]}]) - - var linesWrap = g.select('.linesWrap') - .datum(dataLines.length ? dataLines : [{values:[]}]) - - - d3.transition(barsWrap).call(bars); - d3.transition(linesWrap).call(lines); - - - g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - xAxis - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.x.axis') - .attr('transform', 'translate(0,' + y1.range()[0] + ')'); - d3.transition(g.select('.x.axis')) - .call(xAxis); - - - yAxis1 - .ticks( availableHeight / 36 ) - .tickSize(-availableWidth, 0); - - d3.transition(g.select('.y1.axis')) - .call(yAxis1); - - - yAxis2 - .ticks( availableHeight / 36 ) - .tickSize(dataBars.length ? 0 : -availableWidth, 0); // Show the y2 rules only if y1 has none - - g.select('.y2.axis') - .attr('transform', 'translate(' + x.range()[1] + ',0)'); - - d3.transition(g.select('.y2.axis')) - .call(yAxis2); - - - - legend.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - - if (!data.filter(function(d) { return !d.disabled }).length) { - data.map(function(d) { - d.disabled = false; - wrap.selectAll('.series').classed('disabled', false); - return d; - }); - } - - selection.transition().call(chart); - }); - - - lines.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, container[0][0]) } ); // TODO: maybe merge with above? - - lines.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - if (tooltips) dispatch.on('tooltipHide', nv.tooltip.cleanup); - - - bars.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, container[0][0]) } ); // TODO: maybe merge with above? - - bars.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - if (tooltips) dispatch.on('tooltipHide', nv.tooltip.cleanup); - - - chart.update = function() { selection.transition().call(chart) }; - - }); - - return chart; - } - - chart.dispatch = dispatch; - chart.legend = legend; - chart.lines = lines; - chart.bars = bars; - chart.xAxis = xAxis; - chart.yAxis1 = yAxis1; - chart.yAxis2 = yAxis2; - - d3.rebind(chart, lines, 'size', 'clipVoronoi'); - //d3.rebind(chart, lines, 'x', 'y', 'size', 'xDomain', 'yDomain', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id'); - - //d3.rebind(chart, lines, 'interactive'); - //consider rebinding x and y as well - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - lines.x(_); - bars.x(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - lines.y(_); - bars.y(_); - return chart; - }; - - 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 = _; - legend.color(_); - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - 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; -} - -nv.models.lineWithFocus = function() { - var margin = {top: 30, right: 20, bottom: 30, left: 60}, - margin2 = {top: 0, right: 20, bottom: 20, left: 60}, - width = 960, - height = 500, - height1 = 400, - height2 = 100, - color = d3.scale.category20().range(), - getX = function(d) { return d.x }, - getY = function(d) { return d.y }, - id = Math.floor(Math.random() * 10000); //Create semi-unique ID incase user doesn't select one - - var x = d3.scale.linear(), - y = d3.scale.linear(), - x2 = d3.scale.linear(), - y2 = d3.scale.linear(), - xAxis = nv.models.axis().scale(x).orient('bottom'), - yAxis = nv.models.axis().scale(y).orient('left'), - xAxis2 = nv.models.axis().scale(x2).orient('bottom'), - yAxis2 = nv.models.axis().scale(y2).orient('left'), - legend = nv.models.legend().height(30), - focus = nv.models.line().clipEdge(true), - context = nv.models.line().interactive(false), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'), - brush = d3.svg.brush() - .x(x2); - - - //var wrap, gEnter, g, focus, focusLines, contextWrap, focusWrap, contextLines; //brought all variables to this scope for use within brush function... is this a bad idea? - - //var seriesData; //Temporarily bringing this data to this scope.... may be bad idea (same with above).. may need to rethink brushing - - function chart(selection) { - selection.each(function(data) { - var seriesData = data.filter(function(d) { return !d.disabled }) - .map(function(d) { return d.values }), - availableWidth = width - margin.left - margin.right, - availableHeight1 = height1 - margin.top - margin.bottom, - availableHeight2 = height2 - margin2.top - margin2.bottom; - - x2 .domain(d3.extent(d3.merge(seriesData), getX )) - .range([0, availableWidth]); - y2 .domain(d3.extent(d3.merge(seriesData), getY )) - .range([availableHeight2, 0]); - - x .domain(brush.empty() ? x2.domain() : brush.extent()) - .range([0, availableWidth]); - y .domain(y2.domain()) - .range([availableHeight1, 0]); - - brush.on('brush', onBrush); - - focus - .width(availableWidth) - .height(availableHeight1) - .color(data.map(function(d,i) { - return d.color || color[i % 10]; - }).filter(function(d,i) { return !data[i].disabled })) - - context - .width(availableWidth) - .height(availableHeight2) - .color(data.map(function(d,i) { - return d.color || color[i % 10]; - }).filter(function(d,i) { return !data[i].disabled })) - - - updateFocus(); - - - var wrap = d3.select(this).selectAll('g.wrap').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 lineWithFocus').append('g'); - - gEnter.append('g').attr('class', 'focus'); - gEnter.append('g').attr('class', 'context'); - gEnter.append('g').attr('class', 'legendWrap'); - - - - var g = wrap.select('g') - //.attr('transform', 'translate(0,0)'); - - - - - // ********** LEGEND ********** - - legend.width(width/2 - margin.right); - - g.select('.legendWrap') - .datum(data) - .attr('transform', 'translate(' + (availableWidth / 2) + ',0)') + g.select('.legendWrap') + .datum(data.map(function(series) { + series.key = series.key + (series.bar ? ' (left axis)' : ' (right axis)'); + return series; + })) .call(legend); + if ( margin.top != legend.height()) { + margin.top = legend.height(); + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + } - //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend - margin.top = legend.height(); - + g.select('.legendWrap') + .attr('transform', 'translate(0,' + (-margin.top) +')'); + } - // ********** FOCUS ********** + var barsWrap = g.select('.barsWrap') + .datum(dataBars.length ? dataBars : [{values:[]}]) - var focusWrap = g.select('.focus') - .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + var linesWrap = g.select('.linesWrap') + .datum(dataLines.length ? dataLines : [{values:[]}]) - gEnter.select('.focus').append('g').attr('class', 'x axis'); - gEnter.select('.focus').append('g').attr('class', 'y axis'); - gEnter.select('.focus').append('g').attr('class', 'focusLines'); + d3.transition(barsWrap).call(bars); + d3.transition(linesWrap).call(lines); - var focusLines = focusWrap.select('.focusLines') - .datum(data.filter(function(d) { return !d.disabled })) - d3.transition(focusLines).call(focus); + g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); xAxis - .domain(x.domain()) - .range(x.range()) - .ticks( width / 100 ) - .tickSize(-(availableHeight1), 0); + .ticks( availableWidth / 100 ) + .tickSize(-availableHeight, 0); - focusWrap.select('.x.axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); + g.select('.x.axis') + .attr('transform', 'translate(0,' + y1.range()[0] + ')'); d3.transition(g.select('.x.axis')) .call(xAxis); - yAxis - .domain(y.domain()) - .range(y.range()) - .ticks( height / 36 ) - .tickSize(-(availableWidth), 0); - - d3.transition(g.select('.y.axis')) - .call(yAxis); - - - - - // ********** CONTEXT ********** - var contextWrap = g.select('.context') - .attr('transform', 'translate(' + margin2.left + ',' + height1 + ')'); - - gEnter.select('.context').append('g').attr('class', 'x2 axis'); - gEnter.select('.context').append('g').attr('class', 'y2 axis'); - gEnter.select('.context').append('g').attr('class', 'contextLines'); - gEnter.select('.context').append('g').attr('class', 'x brush') - .attr('class', 'x brush') - .call(brush) - .selectAll('rect') - .attr('y', -5) - .attr('height', height2 + 4); - - var contextLines = contextWrap.select('.contextLines') - .datum(data.filter(function(d) { return !d.disabled })) - - d3.transition(contextLines).call(context); - - - xAxis2 - .domain(x2.domain()) - .range(x2.range()) - .ticks( width / 100 ) - .tickSize(-(availableHeight2), 0); + yAxis1 + .ticks( availableHeight / 36 ) + .tickSize(-availableWidth, 0); - contextWrap.select('.x2.axis') - .attr('transform', 'translate(0,' + y2.range()[0] + ')'); - d3.transition(contextWrap.select('.x2.axis')) - .call(xAxis2); + d3.transition(g.select('.y1.axis')) + .call(yAxis1); yAxis2 - .domain(y2.domain()) - .range(y2.range()) - .ticks( availableHeight2 / 24 ) - .tickSize(-(availableWidth), 0); + .ticks( availableHeight / 36 ) + .tickSize(dataBars.length ? 0 : -availableWidth, 0); // Show the y2 rules only if y1 has none - contextWrap.select('.y2.axis'); + g.select('.y2.axis') + .attr('transform', 'translate(' + x.range()[1] + ',0)'); - d3.transition(contextWrap.select('.y2.axis')) + d3.transition(g.select('.y2.axis')) .call(yAxis2); - - - - // ********** EVENT LISTENERS ********** - - legend.dispatch.on('legendClick', function(d,i) { + legend.dispatch.on('legendClick', function(d,i) { d.disabled = !d.disabled; if (!data.filter(function(d) { return !d.disabled }).length) { @@ -3595,94 +2781,65 @@ nv.models.lineWithFocus = function() { selection.transition().call(chart); }); -/* - legend.dispatch.on('legendMouseover', function(d, i) { - d.hover = true; - selection.transition().call(chart) - }); - legend.dispatch.on('legendMouseout', function(d, i) { - d.hover = false; - selection.transition().call(chart) - }); -*/ - focus.dispatch.on('elementMouseover.tooltip', function(e) { - dispatch.tooltipShow({ - point: e.point, - series: e.series, - pos: [e.pos[0] + margin.left, e.pos[1] + margin.top], - seriesIndex: e.seriesIndex, - pointIndex: e.pointIndex - }); + lines.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); }); - focus.dispatch.on('elementMouseout.tooltip', function(e) { + if (tooltips) dispatch.on('tooltipShow', function(e) { showTooltip(e, container[0][0]) } ); // TODO: maybe merge with above? + + lines.dispatch.on('elementMouseout.tooltip', function(e) { dispatch.tooltipHide(e); }); + if (tooltips) dispatch.on('tooltipHide', nv.tooltip.cleanup); + bars.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, container[0][0]) } ); // TODO: maybe merge with above? + bars.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + if (tooltips) dispatch.on('tooltipHide', nv.tooltip.cleanup); - function onBrush() { - updateFocus(); - - focusLines.call(focus) - wrap.select('.x.axis').call(xAxis); - wrap.select('.y.axis').call(yAxis); - } - - function updateFocus() { - var yDomain = brush.empty() ? y2.domain() : d3.extent(d3.merge(seriesData).filter(function(d) { - return getX(d) >= brush.extent()[0] && getX(d) <= brush.extent()[1]; - }), getY); //This doesn't account for the 1 point before and the 1 point after the domain. Would fix, but likely need to change entire methodology here - - if (typeof yDomain[0] == 'undefined') yDomain = y2.domain(); //incase the brush doesn't cover a single point - - - x.domain(brush.empty() ? x2.domain() : brush.extent()); - y.domain(yDomain); - - //TODO: Rethink this... performance is horrible, likely need to cut off focus data to within the range - // If I limit the data for focusLines would want to include 1 point before and after the extent, - // Need to figure out an optimized way to accomplish this. - // ***One concern is to try not to make the assumption that all lines are of the same length, and - // points with the same index have the same x value (while this is true in our test cases, may - // not always be) - - focus.xDomain(x.domain()); - focus.yDomain(y.domain()); - } - + chart.update = function() { selection.transition().call(chart) }; }); return chart; } + chart.dispatch = dispatch; + chart.legend = legend; + chart.lines = lines; + chart.bars = bars; + chart.xAxis = xAxis; + chart.yAxis1 = yAxis1; + chart.yAxis2 = yAxis2; + d3.rebind(chart, lines, 'size', 'clipVoronoi'); + //d3.rebind(chart, lines, 'x', 'y', 'size', 'xDomain', 'yDomain', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id'); - // ********** FUNCTIONS ********** - - - - - // ********** PUBLIC ACCESSORS ********** - - chart.dispatch = dispatch; + //d3.rebind(chart, lines, 'interactive'); + //consider rebinding x and y as well chart.x = function(_) { if (!arguments.length) return getX; getX = _; - focus.x(_); - context.x(_); + lines.x(_); + bars.x(_); return chart; }; chart.y = function(_) { if (!arguments.length) return getY; getY = _; - focus.y(_); - context.y(_); + lines.y(_); + bars.y(_); return chart; }; @@ -3701,46 +2858,35 @@ nv.models.lineWithFocus = function() { chart.height = function(_) { if (!arguments.length) return height; height = _; - height1 = _ - height2; return chart; }; - chart.contextHeight = function(_) { - if (!arguments.length) return height2; - height2 = _; - height1 = height - _; + chart.color = function(_) { + if (!arguments.length) return color; + color = _; + legend.color(_); return chart; }; - chart.id = function(_) { - if (!arguments.length) return id; - id = _; + chart.showLegend = function(_) { + if (!arguments.length) return showLegend; + showLegend = _; return chart; }; - - // Chart has multiple similar Axes, to prevent code duplication, probably need to link all axis functions manually like below - chart.xTickFormat = function(_) { - if (!arguments.length) return x.tickFormat(); - xAxis.tickFormat(_); - xAxis2.tickFormat(_); + chart.tooltips = function(_) { + if (!arguments.length) return tooltips; + tooltips = _; return chart; }; - chart.yTickFormat = function(_) { - if (!arguments.length) return y.tickFormat(); - yAxis.tickFormat(_); - yAxis2.tickFormat(_); + chart.tooltipContent = function(_) { + if (!arguments.length) return tooltip; + tooltip = _; return chart; }; - - //TODO: allow for both focus and context axes to be linked - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - return chart; } @@ -3974,7 +3120,7 @@ nv.models.lineWithFocusChart = function() { } function updateFocus() { - var yDomain = brush.empty() ? y2.domain() : d3.extent(d3.merge(data.map(function(d) { return d.values })).filter(function(d) { + var yDomain = brush.empty() ? y2.domain() : d3.extent(d3.merge(data.filter(function(d) { return !d.disabled }).map(function(d) { return d.values })).filter(function(d) { return lines.x()(d) >= brush.extent()[0] && lines.x()(d) <= brush.extent()[1]; }), lines.y()); //This doesn't account for the 1 point before and the 1 point after the domain. Would fix, but likely need to change entire methodology here diff --git a/nv.d3.min.js b/nv.d3.min.js index eaf6437..d10726d 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 e(f){f.each(function(e){(d.orient()=="top"||d.orient()=="bottom")&&d.ticks(Math.abs(a.range()[1]-a.range()[0])/100);var f=d3.select(this).selectAll("text.axislabel").data([b||null]);f.exit().remove();switch(d.orient()){case"top":f.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",0),f.attr("x",a.range()[1]/2);break;case"right":f.enter().append("text").attr("class","axislabel").attr("transform","rotate(90)").attr("y",-40),f.attr("x",-a.range()[0]/2);break;case"bottom":f.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",25),f.attr("x",a.range()[1]/2);break;case"left":f.enter().append("text").attr("class","axislabel").attr("transform","rotate(-90)").attr("y",-40),f.attr("x",-a.range()[0]/2)}f.text(function(a){return a}),d3.transition(d3.select(this)).call(d),c&&d3.select(this).selectAll("line.tick").filter(function(a){return!parseFloat(Math.round(a*1e5)/1e6)}).classed("zero",!0)});return e}var a=d3.scale.linear(),b=null,c=!0,d=d3.svg.axis().scale(a).orient("bottom").tickFormat(function(a){return a});d3.rebind(e,d,"orient","ticks","tickValues","tickSubdivide","tickSize","tickPadding","tickFormat"),d3.rebind(e,a,"domain","range","rangeBand","rangeBands"),e.axisLabel=function(a){if(!arguments.length)return b;b=a;return e},e.highlightZero=function(a){if(!arguments.length)return c;c=a;return e},e.scale=function(b){if(!arguments.length)return a;a=b,d.scale(a),d3.rebind(e,a,"domain","range","rangeBand","rangeBands");return e};return e},a.models.bar=function(){function q(r){r.each(function(q){l.domain(q.map(function(a,b){return a[e]})).rangeRoundBands([0,b-a.left-a.right],.1);var r=d3.min(q,function(a){return a[j]}),s=d3.max(q,function(a){return a[j]}),t=Math.max(-r,s),u=-t;r>=0&&(u=0),m.domain([u,t]).range([c-a.top-a.bottom,0]).nice(),n.ticks(b/100),o.ticks(c/36).tickSize(-(b-a.right-a.left),0);var v=d3.select(this).on("click",function(a,b){p.chartClick({data:a,index:b,pos:d3.event,id:h})}),w=v.selectAll("g.wrap").data([q]),z=w.enter();z.append("text").attr("class","title").attr("dy",".91em").attr("text-anchor","start").text(k),z=z.append("g").attr("class","nvd3 wrap").attr("id","wrap-"+h).append("g"),z.append("g").attr("class","x axis"),z.append("g").attr("class","y axis"),z.append("g").attr("class","bars"),w.attr("width",b).attr("height",c);var A=w.select("g").attr("transform","translate("+a.left+","+a.top+")"),B=w.select(".bars").selectAll(".bar").data(function(a){return a});B.exit().remove();var C=B.enter().append("svg:rect").attr("class",function(a){return a[j]<0?"bar negative":"bar positive"}).attr("fill",function(a,b){return i(b)}).attr("x",0).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),p.tooltipShow({label:a[e],value:a[j],data:a,index:b,pos:[d3.event.pageX,d3.event.pageY],id:h})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),p.tooltipHide({label:a[e],value:a[j],data:a,index:b,id:h})}).on("click",function(a,b){p.elementClick({label:a[e],value:a[j],data:a,index:b,pos:d3.event,id:h}),d3.event.stopPropagation()}).on("dblclick",function(a,b){p.elementDblClick({label:a[e],value:a[j],data:a,index:b,pos:d3.event,id:h}),d3.event.stopPropagation()});B.attr("class",function(a){return a[j]<0?"bar negative":"bar positive"}).attr("transform",function(a,b){return"translate("+l(a[e])+",0)"}).attr("width",l.rangeBand).order().transition().duration(d).attr("y",function(a){return m(Math.max(0,a[j]))}).attr("height",function(a){return Math.abs(m(a[j])-m(0))}),A.select(".x.axis").attr("transform","translate(0,"+m.range()[0]+")").call(n),f&&A.select(".x.axis").selectAll("text").attr("text-anchor","start").attr("transform",function(a){return"rotate(35)translate("+this.getBBox().height/2+","+"0"+")"}),g||(A.select(".x.axis").selectAll("text").attr("fill","rgba(0,0,0,0)"),A.select(".x.axis").selectAll("line").attr("style","opacity: 0")),A.select(".y.axis").call(o)});return q}var a={top:20,right:10,bottom:80,left:60},b=960,c=500,d=500,e="label",f=!0,g=!0,h=Math.floor(Math.random()*1e4),i=d3.scale.category20(),j="y",k="",l=d3.scale.ordinal(),m=d3.scale.linear(),n=d3.svg.axis().scale(l).orient("bottom"),o=d3.svg.axis().scale(m).orient("left"),p=d3.dispatch("chartClick","elementClick","elementDblClick","tooltipShow","tooltipHide");q.margin=function(b){if(!arguments.length)return a;a=b;return q},q.width=function(c){if(!arguments.length)return b;a.left+a.right+20>c?b=a.left+a.right+20:b=c;return q},q.height=function(b){if(!arguments.length)return c;a.top+a.bottom+20>b?c=a.top+a.bottom+20:c=b;return q},q.animate=function(a){if(!arguments.length)return d;d=a;return q},q.labelField=function(a){if(!arguments.length)return e;e=a;return q},q.dataField=function(a){if(!arguments.length)return j;j=a;return q},q.id=function(a){if(!arguments.length)return h;h=a;return q},q.rotatedLabel=function(a){if(!arguments.length)return f;f=a;return q},q.showLabels=function(a){if(!arguments.length)return g;g=a;return q},q.title=function(a){if(!arguments.length)return k;k=a;return q},q.xaxis={},d3.rebind(q.xaxis,n,"tickFormat"),q.yaxis={},d3.rebind(q.yaxis,o,"tickFormat"),q.dispatch=p;return q},a.models.historicalBar=function(){function r(g){g.each(function(g){var h=b-a.left-a.right,o=c-a.top-a.bottom;m.domain(k||d3.extent(g[0].values,e)).range([0,h]),n.domain(l||d3.extent(g[0].values,f)).range([o,0]);var p=d3.select(this).on("click",function(a,b){q.chartClick({data:a,index:b,pos:d3.event,id:d})}),r=d3.select(this).selectAll("g.wrap.bar").data([g[0].values]),s=r.enter().append("g").attr("class","wrap nvd3 bar"),t=s.append("g");t.append("g").attr("class","bars"),r.attr("width",b).attr("height",c);var u=r.select("g").attr("transform","translate("+a.left+","+a.top+")");s.append("defs").append("clipPath").attr("id","chart-clip-path-"+d).append("rect"),r.select("#chart-clip-path-"+d+" rect").attr("width",h).attr("height",o),t.attr("clip-path",i?"url(#chart-clip-path-"+d+")":"");var v=t.append("g").attr("class","shiftWrap"),w=r.select(".bars").selectAll(".bar").data(function(a){return a});w.exit().remove();var z=w.enter().append("svg:rect").attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("fill",function(a,b){return j[0]}).attr("x",0).attr("y",function(a,b){return n(Math.max(0,f(a,b)))}).attr("height",function(a,b){return Math.abs(n(f(a,b))-n(0))}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),q.elementMouseover({point:a,series:g[0],pos:[m(e(a,b)),n(f(a,b))],pointIndex:b,seriesIndex:0,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),q.elementMouseout({point:a,series:g[0],pointIndex:b,seriesIndex:0,e:d3.event})}).on("click",function(a,b){q.elementClick({value:f(a,b),data:a,index:b,pos:[m(e(a,b)),n(f(a,b))],e:d3.event,id:d}),d3.event.stopPropagation()}).on("dblclick",function(a,b){q.elementDblClick({value:f(a,b),data:a,index:b,pos:[m(e(a,b)),n(f(a,b))],e:d3.event,id:d}),d3.event.stopPropagation()});w.attr("class",function(a,b){return f(a,b)<0?"bar negative":"bar positive"}).attr("transform",function(a,b){return"translate("+(m(e(a,b))-m(.5))+",0)"}).attr("width",m(.9)),d3.transition(w).attr("y",function(a,b){return n(Math.max(0,f(a,b)))}).attr("height",function(a,b){return Math.abs(n(f(a,b))-n(0))})});return r}var a={top:0,right:0,bottom:0,left:0},b=960,c=500,d=Math.floor(Math.random()*1e4),e=function(a){return a.x},f=function(a){return a.y},g=[],h=[],i=!0,j=d3.scale.category20().range(),k,l,m=d3.scale.linear(),n=d3.scale.linear(),o=d3.svg.axis().scale(m).orient("bottom"),p=d3.svg.axis().scale(n).orient("left"),q=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");r.dispatch=q,r.x=function(a){if(!arguments.length)return e;e=a;return r},r.y=function(a){if(!arguments.length)return f;f=a;return r},r.margin=function(b){if(!arguments.length)return a;a=b;return r},r.width=function(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%10]}).filter(function(a,b){return!f[b].disabled}));var D=d3.select(this).classed("chart-"+i,!0).selectAll("g.wrap").data([z]),E=D.enter().append("g").attr("class","wrap nvd3 cumulativeLine").append("g");E.append("g").attr("class","x axis"),E.append("g").attr("class","y axis"),E.append("g").attr("class","linesWrap"),E.append("g").attr("class","legendWrap"),E.append("g").attr("class","controlsWrap"),b.top=q.height();var F=D.select("g").attr("transform","translate("+b.left+","+b.top+")");q.width(g/2-b.right),F.select(".legendWrap").datum(f).attr("transform","translate("+(g/2-b.left)+","+ -b.top+")").call(q),j&&(r.width(140).color(["#444","#444","#444"]),F.select(".controlsWrap").datum(v).attr("transform","translate(0,"+ -b.top+")").call(r));var G=F.select(".linesWrap").datum(z.filter(function(a){return!a.disabled}));d3.transition(G).call(s);var H=G.selectAll(".indexLine").data([u]);H.enter().append("rect").attr("class","indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).call(w),H.attr("transform",function(a){return"translate("+m(a.i)+",0)"}).attr("height",y),o.domain(l.domain()).range(l.range()).ticks(g/100).tickSize(-y,0),F.select(".x.axis").attr("transform","translate(0,"+n.range()[0]+")"),d3.transition(F.select(".x.axis")).call(o),p.domain(n.domain()).range(n.range()).ticks(h/36).tickSize(-x,0),d3.transition(F.select(".y.axis")).call(p),q.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,f.filter(function(a){return!a.disabled}).length||f.map(function(a){a.disabled=!1,D.selectAll(".series").classed("disabled",!1);return a}),a.transition().call(A)}),r.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,k=!b.disabled,a.transition().call(A)}),s.dispatch.on("elementMouseover.tooltip",function(a){t.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),s.dispatch.on("elementMouseout.tooltip",function(a){t.tooltipHide(a)})});return A}function z(a,b){d3.transition(d3.select(".chart-"+i)).call(A)}function y(a,b){a.x+=d3.event.dx,a.i=Math.round(m.invert(a.x)),d3.select(this).attr("transform","translate("+m(a.i)+",0)")}function x(a,b){}var b={top:30,right:20,bottom:30,left:60},c=function(){return 960},d=function(){return 500},e=d3.scale.category20().range(),f=function(){return 2.5},g=function(a){return a.x},h=function(a){return a.y},i=Math.floor(Math.random()*1e4),j=!0,k=!0,l=d3.scale.linear(),m=d3.scale.linear(),n=d3.scale.linear(),o=a.models.axis().scale(l).orient("bottom"),p=a.models.axis().scale(n).orient("left"),q=a.models.legend().height(30),r=a.models.legend().height(30),s=a.models.line(),t=d3.dispatch("tooltipShow","tooltipHide"),u={i:0,x:0},v=[{key:"Re-scale y-axis"}],w=d3.behavior.drag().on("dragstart",x).on("drag",y).on("dragend",z);A.dispatch=t,A.x=function(a){if(!arguments.length)return g;g=a;return A},A.y=function(a){if(!arguments.length)return h;h=a;return A},A.margin=function(a){if(!arguments.length)return b;b=a;return A},A.width=function(a){if(!arguments.length)return c;c=d3.functor(a);return A},A.height=function(a){if(!arguments.length)return d;d=d3.functor(a);return A},A.color=function(a){if(!arguments.length)return e;e=a,q.color(a);return A},A.dotRadius=function(a){if(!arguments.length)return f;f=d3.functor(a),s.dotRadius=a;return A},A.showRescaleToggle=function(a){if(!arguments.length)return j;j=a;return A},A.xAxis=o,A.yAxis=p;return A},a.models.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=(d||parseInt(z.style("width"))||960)-b.left-b.right,D=(e||parseInt(z.style("height"))||400)-b.top-b.bottom,E=C(u.i,y);n.domain([0,y[0].values.length-1]).range([0,A]).clamp(!0);var F=z.selectAll("g.wrap.cumulativeLine").data([E]),G=F.enter().append("g").attr("class","wrap nvd3 cumulativeLine").append("g");G.append("g").attr("class","x axis"),G.append("g").attr("class","y axis"),G.append("g").attr("class","linesWrap"),G.append("g").attr("class","legendWrap"),G.append("g").attr("class","controlsWrap");var H=F.select("g");f&&(r.width(A),H.select(".legendWrap").datum(y).call(r),b.top!=r.height()&&(b.top=r.height(),D=(e||parseInt(z.style("height"))||400)-b.top-b.bottom),H.select(".legendWrap").attr("transform","translate(0,"+ -b.top+")")),i&&(s.width(140).color(["#444","#444","#444"]),H.select(".controlsWrap").datum(v).attr("transform","translate(0,"+ -b.top+")").call(s)),k.width(A).height(D).color(E.map(function(a,b){return a.color||c[b%10]}).filter(function(a,b){return!y[b].disabled})),H.attr("transform","translate("+b.left+","+b.top+")");var I=H.select(".linesWrap").datum(E.filter(function(a){return!a.disabled}));d3.transition(I).call(k);var J=I.selectAll(".indexLine").data([u]);J.enter().append("rect").attr("class","indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).call(x),J.attr("transform",function(a){return"translate("+n(a.i)+",0)"}).attr("height",D),p.scale(l).ticks(A/100).tickSize(-D,0),H.select(".x.axis").attr("transform","translate(0,"+m.range()[0]+")"),d3.transition(H.select(".x.axis")).call(p),q.scale(m).ticks(D/36).tickSize(-A,0),d3.transition(H.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,F.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,z[0][0])}),k.dispatch.on("elementMouseout.tooltip",function(a){t.tooltipHide(a)}),g&&t.on("tooltipHide",a.tooltip.cleanup)}),B.update=function(){B(h)};return B}function A(a,b){B.update()}function z(a,b){a.x+=d3.event.dx,a.i=Math.round(n.invert(a.x)),d3.select(this).attr("transform","translate("+n(a.i)+",0)")}function y(a,b){}var b={top:30,right:20,bottom:50,left:60},c=d3.scale.category20().range(),d=null,e=null,f=!0,g=!0,h=function(a,b,c,d,e){return"

"+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"),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;o=o||e,p=p||f,s=s.map(function(a,b){a.values=a.values.map(function(a){a.series=b;return a});return a});var v=m&&n?[]:s.map(function(a){return a.values.map(function(a,b){return{x:g(a,b),y:h(a,b),y0:a.y0}})});e.domain(m||d3.merge(v).map(function(a){return a.x})).rangeBands([0,t],.1),f.domain(n||d3.extent(d3.merge(v).map(function(a){return a.y}).concat(i))),k?f.range([u-(f.domain()[0]<0?12:0),f.domain()[1]<0?0:12]):f.range([u,0]);var w=d3.select(this).selectAll("g.wrap.discretebar").data([s]),z=w.enter().append("g").attr("class","wrap nvd3 discretebar"),A=z.append("g");A.append("g").attr("class","groups");var B=w.select("g");w.attr("transform","translate("+a.left+","+a.top+")");var C=w.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});C.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(C.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),C.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}),d3.transition(C).style("stroke-opacity",1).style("fill-opacity",.75);var D=C.selectAll("g.bar").data(function(a){return a.values});D.exit().remove();var E=D.enter().append("g").attr("transform",function(a,b,c){return"translate("+e(g(a,b))+", "+f(0)+")"}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),q.elementMouseover({value:h(a,b),point:a,series:s[a.series],pos:[e(g(a,b))+e.rangeBand()*(a.series+.5)/s.length,f(h(a,b))],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),q.elementMouseout({value:h(a,b),point:a,series:s[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){q.elementClick({value:h(a,b),point:a,series:s[a.series],pos:[e(g(a,b))+e.rangeBand()*(a.series+.5)/s.length,f(h(a,b))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(a,b){q.elementDblClick({value:h(a,b),point:a,series:s[a.series],pos:[e(g(a,b))+e.rangeBand()*(a.series+.5)/s.length,f(h(a,b))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()});E.append("rect").attr("height",0).attr("width",e.rangeBand()/s.length).style("fill",function(a,b){return a.color||j[b%10]}).style("stroke",function(a,b){return a.color||j[b%10]}),k?(E.append("text").attr("text-anchor","middle"),D.selectAll("text").attr("dx",e.rangeBand()/2).attr("dy",function(a,b){return h(a,b)<0?f(h(a,b))-f(0)+12:-4}).text(function(a,b){return l(h(a,b))})):D.selectAll("text").remove(),D.attr("class",function(a,b){return h(a,b)<0?"bar negative":"bar positive"}),d3.transition(D).attr("transform",function(a,b){return"translate("+e(g(a,b))+", "+(h(a,b)<0?f(0):f(h(a,b)))+")"}).selectAll("rect").attr("width",e.rangeBand()/s.length).attr("height",function(a,b){return Math.abs(f(h(a,b))-f(0))}),r.update=function(){d.transition().call(r)},o=e.copy(),p=f.copy()});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=(c||parseInt(p.style("width"))||960)-b.left-b.right,s=(d||parseInt(p.style("height"))||400)-b.top-b.bottom;i.width(r).height(s);var t=p.selectAll("g.wrap.discreteBarWithAxes").data([h]),u=t.enter().append("g").attr("class","wrap nvd3 discreteBarWithAxes").append("g"),v=u.append("defs");u.append("g").attr("class","x axis"),u.append("g").attr("class","y axis"),u.append("g").attr("class","barsWrap");var w=t.select("g");w.attr("transform","translate("+b.left+","+b.top+")");var z=w.select(".barsWrap").datum(h.filter(function(a){return!a.disabled}));d3.transition(z).call(i),v.append("clipPath").attr("id","x-label-clip-"+i.id()).append("rect"),w.select("#x-label-clip-"+i.id()+" rect").attr("width",j.rangeBand()*(f?2:1)).attr("height",16).attr("x",-j.rangeBand()/(f?1:2)),l.ticks(r/100).tickSize(-s,0),w.select(".x.axis").attr("transform","translate(0,"+(k.range()[0]+(i.showValues()?16:0))+")"),d3.transition(w.select(".x.axis")).call(l);var A=w.select(".x.axis").selectAll("g");f&&A.selectAll("text").attr("transform",function(a,b,c){return"translate(0,"+(c%2==0?"0":"12")+")"}),A.selectAll("text").attr("clip-path",function(a,b,c){return"url(#x-label-clip-"+i.id()+")"}),m.ticks(s/36).tickSize(-r,0),d3.transition(w.select(".y.axis")).call(m),i.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],n.tooltipShow(a)}),g&&n.on("tooltipShow",function(a){o(a,p[0][0])}),i.dispatch.on("elementMouseout.tooltip",function(a){n.tooltipHide(a)}),g&&n.on("tooltipHide",a.tooltip.cleanup),q.update=function(){e.transition().call(q)}});return q}var b={top:30,right:20,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!1,g=!0,h=function(a,b,c,d,e){return"

"+b+"

"+"

"+c+"

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

"+a+"

"+"

"+c+" at "+b+"

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

"+a+"

"+"

"+c+" at "+b+"

"},l=a.models.line(),m=a.models.historicalBar(),n=d3.scale.linear(),o=m.yScale(),p=l.yScale(),q=a.models.axis().scale(n).orient("bottom"),r=a.models.axis().scale(o).orient("left"),s=a.models.axis().scale(p).orient("right"),t=a.models.legend().height(30),u=d3.dispatch("tooltipShow","tooltipHide"),v=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=q.tickFormat()(l.x()(b.point)),g=r.tickFormat()(l.y()(b.point)),h=k(b.series.key,f,g,b,w);a.tooltip.show([d,e],h,b.value<0?"n":"s")};w.dispatch=u,w.legend=t,w.lines=l,w.bars=m,w.xAxis=q,w.yAxis1=r,w.yAxis2=s,d3.rebind(w,l,"size","clipVoronoi"),w.x=function(a){if(!arguments.length)return f;f=a,l.x(a),m.x(a);return w},w.y=function(a){if(!arguments.length)return g;g=a,l.y(a),m.y(a);return w},w.margin=function(a){if(!arguments.length)return b;b=a;return w},w.width=function(a){if(!arguments.length)return c;c=a;return w},w.height=function(a){if(!arguments.length)return d;d=a;return w},w.color=function(a){if(!arguments.length)return h;h=a,t.color(a);return w},w.showLegend=function(a){if(!arguments.length)return i;i=a;return w},w.tooltips=function(a){if(!arguments.length)return j;j=a;return w},w.tooltipContent=function(a){if(!arguments.length)return k;k=a;return w};return w},a.models.lineWithFocus=function(){function y(a){a.each(function(k){function L(){var a=x.empty()?o.domain():d3.extent(d3.merge(z).filter(function(a){return i(a)>=x.extent()[0]&&i(a)<=x.extent()[1]}),j);typeof a[0]=="undefined"&&(a=o.domain()),l.domain(x.empty()?n.domain():x.extent()),m.domain(a),u.xDomain(l.domain()),u.yDomain(m.domain())}function K(){L(),H.call(u),D.select(".x.axis").call(p),D.select(".y.axis").call(q)}var z=k.filter(function(a){return!a.disabled}).map(function(a){return a.values}),A=d-b.left-b.right,B=f-b.top-b.bottom,C=g-c.top-c.bottom;n.domain(d3.extent(d3.merge(z),i)).range([0,A]),o.domain(d3.extent(d3.merge(z),j)).range([C,0]),l.domain(x.empty()?n.domain():x.extent()).range([0,A]),m.domain(o.domain()).range([B,0]),x.on("brush",K),u.width(A).height(B).color(k.map(function(a,b){return a.color||h[b%10]}).filter(function(a,b){return!k[b].disabled})),v.width(A).height(C).color(k.map(function(a,b){return a.color||h[b%10]}).filter(function(a,b){return!k[b].disabled})),L();var D=d3.select(this).selectAll("g.wrap").data([k]),E=D.enter().append("g").attr("class","wrap nvd3 lineWithFocus").append("g");E.append("g").attr("class","focus"),E.append("g").attr("class","context"),E.append("g").attr("class","legendWrap");var F=D.select("g");t.width(d/2-b.right),F.select(".legendWrap").datum(k).attr("transform","translate("+A/2+",0)").call(t),b.top=t.height();var G=F.select(".focus").attr("transform","translate("+b.left+","+b.top+")");E.select(".focus").append("g").attr("class","x axis"),E.select(".focus").append("g").attr("class","y axis"),E.select(".focus").append("g").attr("class","focusLines");var H=G.select(".focusLines").datum(k.filter(function(a){return!a.disabled}));d3.transition(H).call(u),p.domain(l.domain()).range(l.range()).ticks(d/100).tickSize(-B,0),G.select(".x.axis").attr("transform","translate(0,"+m.range()[0]+")"),d3.transition(F.select(".x.axis")).call(p),q.domain(m.domain()).range(m.range()).ticks(e/36).tickSize(-A,0),d3.transition(F.select(".y.axis")).call(q);var I=F.select(".context").attr("transform","translate("+c.left+","+f+")");E.select(".context").append("g").attr("class","x2 axis"),E.select(".context").append("g").attr("class","y2 axis"),E.select(".context").append("g").attr("class","contextLines"),E.select(".context").append("g").attr("class","x brush").attr("class","x brush").call(x).selectAll("rect").attr("y",-5).attr("height",g+4);var J=I.select(".contextLines").datum(k.filter(function(a){return!a.disabled}));d3.transition(J).call(v),r.domain(n.domain()).range(n.range()).ticks(d/100).tickSize(-C,0),I.select(".x2.axis").attr("transform","translate(0,"+o.range()[0]+")"),d3.transition(I.select(".x2.axis")).call(r),s.domain(o.domain()).range(o.range()).ticks(C/24).tickSize(-A,0),I.select(".y2.axis"),d3.transition(I.select(".y2.axis")).call(s),t.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,k.filter(function(a){return!a.disabled}).length||k.map(function(a){a.disabled=!1,D.selectAll(".series").classed("disabled",!1);return a}),a.transition().call(y)}),u.dispatch.on("elementMouseover.tooltip",function(a){w.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),u.dispatch.on("elementMouseout.tooltip",function(a){w.tooltipHide(a)})});return y}var b={top:30,right:20,bottom:30,left:60},c={top:0,right:20,bottom:20,left:60},d=960,e=500,f=400,g=100,h=d3.scale.category20().range(),i=function(a){return a.x},j=function(a){return a.y},k=Math.floor(Math.random()*1e4),l=d3.scale.linear(),m=d3.scale.linear(),n=d3.scale.linear(),o=d3.scale.linear(),p=a.models.axis().scale(l).orient("bottom"),q=a.models.axis().scale(m).orient("left"),r=a.models.axis().scale(n).orient("bottom"),s=a.models.axis().scale(o).orient("left"),t=a.models.legend().height(30),u=a.models.line().clipEdge(!0),v=a.models.line().interactive(!1),w=d3.dispatch("tooltipShow","tooltipHide"),x=d3.svg.brush().x(n);y.dispatch=w,y.x=function(a){if(!arguments.length)return i;i=a,u.x(a),v.x(a);return y},y.y=function(a){if(!arguments.length)return j;j=a,u.y(a),v.y(a);return y},y.margin=function(a){if(!arguments.length)return b;b=a;return y},y.width=function(a){if(!arguments.length)return d;d=a;return y},y.height=function(a){if(!arguments.length)return e;e=a,f=a-g;return y},y.contextHeight=function(a){if(!arguments.length)return g;g=a,f=e-a;return y},y.id=function(a){if(!arguments.length)return k;k=a;return y},y.xTickFormat=function(a){if(!arguments.length)return l.tickFormat();p.tickFormat(a),r.tickFormat(a);return y},y.yTickFormat=function(a){if(!arguments.length)return m.tickFormat();q.tickFormat(a),s.tickFormat(a);return y},y.xAxis=p,y.yAxis=q;return y},a.models.lineWithFocusChart=function(){function y(j){j.each(function(z){function M(){var a=w.empty()?p.domain():d3.extent(d3.merge(z.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 L(){M(),J.call(k),I.select(".focus .x.axis").call(q),I.select(".focus .y.axis").call(r)}var A=d3.select(this),B=(e||parseInt(A.style("width"))||960)-b.left-b.right,C=(f||parseInt(A.style("height"))||400)-b.top-b.bottom-g,D=g-c.top-c.bottom;w.on("brush",L);var E=A.selectAll("g.wrap.lineWithFocusChart").data([z]),F=E.enter().append("g").attr("class","wrap nvd3 lineWithFocusChart").append("g"),G=F.append("g").attr("class","focus");G.append("g").attr("class","x axis"),G.append("g").attr("class","y axis"),G.append("g").attr("class","linesWrap");var H=F.append("g").attr("class","context");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","x brush"),F.append("g").attr("class","legendWrap");var I=E.select("g");h&&(u.width(B),I.select(".legendWrap").datum(z).call(u),b.top!=u.height()&&(b.top=u.height(),C=(f||parseInt(A.style("height"))||400)-b.top-b.bottom),I.select(".legendWrap").attr("transform","translate(0,"+ -b.top+")")),k.width(B).height(C).color(z.map(function(a,b){return a.color||d[b%10]}).filter(function(a,b){return!z[b].disabled})),l.width(B).height(D).color(z.map(function(a,b){return a.color||d[b%10]}).filter(function(a,b){return!z[b].disabled})),I.attr("transform","translate("+b.left+","+b.top+")");var J=I.select(".focus .linesWrap").datum(z.filter(function(a){return!a.disabled}));d3.transition(J).call(k),q.ticks(B/100).tickSize(-C,0),I.select(".focus .x.axis").attr("transform","translate(0,"+n.range()[0]+")"),d3.transition(I.select(".focus .x.axis")).call(q),r.ticks(C/36).tickSize(-B,0),d3.transition(I.select(".focus .y.axis")).call(r),I.select(".context").attr("transform","translate(0,"+(C+b.bottom+c.top)+")");var K=I.select(".context .linesWrap").datum(z.filter(function(a){return!a.disabled}));d3.transition(K).call(l),I.select(".x.brush").call(w).selectAll("rect").attr("y",-5).attr("height",D+4),s.ticks(B/100).tickSize(-D,0),I.select(".context .x.axis").attr("transform","translate(0,"+p.range()[0]+")"),d3.transition(I.select(".context .x.axis")).call(s),t.ticks(D/36).tickSize(-B,0),d3.transition(I.select(".context .y.axis")).call(t),M(),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,E.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,A[0][0])}),k.dispatch.on("elementMouseout.tooltip",function(a){v.tooltipHide(a)}),i&&v.on("tooltipHide",a.tooltip.cleanup)}),y.update=function(){y(j)};return y}var b={top:30,right:20,bottom:50,left:60},c={top:0,right:20,bottom:20,left:60},d=d3.scale.category20().range(),e=null,f=null,g=100,h=!0,i=!0,j=function(a,b,c,d,e){return"

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

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

"+b+"

"+"

"+c+"

"},j=a.models.multiBarHorizontal().stacked(!1),k=j.xScale(),l=j.yScale(),m=a.models.axis().scale(k).orient("left").highlightZero(!1),n=a.models.axis().scale(l).orient("bottom"),o=a.models.legend().height(30),p=a.models.legend().height(30),q=d3.dispatch("tooltipShow","tooltipHide");m.tickFormat(function(a){return a}),n.tickFormat(d3.format(",.1f"));var r=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=m.tickFormat()(j.x()(b.point)),g=n.tickFormat()(j.y()(b.point)),h=i(b.series.key,f,g,b,t);a.tooltip.show([d,e],h,b.value<0?"e":"w")},s=[{key:"Grouped"},{key:"Stacked",disabled:!0}];t.dispatch=q,t.multibar=j,t.legend=o,t.xAxis=m,t.yAxis=n,d3.rebind(t,j,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id","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 K(){if(!p){F.select("#points-clip-"+f).remove(),F.select(".point-paths").remove();return!1}I.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){H.append("clipPath").attr("id","points-clip-"+f);var c=F.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]}),F.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=F.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;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 E=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(E).map(function(a){return a.x}).concat(m))).range([0,C]),h.domain(u||d3.extent(d3.merge(E).map(function(a){return a.y}).concat(n))).range([D,0]),i.domain(v||d3.extent(d3.merge(E).map(function(a){return a.size}).concat(o))).range([16,256]);var F=d3.select(this).selectAll("g.wrap.scatter").data([B]),G=F.enter().append("g").attr("class","wrap nvd3 scatter chart-"+f),H=G.append("defs"),I=G.append("g"),J=F.select("g");I.append("g").attr("class","groups"),F.attr("transform","translate("+a.left+","+a.top+")"),H.append("clipPath").attr("id","edge-clip-"+f).append("rect"),F.select("#edge-clip-"+f+" rect").attr("width",C).attr("height",D),J.attr("clip-path",q?"url(#edge-clip-"+f+")":"");var L=F.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.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(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}),d3.transition(L).style("fill",function(a,b){return d[b%20]}).style("stroke",function(a,b){return d[b%20]}).style("stroke-opacity",1).style("fill-opacity",.5);var M=L.selectAll("path.point").data(function(a){return a.values});M.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(L.exit().selectAll("path.point")).attr("transform",function(a,b){return"translate("+g(j(a,b))+","+h(k(a,b))+")"}).remove(),M.attr("class",function(a,b){return"point point-"+b}),d3.transition(M).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(K,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 w(j){j.each(function(k){w.update=function(){j.transition().call(w)};var l=d3.select(this),z=(c||parseInt(l.style("width"))||960)-b.left-b.right,A=(d||parseInt(l.style("height"))||400)-b.top-b.bottom;t=t||m.xScale(),u=u||m.yScale();var B=l.selectAll("g.wrap.scatterChart").data([k]),C=B.enter().append("g").attr("class","wrap nvd3 scatterChart chart-"+m.id()).append("g");C.append("g").attr("class","legendWrap"),C.append("g").attr("class","x axis"),C.append("g").attr("class","y axis"),C.append("g").attr("class","scatterWrap");var D=B.select("g");h&&(r.width(z/2),B.select(".legendWrap").datum(k).call(r),b.top!=r.height()&&(b.top=r.height(),A=(d||parseInt(l.style("height"))||400)-b.top-b.bottom),B.select(".legendWrap").attr("transform","translate("+z/2+","+ -b.top+")")),m.width(z).height(A).color(k.map(function(a,b){return a.color||e[b%20]}).filter(function(a,b){return!k[b].disabled})),D.attr("transform","translate("+b.left+","+b.top+")");var E=B.select(".scatterWrap").datum(k.filter(function(a){return!a.disabled}));d3.transition(E).call(m),p.ticks(z/100).tickSize(-A,0),D.select(".x.axis").attr("transform","translate(0,"+o.range()[0]+")"),d3.transition(D.select(".x.axis")).call(p),q.ticks(A/36).tickSize(-z,0),d3.transition(D.select(".y.axis")).call(q);if(f||g){var F=E.selectAll("g.distribution").data(function(a){return a},function(a){return a.key});F.enter().append("g").attr("class",function(a,b){return"distribution series-"+b}),F.style("stroke",function(a,b){return e.filter(function(a,b){return k[b]&&!k[b].disabled})[b%10]})}if(f){var G=F.selectAll("line.distX").data(function(a){return a.values});G.enter().append("line").attr("x1",function(a,b){return t(m.x()(a,b))}).attr("x2",function(a,b){return t(m.x()(a,b))}),d3.transition(F.exit().selectAll("line.distX")).attr("x1",function(a,b){return n(m.x()(a,b))}).attr("x2",function(a,b){return n(m.x()(a,b))}).remove(),G.attr("class",function(a,b){return"distX distX-"+b}).attr("y1",o.range()[0]).attr("y2",o.range()[0]+8),d3.transition(G).attr("x1",function(a,b){return n(m.x()(a,b))}).attr("x2",function(a,b){return n(m.x()(a,b))})}if(g){var H=F.selectAll("line.distY").data(function(a){return a.values});H.enter().append("line").attr("y1",function(a,b){return u(m.y()(a,b))}).attr("y2",function(a,b){return u(m.y()(a,b))}),d3.transition(F.exit().selectAll("line.distY")).attr("y1",function(a,b){return o(m.y()(a,b))}).attr("y2",function(a,b){return o(m.y()(a,b))}).remove(),H.attr("class",function(a,b){return"distY distY-"+b}).attr("x1",n.range()[0]).attr("x2",n.range()[0]-8),d3.transition(H).attr("y1",function(a,b){return o(m.y()(a,b))}).attr("y2",function(a,b){return o(m.y()(a,b))})}r.dispatch.on("legendClick",function(a,b,c){a.disabled=!a.disabled,k.filter(function(a){return!a.disabled}).length||k.map(function(a){a.disabled=!1,B.selectAll(".series").classed("disabled",!1);return a}),j.transition().call(w)}),m.dispatch.on("elementMouseover.tooltip",function(a){d3.select(".chart-"+m.id()+" .series-"+a.seriesIndex+" .distX-"+a.pointIndex).attr("y1",a.pos[1]),d3.select(".chart-"+m.id()+" .series-"+a.seriesIndex+" .distY-"+a.pointIndex).attr("x1",a.pos[0]),a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],s.tooltipShow(a)}),i&&s.on("tooltipShow",function(a){v(a,l[0][0])}),m.dispatch.on("elementMouseout.tooltip",function(a){s.tooltipHide(a),d3.select(".chart-"+m.id()+" .series-"+a.seriesIndex+" .distX-"+a.pointIndex).attr("y1",o.range()[0]),d3.select(".chart-"+m.id()+" .series-"+a.seriesIndex+" .distY-"+a.pointIndex).attr("x1",n.range()[0])}),i&&s.on("tooltipHide",a.tooltip.cleanup),t=n.copy(),u=o.copy()});return w}var b={top:30,right:20,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!1,g=!1,h=!0,i=!0,j=function(a,b,c){return""+b+""},k=function(a,b,c){return""+c+""},l=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" at "+b+"

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

"+a+"

"+"

"+c+" on "+b+"

"},j=a.models.stackedArea(),k=j.xScale(),l=j.yScale(),m=a.models.axis().scale(k).orient("bottom"),n=a.models.axis().scale(l).orient("left"),o=a.models.legend().height(30),p=a.models.legend().height(30),q=d3.dispatch("tooltipShow","tooltipHide"),r=[{key:"Stacked"},{key:"Stream",disabled:!0},{key:"Expanded",disabled:!0}],s=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=m.tickFormat()(j.x()(b.point)),g=n.tickFormat()(j.y()(b.point)),h=i(b.series.key,f,g,b,t);a.tooltip.show([d,e],h,b.value<0?"n":"s")};t.dispatch=q,t.stacked=j,t.xAxis=m,t.yAxis=n,d3.rebind(t,j,"x","y","interactive","offset","order","style","clipEdge","size","forceX","forceY","forceSize"),t.margin=function(a){if(!arguments.length)return b;b=a;return t},t.width=function(a){if(!arguments.length)return getWidth;c=a;return t},t.height=function(a){if(!arguments.length)return getHeight;d=a;return t},t.color=function(a){if(!arguments.length)return e;e=a,o.color(a);return t},t.showControls=function(a){if(!arguments.length)return f;f=a;return t},t.showLegend=function(a){if(!arguments.length)return g;g=a;return t},t.tooltips=function(a){if(!arguments.length)return h;h=a;return t},t.tooltipContent=function(a){if(!arguments.length)return i;i=a;return t};return t}})() \ No newline at end of file +(function(){function c(a,b,c){return function(d,e,f){var g=a(d),h=[];g1)while(gl+k&&(o=l-h-5);break;case"w":n=b[0]+e,o=b[1]-h/2,n+i>j&&(n=b[0]-i-e),ol+k&&(o=l-h-5);break;case"n":n=b[0]-i/2,o=b[1]+e,nj&&(n=j-i-5),o+h>l+k&&(o=b[1]-h-e);break;case"s":n=b[0]-i/2,o=b[1]-h-e,nj&&(n=j-i-5),l>o&&(o=b[1]+20)}f.style.left=n+"px",f.style.top=o+"px",f.style.opacity=1;return f},b.cleanup=function(){var a=document.getElementsByClassName("nvtooltip"),b=[];while(a.length)b.push(a[0]),a[0].style.transitionDelay="0 !important",a[0].style.opacity=0,a[0].className="nvtooltip-pending-removal";setTimeout(function(){while(b.length){var a=b.pop();a.parentNode.removeChild(a)}},500)}}(),a.utils.windowSize=function(){var a={width:640,height:480};document.body&&document.body.offsetWidth&&(a.width=document.body.offsetWidth,a.height=document.body.offsetHeight),document.compatMode=="CSS1Compat"&&document.documentElement&&document.documentElement.offsetWidth&&(a.width=document.documentElement.offsetWidth,a.height=document.documentElement.offsetHeight),window.innerWidth&&window.innerHeight&&(a.width=window.innerWidth,a.height=window.innerHeight);return a},a.utils.windowResize=function(a){var b=window.onresize;window.onresize=function(c){typeof b=="function"&&b(c),a(c)}},a.models.axis=function(){function e(f){f.each(function(e){(d.orient()=="top"||d.orient()=="bottom")&&d.ticks(Math.abs(a.range()[1]-a.range()[0])/100);var f=d3.select(this).selectAll("text.axislabel").data([b||null]);f.exit().remove();switch(d.orient()){case"top":f.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",0),f.attr("x",a.range()[1]/2);break;case"right":f.enter().append("text").attr("class","axislabel").attr("transform","rotate(90)").attr("y",-40),f.attr("x",-a.range()[0]/2);break;case"bottom":f.enter().append("text").attr("class","axislabel").attr("text-anchor","middle").attr("y",25),f.attr("x",a.range()[1]/2);break;case"left":f.enter().append("text").attr("class","axislabel").attr("transform","rotate(-90)").attr("y",-40),f.attr("x",-a.range()[0]/2)}f.text(function(a){return a}),d3.transition(d3.select(this)).call(d),c&&d3.select(this).selectAll("line.tick").filter(function(a){return!parseFloat(Math.round(a*1e5)/1e6)}).classed("zero",!0)});return e}var a=d3.scale.linear(),b=null,c=!0,d=d3.svg.axis().scale(a).orient("bottom").tickFormat(function(a){return a});d3.rebind(e,d,"orient","ticks","tickValues","tickSubdivide","tickSize","tickPadding","tickFormat"),d3.rebind(e,a,"domain","range","rangeBand","rangeBands"),e.axisLabel=function(a){if(!arguments.length)return b;b=a;return e},e.highlightZero=function(a){if(!arguments.length)return c;c=a;return e},e.scale=function(b){if(!arguments.length)return a;a=b,d.scale(a),d3.rebind(e,a,"domain","range","rangeBand","rangeBands");return e};return e},a.models.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%10]}).filter(function(a,b){return!f[b].disabled}));var D=d3.select(this).classed("chart-"+i,!0).selectAll("g.wrap").data([z]),E=D.enter().append("g").attr("class","wrap nvd3 cumulativeLine").append("g");E.append("g").attr("class","x axis"),E.append("g").attr("class","y axis"),E.append("g").attr("class","linesWrap"),E.append("g").attr("class","legendWrap"),E.append("g").attr("class","controlsWrap"),b.top=q.height();var F=D.select("g").attr("transform","translate("+b.left+","+b.top+")");q.width(g/2-b.right),F.select(".legendWrap").datum(f).attr("transform","translate("+(g/2-b.left)+","+ -b.top+")").call(q),j&&(r.width(140).color(["#444","#444","#444"]),F.select(".controlsWrap").datum(v).attr("transform","translate(0,"+ -b.top+")").call(r));var G=F.select(".linesWrap").datum(z.filter(function(a){return!a.disabled}));d3.transition(G).call(s);var H=G.selectAll(".indexLine").data([u]);H.enter().append("rect").attr("class","indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).call(w),H.attr("transform",function(a){return"translate("+m(a.i)+",0)"}).attr("height",y),o.domain(l.domain()).range(l.range()).ticks(g/100).tickSize(-y,0),F.select(".x.axis").attr("transform","translate(0,"+n.range()[0]+")"),d3.transition(F.select(".x.axis")).call(o),p.domain(n.domain()).range(n.range()).ticks(h/36).tickSize(-x,0),d3.transition(F.select(".y.axis")).call(p),q.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,f.filter(function(a){return!a.disabled}).length||f.map(function(a){a.disabled=!1,D.selectAll(".series").classed("disabled",!1);return a}),a.transition().call(A)}),r.dispatch.on("legendClick",function(b,c){b.disabled=!b.disabled,k=!b.disabled,a.transition().call(A)}),s.dispatch.on("elementMouseover.tooltip",function(a){t.tooltipShow({point:a.point,series:a.series,pos:[a.pos[0]+b.left,a.pos[1]+b.top],seriesIndex:a.seriesIndex,pointIndex:a.pointIndex})}),s.dispatch.on("elementMouseout.tooltip",function(a){t.tooltipHide(a)})});return A}function z(a,b){d3.transition(d3.select(".chart-"+i)).call(A)}function y(a,b){a.x+=d3.event.dx,a.i=Math.round(m.invert(a.x)),d3.select(this).attr("transform","translate("+m(a.i)+",0)")}function x(a,b){}var b={top:30,right:20,bottom:30,left:60},c=function(){return 960},d=function(){return 500},e=d3.scale.category20().range(),f=function(){return 2.5},g=function(a){return a.x},h=function(a){return a.y},i=Math.floor(Math.random()*1e4),j=!0,k=!0,l=d3.scale.linear(),m=d3.scale.linear(),n=d3.scale.linear(),o=a.models.axis().scale(l).orient("bottom"),p=a.models.axis().scale(n).orient("left"),q=a.models.legend().height(30),r=a.models.legend().height(30),s=a.models.line(),t=d3.dispatch("tooltipShow","tooltipHide"),u={i:0,x:0},v=[{key:"Re-scale y-axis"}],w=d3.behavior.drag().on("dragstart",x).on("drag",y).on("dragend",z);A.dispatch=t,A.x=function(a){if(!arguments.length)return g;g=a;return A},A.y=function(a){if(!arguments.length)return h;h=a;return A},A.margin=function(a){if(!arguments.length)return b;b=a;return A},A.width=function(a){if(!arguments.length)return c;c=d3.functor(a);return A},A.height=function(a){if(!arguments.length)return d;d=d3.functor(a);return A},A.color=function(a){if(!arguments.length)return e;e=a,q.color(a);return A},A.dotRadius=function(a){if(!arguments.length)return f;f=d3.functor(a),s.dotRadius=a;return A},A.showRescaleToggle=function(a){if(!arguments.length)return j;j=a;return A},A.xAxis=o,A.yAxis=p;return A},a.models.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=(d||parseInt(z.style("width"))||960)-b.left-b.right,D=(e||parseInt(z.style("height"))||400)-b.top-b.bottom,E=C(u.i,y);n.domain([0,y[0].values.length-1]).range([0,A]).clamp(!0);var F=z.selectAll("g.wrap.cumulativeLine").data([E]),G=F.enter().append("g").attr("class","wrap nvd3 cumulativeLine").append("g");G.append("g").attr("class","x axis"),G.append("g").attr("class","y axis"),G.append("g").attr("class","linesWrap"),G.append("g").attr("class","legendWrap"),G.append("g").attr("class","controlsWrap");var H=F.select("g");f&&(r.width(A),H.select(".legendWrap").datum(y).call(r),b.top!=r.height()&&(b.top=r.height(),D=(e||parseInt(z.style("height"))||400)-b.top-b.bottom),H.select(".legendWrap").attr("transform","translate(0,"+ -b.top+")")),i&&(s.width(140).color(["#444","#444","#444"]),H.select(".controlsWrap").datum(v).attr("transform","translate(0,"+ -b.top+")").call(s)),k.width(A).height(D).color(E.map(function(a,b){return a.color||c[b%10]}).filter(function(a,b){return!y[b].disabled})),H.attr("transform","translate("+b.left+","+b.top+")");var I=H.select(".linesWrap").datum(E.filter(function(a){return!a.disabled}));d3.transition(I).call(k);var J=I.selectAll(".indexLine").data([u]);J.enter().append("rect").attr("class","indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).call(x),J.attr("transform",function(a){return"translate("+n(a.i)+",0)"}).attr("height",D),p.scale(l).ticks(A/100).tickSize(-D,0),H.select(".x.axis").attr("transform","translate(0,"+m.range()[0]+")"),d3.transition(H.select(".x.axis")).call(p),q.scale(m).ticks(D/36).tickSize(-A,0),d3.transition(H.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,F.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,z[0][0])}),k.dispatch.on("elementMouseout.tooltip",function(a){t.tooltipHide(a)}),g&&t.on("tooltipHide",a.tooltip.cleanup)}),B.update=function(){B(h)};return B}function A(a,b){B.update()}function z(a,b){a.x+=d3.event.dx,a.i=Math.round(n.invert(a.x)),d3.select(this).attr("transform","translate("+n(a.i)+",0)")}function y(a,b){}var b={top:30,right:20,bottom:50,left:60},c=d3.scale.category20().range(),d=null,e=null,f=!0,g=!0,h=function(a,b,c,d,e){return"

"+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"),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;o=o||e,p=p||f,s=s.map(function(a,b){a.values=a.values.map(function(a){a.series=b;return a});return a});var v=m&&n?[]:s.map(function(a){return a.values.map(function(a,b){return{x:g(a,b),y:h(a,b),y0:a.y0}})});e.domain(m||d3.merge(v).map(function(a){return a.x})).rangeBands([0,t],.1),f.domain(n||d3.extent(d3.merge(v).map(function(a){return a.y}).concat(i))),k?f.range([u-(f.domain()[0]<0?12:0),f.domain()[1]<0?0:12]):f.range([u,0]);var w=d3.select(this).selectAll("g.wrap.discretebar").data([s]),z=w.enter().append("g").attr("class","wrap nvd3 discretebar"),A=z.append("g");A.append("g").attr("class","groups");var B=w.select("g");w.attr("transform","translate("+a.left+","+a.top+")");var C=w.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.key});C.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(C.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),C.attr("class",function(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}),d3.transition(C).style("stroke-opacity",1).style("fill-opacity",.75);var D=C.selectAll("g.bar").data(function(a){return a.values});D.exit().remove();var E=D.enter().append("g").attr("transform",function(a,b,c){return"translate("+e(g(a,b))+", "+f(0)+")"}).on("mouseover",function(a,b){d3.select(this).classed("hover",!0),q.elementMouseover({value:h(a,b),point:a,series:s[a.series],pos:[e(g(a,b))+e.rangeBand()*(a.series+.5)/s.length,f(h(a,b))],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),q.elementMouseout({value:h(a,b),point:a,series:s[a.series],pointIndex:b,seriesIndex:a.series,e:d3.event})}).on("click",function(a,b){q.elementClick({value:h(a,b),point:a,series:s[a.series],pos:[e(g(a,b))+e.rangeBand()*(a.series+.5)/s.length,f(h(a,b))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(a,b){q.elementDblClick({value:h(a,b),point:a,series:s[a.series],pos:[e(g(a,b))+e.rangeBand()*(a.series+.5)/s.length,f(h(a,b))],pointIndex:b,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()});E.append("rect").attr("height",0).attr("width",e.rangeBand()/s.length).style("fill",function(a,b){return a.color||j[b%10]}).style("stroke",function(a,b){return a.color||j[b%10]}),k?(E.append("text").attr("text-anchor","middle"),D.selectAll("text").attr("dx",e.rangeBand()/2).attr("dy",function(a,b){return h(a,b)<0?f(h(a,b))-f(0)+12:-4}).text(function(a,b){return l(h(a,b))})):D.selectAll("text").remove(),D.attr("class",function(a,b){return h(a,b)<0?"bar negative":"bar positive"}),d3.transition(D).attr("transform",function(a,b){return"translate("+e(g(a,b))+", "+(h(a,b)<0?f(0):f(h(a,b)))+")"}).selectAll("rect").attr("width",e.rangeBand()/s.length).attr("height",function(a,b){return Math.abs(f(h(a,b))-f(0))}),r.update=function(){d.transition().call(r)},o=e.copy(),p=f.copy()});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=(c||parseInt(p.style("width"))||960)-b.left-b.right,s=(d||parseInt(p.style("height"))||400)-b.top-b.bottom;i.width(r).height(s);var t=p.selectAll("g.wrap.discreteBarWithAxes").data([h]),u=t.enter().append("g").attr("class","wrap nvd3 discreteBarWithAxes").append("g"),v=u.append("defs");u.append("g").attr("class","x axis"),u.append("g").attr("class","y axis"),u.append("g").attr("class","barsWrap");var w=t.select("g");w.attr("transform","translate("+b.left+","+b.top+")");var z=w.select(".barsWrap").datum(h.filter(function(a){return!a.disabled}));d3.transition(z).call(i),v.append("clipPath").attr("id","x-label-clip-"+i.id()).append("rect"),w.select("#x-label-clip-"+i.id()+" rect").attr("width",j.rangeBand()*(f?2:1)).attr("height",16).attr("x",-j.rangeBand()/(f?1:2)),l.ticks(r/100).tickSize(-s,0),w.select(".x.axis").attr("transform","translate(0,"+(k.range()[0]+(i.showValues()?16:0))+")"),d3.transition(w.select(".x.axis")).call(l);var A=w.select(".x.axis").selectAll("g");f&&A.selectAll("text").attr("transform",function(a,b,c){return"translate(0,"+(c%2==0?"0":"12")+")"}),A.selectAll("text").attr("clip-path",function(a,b,c){return"url(#x-label-clip-"+i.id()+")"}),m.ticks(s/36).tickSize(-r,0),d3.transition(w.select(".y.axis")).call(m),i.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],n.tooltipShow(a)}),g&&n.on("tooltipShow",function(a){o(a,p[0][0])}),i.dispatch.on("elementMouseout.tooltip",function(a){n.tooltipHide(a)}),g&&n.on("tooltipHide",a.tooltip.cleanup),q.update=function(){e.transition().call(q)}});return q}var b={top:30,right:20,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!1,g=!0,h=function(a,b,c,d,e){return"

"+b+"

"+"

"+c+"

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

"+a+"

"+"

"+c+" at "+b+"

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

"+a+"

"+"

"+c+" at "+b+"

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

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

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

"+b+"

"+"

"+c+"

"},j=a.models.multiBarHorizontal().stacked(!1),k=j.xScale(),l=j.yScale(),m=a.models.axis().scale(k).orient("left").highlightZero(!1),n=a.models.axis().scale(l).orient("bottom"),o=a.models.legend().height(30),p=a.models.legend().height(30),q=d3.dispatch("tooltipShow","tooltipHide");m.tickFormat(function(a){return a}),n.tickFormat(d3.format(",.1f"));var r=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=m.tickFormat()(j.x()(b.point)),g=n.tickFormat()(j.y()(b.point)),h=i(b.series.key,f,g,b,t);a.tooltip.show([d,e],h,b.value<0?"e":"w")},s=[{key:"Grouped"},{key:"Stacked",disabled:!0}];t.dispatch=q,t.multibar=j,t.legend=o,t.xAxis=m,t.yAxis=n,d3.rebind(t,j,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id","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 K(){if(!p){F.select("#points-clip-"+f).remove(),F.select(".point-paths").remove();return!1}I.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){H.append("clipPath").attr("id","points-clip-"+f);var c=F.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]}),F.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=F.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;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 E=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(E).map(function(a){return a.x}).concat(m))).range([0,C]),h.domain(u||d3.extent(d3.merge(E).map(function(a){return a.y}).concat(n))).range([D,0]),i.domain(v||d3.extent(d3.merge(E).map(function(a){return a.size}).concat(o))).range([16,256]);var F=d3.select(this).selectAll("g.wrap.scatter").data([B]),G=F.enter().append("g").attr("class","wrap nvd3 scatter chart-"+f),H=G.append("defs"),I=G.append("g"),J=F.select("g");I.append("g").attr("class","groups"),F.attr("transform","translate("+a.left+","+a.top+")"),H.append("clipPath").attr("id","edge-clip-"+f).append("rect"),F.select("#edge-clip-"+f+" rect").attr("width",C).attr("height",D),J.attr("clip-path",q?"url(#edge-clip-"+f+")":"");var L=F.select(".groups").selectAll(".group").data(function(a){return a},function(a){return a.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(a,b){return"group series-"+b}).classed("hover",function(a){return a.hover}),d3.transition(L).style("fill",function(a,b){return d[b%20]}).style("stroke",function(a,b){return d[b%20]}).style("stroke-opacity",1).style("fill-opacity",.5);var M=L.selectAll("path.point").data(function(a){return a.values});M.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(L.exit().selectAll("path.point")).attr("transform",function(a,b){return"translate("+g(j(a,b))+","+h(k(a,b))+")"}).remove(),M.attr("class",function(a,b){return"point point-"+b}),d3.transition(M).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(K,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 w(j){j.each(function(k){w.update=function(){j.transition().call(w)};var l=d3.select(this),z=(c||parseInt(l.style("width"))||960)-b.left-b.right,A=(d||parseInt(l.style("height"))||400)-b.top-b.bottom;t=t||m.xScale(),u=u||m.yScale();var B=l.selectAll("g.wrap.scatterChart").data([k]),C=B.enter().append("g").attr("class","wrap nvd3 scatterChart chart-"+m.id()).append("g");C.append("g").attr("class","legendWrap"),C.append("g").attr("class","x axis"),C.append("g").attr("class","y axis"),C.append("g").attr("class","scatterWrap");var D=B.select("g");h&&(r.width(z/2),B.select(".legendWrap").datum(k).call(r),b.top!=r.height()&&(b.top=r.height(),A=(d||parseInt(l.style("height"))||400)-b.top-b.bottom),B.select(".legendWrap").attr("transform","translate("+z/2+","+ -b.top+")")),m.width(z).height(A).color(k.map(function(a,b){return a.color||e[b%20]}).filter(function(a,b){return!k[b].disabled})),D.attr("transform","translate("+b.left+","+b.top+")");var E=B.select(".scatterWrap").datum(k.filter(function(a){return!a.disabled}));d3.transition(E).call(m),p.ticks(z/100).tickSize(-A,0),D.select(".x.axis").attr("transform","translate(0,"+o.range()[0]+")"),d3.transition(D.select(".x.axis")).call(p),q.ticks(A/36).tickSize(-z,0),d3.transition(D.select(".y.axis")).call(q);if(f||g){var F=E.selectAll("g.distribution").data(function(a){return a},function(a){return a.key});F.enter().append("g").attr("class",function(a,b){return"distribution series-"+b}),F.style("stroke",function(a,b){return e.filter(function(a,b){return k[b]&&!k[b].disabled})[b%10]})}if(f){var G=F.selectAll("line.distX").data(function(a){return a.values});G.enter().append("line").attr("x1",function(a,b){return t(m.x()(a,b))}).attr("x2",function(a,b){return t(m.x()(a,b))}),d3.transition(F.exit().selectAll("line.distX")).attr("x1",function(a,b){return n(m.x()(a,b))}).attr("x2",function(a,b){return n(m.x()(a,b))}).remove(),G.attr("class",function(a,b){return"distX distX-"+b}).attr("y1",o.range()[0]).attr("y2",o.range()[0]+8),d3.transition(G).attr("x1",function(a,b){return n(m.x()(a,b))}).attr("x2",function(a,b){return n(m.x()(a,b))})}if(g){var H=F.selectAll("line.distY").data(function(a){return a.values});H.enter().append("line").attr("y1",function(a,b){return u(m.y()(a,b))}).attr("y2",function(a,b){return u(m.y()(a,b))}),d3.transition(F.exit().selectAll("line.distY")).attr("y1",function(a,b){return o(m.y()(a,b))}).attr("y2",function(a,b){return o(m.y()(a,b))}).remove(),H.attr("class",function(a,b){return"distY distY-"+b}).attr("x1",n.range()[0]).attr("x2",n.range()[0]-8),d3.transition(H).attr("y1",function(a,b){return o(m.y()(a,b))}).attr("y2",function(a,b){return o(m.y()(a,b))})}r.dispatch.on("legendClick",function(a,b,c){a.disabled=!a.disabled,k.filter(function(a){return!a.disabled}).length||k.map(function(a){a.disabled=!1,B.selectAll(".series").classed("disabled",!1);return a}),j.transition().call(w)}),m.dispatch.on("elementMouseover.tooltip",function(a){d3.select(".chart-"+m.id()+" .series-"+a.seriesIndex+" .distX-"+a.pointIndex).attr("y1",a.pos[1]),d3.select(".chart-"+m.id()+" .series-"+a.seriesIndex+" .distY-"+a.pointIndex).attr("x1",a.pos[0]),a.pos=[a.pos[0]+b.left,a.pos[1]+b.top],s.tooltipShow(a)}),i&&s.on("tooltipShow",function(a){v(a,l[0][0])}),m.dispatch.on("elementMouseout.tooltip",function(a){s.tooltipHide(a),d3.select(".chart-"+m.id()+" .series-"+a.seriesIndex+" .distX-"+a.pointIndex).attr("y1",o.range()[0]),d3.select(".chart-"+m.id()+" .series-"+a.seriesIndex+" .distY-"+a.pointIndex).attr("x1",n.range()[0])}),i&&s.on("tooltipHide",a.tooltip.cleanup),t=n.copy(),u=o.copy()});return w}var b={top:30,right:20,bottom:50,left:60},c=null,d=null,e=d3.scale.category20().range(),f=!1,g=!1,h=!0,i=!0,j=function(a,b,c){return""+b+""},k=function(a,b,c){return""+c+""},l=function(a,b,c,d,e){return"

"+a+"

"+"

"+c+" at "+b+"

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

"+a+"

"+"

"+c+" on "+b+"

"},j=a.models.stackedArea(),k=j.xScale(),l=j.yScale(),m=a.models.axis().scale(k).orient("bottom"),n=a.models.axis().scale(l).orient("left"),o=a.models.legend().height(30),p=a.models.legend().height(30),q=d3.dispatch("tooltipShow","tooltipHide"),r=[{key:"Stacked"},{key:"Stream",disabled:!0},{key:"Expanded",disabled:!0}],s=function(b,c){var d=b.pos[0]+(c.offsetLeft||0),e=b.pos[1]+(c.offsetTop||0),f=m.tickFormat()(j.x()(b.point)),g=n.tickFormat()(j.y()(b.point)),h=i(b.series.key,f,g,b,t);a.tooltip.show([d,e],h,b.value<0?"n":"s")};t.dispatch=q,t.stacked=j,t.xAxis=m,t.yAxis=n,d3.rebind(t,j,"x","y","interactive","offset","order","style","clipEdge","size","forceX","forceY","forceSize"),t.margin=function(a){if(!arguments.length)return b;b=a;return t},t.width=function(a){if(!arguments.length)return getWidth;c=a;return t},t.height=function(a){if(!arguments.length)return getHeight;d=a;return t},t.color=function(a){if(!arguments.length)return e;e=a,o.color(a);return t},t.showControls=function(a){if(!arguments.length)return f;f=a;return t},t.showLegend=function(a){if(!arguments.length)return g;g=a;return t},t.tooltips=function(a){if(!arguments.length)return h;h=a;return t},t.tooltipContent=function(a){if(!arguments.length)return i;i=a;return t};return t}})() \ No newline at end of file diff --git a/src/models/lineWithFocusChart.js b/src/models/lineWithFocusChart.js index 07b0620..29a6051 100644 --- a/src/models/lineWithFocusChart.js +++ b/src/models/lineWithFocusChart.js @@ -229,7 +229,7 @@ nv.models.lineWithFocusChart = function() { } function updateFocus() { - var yDomain = brush.empty() ? y2.domain() : d3.extent(d3.merge(data.map(function(d) { return d.values })).filter(function(d) { + var yDomain = brush.empty() ? y2.domain() : d3.extent(d3.merge(data.filter(function(d) { return !d.disabled }).map(function(d) { return d.values })).filter(function(d) { return lines.x()(d) >= brush.extent()[0] && lines.x()(d) <= brush.extent()[1]; }), lines.y()); //This doesn't account for the 1 point before and the 1 point after the domain. Would fix, but likely need to change entire methodology here