diff --git a/nv.d3.js b/nv.d3.js index 318ca28..43e1d1c 100644 --- a/nv.d3.js +++ b/nv.d3.js @@ -1420,71 +1420,68 @@ nv.utils.optionsFunc = function(args) { return chart; } - -// Chart design based on the recommendations of Stephen Few. Implementation -// based on the work of Clint Ivy, Jamie Love, and Jason Davies. -// http://projects.instantcognition.com/protovis/bulletchart/ - -nv.models.bullet = function() { +//TODO: consider deprecating and using multibar with single series for this +nv.models.historicalBar = function() { "use strict"; //============================================================ // Public Variables with Default Settings //------------------------------------------------------------ var margin = {top: 0, right: 0, bottom: 0, left: 0} - , orient = 'left' // TODO top & bottom - , reverse = false - , ranges = function(d) { return d.ranges } - , markers = function(d) { return d.markers } - , measures = function(d) { return d.measures } - , rangeLabels = function(d) { return d.rangeLabels ? d.rangeLabels : [] } - , markerLabels = function(d) { return d.markerLabels ? d.markerLabels : [] } - , measureLabels = function(d) { return d.measureLabels ? d.measureLabels : [] } - , forceX = [0] // List of numbers to Force into the X scale (ie. 0, or a max / min, etc.) - , width = 380 - , height = 30 - , tickFormat = null - , color = nv.utils.getColor(['#1f77b4']) - , dispatch = d3.dispatch('elementMouseover', 'elementMouseout') + , width = 960 + , height = 500 + , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one + , x = d3.scale.linear() + , y = d3.scale.linear() + , getX = function(d) { return d.x } + , getY = function(d) { return d.y } + , forceX = [] + , forceY = [0] + , padData = false + , clipEdge = true + , color = nv.utils.defaultColor() + , xDomain + , yDomain + , xRange + , yRange + , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout') + , interactive = true ; //============================================================ function chart(selection) { - selection.each(function(d, i) { + selection.each(function(data) { var availableWidth = width - margin.left - margin.right, availableHeight = height - margin.top - margin.bottom, container = d3.select(this); - var rangez = ranges.call(this, d, i).slice().sort(d3.descending), - markerz = markers.call(this, d, i).slice().sort(d3.descending), - measurez = measures.call(this, d, i).slice().sort(d3.descending), - rangeLabelz = rangeLabels.call(this, d, i).slice(), - markerLabelz = markerLabels.call(this, d, i).slice(), - measureLabelz = measureLabels.call(this, d, i).slice(); - //------------------------------------------------------------ // Setup Scales - // Compute the new x-scale. - var x1 = d3.scale.linear() - .domain( d3.extent(d3.merge([forceX, rangez])) ) - .range(reverse ? [availableWidth, 0] : [0, availableWidth]); + x .domain(xDomain || d3.extent(data[0].values.map(getX).concat(forceX) )) - // Retrieve the old x-scale, if this is an update. - var x0 = this.__chart__ || d3.scale.linear() - .domain([0, Infinity]) - .range(x1.range()); + if (padData) + x.range(xRange || [availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5) / data[0].values.length ]); + else + x.range(xRange || [0, availableWidth]); - // Stash the new scale. - this.__chart__ = x1; + y .domain(yDomain || d3.extent(data[0].values.map(getY).concat(forceY) )) + .range(yRange || [availableHeight, 0]); + // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point - var rangeMin = d3.min(rangez), //rangez[2] - rangeMax = d3.max(rangez), //rangez[0] - rangeAvg = rangez[1]; + if (x.domain()[0] === x.domain()[1]) + x.domain()[0] ? + x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01]) + : x.domain([-1,1]); + + if (y.domain()[0] === y.domain()[1]) + y.domain()[0] ? + y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01]) + : y.domain([-1,1]); //------------------------------------------------------------ @@ -1492,236 +1489,144 @@ nv.models.bullet = function() { //------------------------------------------------------------ // Setup containers and skeleton of chart - var wrap = container.selectAll('g.nv-wrap.nv-bullet').data([d]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-bullet'); + var wrap = container.selectAll('g.nv-wrap.nv-historicalBar-' + id).data([data[0].values]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-historicalBar-' + id); + var defsEnter = wrapEnter.append('defs'); var gEnter = wrapEnter.append('g'); var g = wrap.select('g'); - gEnter.append('rect').attr('class', 'nv-range nv-rangeMax'); - gEnter.append('rect').attr('class', 'nv-range nv-rangeAvg'); - gEnter.append('rect').attr('class', 'nv-range nv-rangeMin'); - gEnter.append('rect').attr('class', 'nv-measure'); - gEnter.append('path').attr('class', 'nv-markerTriangle'); + gEnter.append('g').attr('class', 'nv-bars'); wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); //------------------------------------------------------------ + container + .on('click', function(d,i) { + dispatch.chartClick({ + data: d, + index: i, + pos: d3.event, + id: id + }); + }); - var w0 = function(d) { return Math.abs(x0(d) - x0(0)) }, // TODO: could optimize by precalculating x0(0) and x1(0) - w1 = function(d) { return Math.abs(x1(d) - x1(0)) }; - var xp0 = function(d) { return d < 0 ? x0(d) : x0(0) }, - xp1 = function(d) { return d < 0 ? x1(d) : x1(0) }; + defsEnter.append('clipPath') + .attr('id', 'nv-chart-clip-path-' + id) + .append('rect'); - g.select('rect.nv-rangeMax') - .attr('height', availableHeight) - .attr('width', w1(rangeMax > 0 ? rangeMax : rangeMin)) - .attr('x', xp1(rangeMax > 0 ? rangeMax : rangeMin)) - .datum(rangeMax > 0 ? rangeMax : rangeMin) - /* - .attr('x', rangeMin < 0 ? - rangeMax > 0 ? - x1(rangeMin) - : x1(rangeMax) - : x1(0)) - */ + wrap.select('#nv-chart-clip-path-' + id + ' rect') + .attr('width', availableWidth) + .attr('height', availableHeight); - g.select('rect.nv-rangeAvg') - .attr('height', availableHeight) - .attr('width', w1(rangeAvg)) - .attr('x', xp1(rangeAvg)) - .datum(rangeAvg) - /* - .attr('width', rangeMax <= 0 ? - x1(rangeMax) - x1(rangeAvg) - : x1(rangeAvg) - x1(rangeMin)) - .attr('x', rangeMax <= 0 ? - x1(rangeAvg) - : x1(rangeMin)) - */ + g .attr('clip-path', clipEdge ? 'url(#nv-chart-clip-path-' + id + ')' : ''); - g.select('rect.nv-rangeMin') - .attr('height', availableHeight) - .attr('width', w1(rangeMax)) - .attr('x', xp1(rangeMax)) - .attr('width', w1(rangeMax > 0 ? rangeMin : rangeMax)) - .attr('x', xp1(rangeMax > 0 ? rangeMin : rangeMax)) - .datum(rangeMax > 0 ? rangeMin : rangeMax) - /* - .attr('width', rangeMax <= 0 ? - x1(rangeAvg) - x1(rangeMin) - : x1(rangeMax) - x1(rangeAvg)) - .attr('x', rangeMax <= 0 ? - x1(rangeMin) - : x1(rangeAvg)) - */ - g.select('rect.nv-measure') - .style('fill', color) - .attr('height', availableHeight / 3) - .attr('y', availableHeight / 3) - .attr('width', measurez < 0 ? - x1(0) - x1(measurez[0]) - : x1(measurez[0]) - x1(0)) - .attr('x', xp1(measurez)) - .on('mouseover', function() { - dispatch.elementMouseover({ - value: measurez[0], - label: measureLabelz[0] || 'Current', - pos: [x1(measurez[0]), availableHeight/2] - }) - }) - .on('mouseout', function() { - dispatch.elementMouseout({ - value: measurez[0], - label: measureLabelz[0] || 'Current' - }) - }) - var h3 = availableHeight / 6; - if (markerz[0]) { - g.selectAll('path.nv-markerTriangle') - .attr('transform', function(d) { return 'translate(' + x1(markerz[0]) + ',' + (availableHeight / 2) + ')' }) - .attr('d', 'M0,' + h3 + 'L' + h3 + ',' + (-h3) + ' ' + (-h3) + ',' + (-h3) + 'Z') - .on('mouseover', function() { - dispatch.elementMouseover({ - value: markerz[0], - label: markerLabelz[0] || 'Previous', - pos: [x1(markerz[0]), availableHeight/2] - }) - }) - .on('mouseout', function() { - dispatch.elementMouseout({ - value: markerz[0], - label: markerLabelz[0] || 'Previous' - }) - }); - } else { - g.selectAll('path.nv-markerTriangle').remove(); - } + var bars = wrap.select('.nv-bars').selectAll('.nv-bar') + .data(function(d) { return d }, function(d,i) {return getX(d,i)}); + bars.exit().remove(); - wrap.selectAll('.nv-range') - .on('mouseover', function(d,i) { - var label = rangeLabelz[i] || (!i ? "Maximum" : i == 1 ? "Mean" : "Minimum"); + var barsEnter = bars.enter().append('rect') + //.attr('class', function(d,i,j) { return (getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive') + ' nv-bar-' + j + '-' + i }) + .attr('x', 0 ) + .attr('y', function(d,i) { return nv.utils.NaNtoZero(y(Math.max(0, getY(d,i)))) }) + .attr('height', function(d,i) { return nv.utils.NaNtoZero(Math.abs(y(getY(d,i)) - y(0))) }) + .attr('transform', function(d,i) { return 'translate(' + (x(getX(d,i)) - availableWidth / data[0].values.length * .45) + ',0)'; }) + .on('mouseover', function(d,i) { + if (!interactive) return; + d3.select(this).classed('hover', true); dispatch.elementMouseover({ - value: d, - label: label, - pos: [x1(d), availableHeight/2] - }) - }) - .on('mouseout', function(d,i) { - var label = rangeLabelz[i] || (!i ? "Maximum" : i == 1 ? "Mean" : "Minimum"); + point: d, + series: data[0], + pos: [x(getX(d,i)), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted + pointIndex: i, + seriesIndex: 0, + e: d3.event + }); - dispatch.elementMouseout({ - value: d, - label: label - }) }) - -/* // THIS IS THE PREVIOUS BULLET IMPLEMENTATION, WILL REMOVE SHORTLY - // Update the range rects. - var range = g.selectAll('rect.nv-range') - .data(rangez); - - range.enter().append('rect') - .attr('class', function(d, i) { return 'nv-range nv-s' + i; }) - .attr('width', w0) - .attr('height', availableHeight) - .attr('x', reverse ? x0 : 0) - .on('mouseover', function(d,i) { - dispatch.elementMouseover({ - value: d, - label: (i <= 0) ? 'Maximum' : (i > 1) ? 'Minimum' : 'Mean', //TODO: make these labels a variable - pos: [x1(d), availableHeight/2] - }) + .on('mouseout', function(d,i) { + if (!interactive) return; + d3.select(this).classed('hover', false); + dispatch.elementMouseout({ + point: d, + series: data[0], + pointIndex: i, + seriesIndex: 0, + e: d3.event + }); }) - .on('mouseout', function(d,i) { - dispatch.elementMouseout({ - value: d, - label: (i <= 0) ? 'Minimum' : (i >=1) ? 'Maximum' : 'Mean' //TODO: make these labels a variable - }) - }) - - d3.transition(range) - .attr('x', reverse ? x1 : 0) - .attr('width', w1) - .attr('height', availableHeight); - - - // Update the measure rects. - var measure = g.selectAll('rect.nv-measure') - .data(measurez); - - measure.enter().append('rect') - .attr('class', function(d, i) { return 'nv-measure nv-s' + i; }) - .style('fill', function(d,i) { return color(d,i ) }) - .attr('width', w0) - .attr('height', availableHeight / 3) - .attr('x', reverse ? x0 : 0) - .attr('y', availableHeight / 3) - .on('mouseover', function(d) { - dispatch.elementMouseover({ - value: d, - label: 'Current', //TODO: make these labels a variable - pos: [x1(d), availableHeight/2] - }) - }) - .on('mouseout', function(d) { - dispatch.elementMouseout({ - value: d, - label: 'Current' //TODO: make these labels a variable - }) + .on('click', function(d,i) { + if (!interactive) return; + dispatch.elementClick({ + //label: d[label], + value: getY(d,i), + data: d, + index: i, + pos: [x(getX(d,i)), y(getY(d,i))], + e: d3.event, + id: id + }); + d3.event.stopPropagation(); }) + .on('dblclick', function(d,i) { + if (!interactive) return; + dispatch.elementDblClick({ + //label: d[label], + value: getY(d,i), + data: d, + index: i, + pos: [x(getX(d,i)), y(getY(d,i))], + e: d3.event, + id: id + }); + d3.event.stopPropagation(); + }); - d3.transition(measure) - .attr('width', w1) - .attr('height', availableHeight / 3) - .attr('x', reverse ? x1 : 0) - .attr('y', availableHeight / 3); - - + bars + .attr('fill', function(d,i) { return color(d, i); }) + .attr('class', function(d,i,j) { return (getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive') + ' nv-bar-' + j + '-' + i }) + .transition() + .attr('transform', function(d,i) { return 'translate(' + (x(getX(d,i)) - availableWidth / data[0].values.length * .45) + ',0)'; }) + //TODO: better width calculations that don't assume always uniform data spacing;w + .attr('width', (availableWidth / data[0].values.length) * .9 ); - // Update the marker lines. - var marker = g.selectAll('path.nv-markerTriangle') - .data(markerz); - var h3 = availableHeight / 6; - marker.enter().append('path') - .attr('class', 'nv-markerTriangle') - .attr('transform', function(d) { return 'translate(' + x0(d) + ',' + (availableHeight / 2) + ')' }) - .attr('d', 'M0,' + h3 + 'L' + h3 + ',' + (-h3) + ' ' + (-h3) + ',' + (-h3) + 'Z') - .on('mouseover', function(d,i) { - dispatch.elementMouseover({ - value: d, - label: 'Previous', - pos: [x1(d), availableHeight/2] - }) + bars.transition() + .attr('y', function(d,i) { + var rval = getY(d,i) < 0 ? + y(0) : + y(0) - y(getY(d,i)) < 1 ? + y(0) - 1 : + y(getY(d,i)); + return nv.utils.NaNtoZero(rval); }) - .on('mouseout', function(d,i) { - dispatch.elementMouseout({ - value: d, - label: 'Previous' - }) - }); - - d3.transition(marker) - .attr('transform', function(d) { return 'translate(' + (x1(d) - x1(0)) + ',' + (availableHeight / 2) + ')' }); - - marker.exit().remove(); -*/ + .attr('height', function(d,i) { return nv.utils.NaNtoZero(Math.max(Math.abs(y(getY(d,i)) - y(0)),1)) }); }); - // d3.timer.flush(); // Not needed? - return chart; } + //Create methods to allow outside functions to highlight a specific bar. + chart.highlightPoint = function(pointIndex, isHoverOver) { + d3.select(".nv-historicalBar-" + id) + .select(".nv-bars .nv-bar-0-" + pointIndex) + .classed("hover", isHoverOver) + ; + }; + chart.clearHighlights = function() { + d3.select(".nv-historicalBar-" + id) + .select(".nv-bars .nv-bar.hover") + .classed("hover", false) + ; + }; //============================================================ // Expose Public Variables //------------------------------------------------------------ @@ -1730,38 +1635,24 @@ nv.models.bullet = function() { chart.options = nv.utils.optionsFunc.bind(chart); - // left, right, top, bottom - chart.orient = function(_) { - if (!arguments.length) return orient; - orient = _; - reverse = orient == 'right' || orient == 'bottom'; - return chart; - }; - - // ranges (bad, satisfactory, good) - chart.ranges = function(_) { - if (!arguments.length) return ranges; - ranges = _; - return chart; - }; - - // markers (previous, goal) - chart.markers = function(_) { - if (!arguments.length) return markers; - markers = _; + chart.x = function(_) { + if (!arguments.length) return getX; + getX = _; return chart; }; - // measures (actual, forecast) - chart.measures = function(_) { - if (!arguments.length) return measures; - measures = _; + chart.y = function(_) { + if (!arguments.length) return getY; + getY = _; return chart; }; - chart.forceX = function(_) { - if (!arguments.length) return forceX; - forceX = _; + chart.margin = function(_) { + if (!arguments.length) return margin; + margin.top = typeof _.top != 'undefined' ? _.top : margin.top; + margin.right = typeof _.right != 'undefined' ? _.right : margin.right; + margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; + margin.left = typeof _.left != 'undefined' ? _.left : margin.left; return chart; }; @@ -1777,18 +1668,63 @@ nv.models.bullet = function() { return chart; }; - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; + chart.xScale = function(_) { + if (!arguments.length) return x; + x = _; return chart; }; - chart.tickFormat = function(_) { - if (!arguments.length) return tickFormat; - tickFormat = _; + chart.yScale = function(_) { + if (!arguments.length) return y; + y = _; + return chart; + }; + + chart.xDomain = function(_) { + if (!arguments.length) return xDomain; + xDomain = _; + return chart; + }; + + chart.yDomain = function(_) { + if (!arguments.length) return yDomain; + yDomain = _; + return chart; + }; + + chart.xRange = function(_) { + if (!arguments.length) return xRange; + xRange = _; + return chart; + }; + + chart.yRange = function(_) { + if (!arguments.length) return yRange; + yRange = _; + return chart; + }; + + chart.forceX = function(_) { + if (!arguments.length) return forceX; + forceX = _; + return chart; + }; + + chart.forceY = function(_) { + if (!arguments.length) return forceY; + forceY = _; + return chart; + }; + + chart.padData = function(_) { + if (!arguments.length) return padData; + padData = _; + return chart; + }; + + chart.clipEdge = function(_) { + if (!arguments.length) return clipEdge; + clipEdge = _; return chart; }; @@ -1798,124 +1734,74 @@ nv.models.bullet = function() { return chart; }; - //============================================================ + chart.id = function(_) { + if (!arguments.length) return id; + id = _; + return chart; + }; + chart.interactive = function(_) { + if(!arguments.length) return interactive; + interactive = false; + return chart; + }; - return chart; -}; + //============================================================ + return chart; +} // Chart design based on the recommendations of Stephen Few. Implementation // based on the work of Clint Ivy, Jamie Love, and Jason Davies. // http://projects.instantcognition.com/protovis/bulletchart/ -nv.models.bulletChart = function() { + +nv.models.bullet = function() { "use strict"; //============================================================ // Public Variables with Default Settings //------------------------------------------------------------ - var bullet = nv.models.bullet() - ; - - var orient = 'left' // TODO top & bottom + var margin = {top: 0, right: 0, bottom: 0, left: 0} + , orient = 'left' // TODO top & bottom , reverse = false - , margin = {top: 5, right: 40, bottom: 20, left: 120} , ranges = function(d) { return d.ranges } , markers = function(d) { return d.markers } , measures = function(d) { return d.measures } - , width = null - , height = 55 + , rangeLabels = function(d) { return d.rangeLabels ? d.rangeLabels : [] } + , markerLabels = function(d) { return d.markerLabels ? d.markerLabels : [] } + , measureLabels = function(d) { return d.measureLabels ? d.measureLabels : [] } + , forceX = [0] // List of numbers to Force into the X scale (ie. 0, or a max / min, etc.) + , width = 380 + , height = 30 , tickFormat = null - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + x + '

' + - '

' + y + '

' - } - , noData = 'No Data Available.' - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide') + , color = nv.utils.getColor(['#1f77b4']) + , dispatch = d3.dispatch('elementMouseover', 'elementMouseout') ; //============================================================ - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ) + margin.left, - top = e.pos[1] + ( offsetElement.offsetTop || 0) + margin.top, - content = tooltip(e.key, e.label, e.value, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'e' : 'w', null, offsetElement); - }; - - //============================================================ - - function chart(selection) { selection.each(function(d, i) { - var container = d3.select(this); - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, + var availableWidth = width - margin.left - margin.right, availableHeight = height - margin.top - margin.bottom, - that = this; - - - chart.update = function() { chart(selection) }; - chart.container = this; - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!d || !ranges.call(this, d, i)) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', 18 + margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - + container = d3.select(this); var rangez = ranges.call(this, d, i).slice().sort(d3.descending), markerz = markers.call(this, d, i).slice().sort(d3.descending), - measurez = measures.call(this, d, i).slice().sort(d3.descending); - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-bulletChart').data([d]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-bulletChart'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-bulletWrap'); - gEnter.append('g').attr('class', 'nv-titles'); + measurez = measures.call(this, d, i).slice().sort(d3.descending), + rangeLabelz = rangeLabels.call(this, d, i).slice(), + markerLabelz = markerLabels.call(this, d, i).slice(), + measureLabelz = measureLabels.call(this, d, i).slice(); - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); //------------------------------------------------------------ - + // Setup Scales // Compute the new x-scale. var x1 = d3.scale.linear() - .domain([0, Math.max(rangez[0], markerz[0], measurez[0])]) // TODO: need to allow forceX and forceY, and xDomain, yDomain + .domain( d3.extent(d3.merge([forceX, rangez])) ) .range(reverse ? [availableWidth, 0] : [0, availableWidth]); // Retrieve the old x-scale, if this is an update. @@ -1926,134 +1812,245 @@ nv.models.bulletChart = function() { // Stash the new scale. this.__chart__ = x1; - /* - // Derive width-scales from the x-scales. - var w0 = bulletWidth(x0), - w1 = bulletWidth(x1); - function bulletWidth(x) { - var x0 = x(0); - return function(d) { - return Math.abs(x(d) - x(0)); - }; - } + var rangeMin = d3.min(rangez), //rangez[2] + rangeMax = d3.max(rangez), //rangez[0] + rangeAvg = rangez[1]; - function bulletTranslate(x) { - return function(d) { - return 'translate(' + x(d) + ',0)'; - }; - } - */ + //------------------------------------------------------------ - var w0 = function(d) { return Math.abs(x0(d) - x0(0)) }, // TODO: could optimize by precalculating x0(0) and x1(0) - w1 = function(d) { return Math.abs(x1(d) - x1(0)) }; + //------------------------------------------------------------ + // Setup containers and skeleton of chart - var title = gEnter.select('.nv-titles').append('g') - .attr('text-anchor', 'end') - .attr('transform', 'translate(-6,' + (height - margin.top - margin.bottom) / 2 + ')'); - title.append('text') - .attr('class', 'nv-title') - .text(function(d) { return d.title; }); + var wrap = container.selectAll('g.nv-wrap.nv-bullet').data([d]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-bullet'); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g'); - title.append('text') - .attr('class', 'nv-subtitle') - .attr('dy', '1em') - .text(function(d) { return d.subtitle; }); + gEnter.append('rect').attr('class', 'nv-range nv-rangeMax'); + gEnter.append('rect').attr('class', 'nv-range nv-rangeAvg'); + gEnter.append('rect').attr('class', 'nv-range nv-rangeMin'); + gEnter.append('rect').attr('class', 'nv-measure'); + gEnter.append('path').attr('class', 'nv-markerTriangle'); + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + //------------------------------------------------------------ - bullet - .width(availableWidth) - .height(availableHeight) - var bulletWrap = g.select('.nv-bulletWrap'); - d3.transition(bulletWrap).call(bullet); + var w0 = function(d) { return Math.abs(x0(d) - x0(0)) }, // TODO: could optimize by precalculating x0(0) and x1(0) + w1 = function(d) { return Math.abs(x1(d) - x1(0)) }; + var xp0 = function(d) { return d < 0 ? x0(d) : x0(0) }, + xp1 = function(d) { return d < 0 ? x1(d) : x1(0) }; + g.select('rect.nv-rangeMax') + .attr('height', availableHeight) + .attr('width', w1(rangeMax > 0 ? rangeMax : rangeMin)) + .attr('x', xp1(rangeMax > 0 ? rangeMax : rangeMin)) + .datum(rangeMax > 0 ? rangeMax : rangeMin) + /* + .attr('x', rangeMin < 0 ? + rangeMax > 0 ? + x1(rangeMin) + : x1(rangeMax) + : x1(0)) + */ - // Compute the tick format. - var format = tickFormat || x1.tickFormat( availableWidth / 100 ); + g.select('rect.nv-rangeAvg') + .attr('height', availableHeight) + .attr('width', w1(rangeAvg)) + .attr('x', xp1(rangeAvg)) + .datum(rangeAvg) + /* + .attr('width', rangeMax <= 0 ? + x1(rangeMax) - x1(rangeAvg) + : x1(rangeAvg) - x1(rangeMin)) + .attr('x', rangeMax <= 0 ? + x1(rangeAvg) + : x1(rangeMin)) + */ - // Update the tick groups. - var tick = g.selectAll('g.nv-tick') - .data(x1.ticks( availableWidth / 50 ), function(d) { - return this.textContent || format(d); - }); + g.select('rect.nv-rangeMin') + .attr('height', availableHeight) + .attr('width', w1(rangeMax)) + .attr('x', xp1(rangeMax)) + .attr('width', w1(rangeMax > 0 ? rangeMin : rangeMax)) + .attr('x', xp1(rangeMax > 0 ? rangeMin : rangeMax)) + .datum(rangeMax > 0 ? rangeMin : rangeMax) + /* + .attr('width', rangeMax <= 0 ? + x1(rangeAvg) - x1(rangeMin) + : x1(rangeMax) - x1(rangeAvg)) + .attr('x', rangeMax <= 0 ? + x1(rangeMin) + : x1(rangeAvg)) + */ - // Initialize the ticks with the old scale, x0. - var tickEnter = tick.enter().append('g') - .attr('class', 'nv-tick') - .attr('transform', function(d) { return 'translate(' + x0(d) + ',0)' }) - .style('opacity', 1e-6); + g.select('rect.nv-measure') + .style('fill', color) + .attr('height', availableHeight / 3) + .attr('y', availableHeight / 3) + .attr('width', measurez < 0 ? + x1(0) - x1(measurez[0]) + : x1(measurez[0]) - x1(0)) + .attr('x', xp1(measurez)) + .on('mouseover', function() { + dispatch.elementMouseover({ + value: measurez[0], + label: measureLabelz[0] || 'Current', + pos: [x1(measurez[0]), availableHeight/2] + }) + }) + .on('mouseout', function() { + dispatch.elementMouseout({ + value: measurez[0], + label: measureLabelz[0] || 'Current' + }) + }) - tickEnter.append('line') - .attr('y1', availableHeight) - .attr('y2', availableHeight * 7 / 6); + var h3 = availableHeight / 6; + if (markerz[0]) { + g.selectAll('path.nv-markerTriangle') + .attr('transform', function(d) { return 'translate(' + x1(markerz[0]) + ',' + (availableHeight / 2) + ')' }) + .attr('d', 'M0,' + h3 + 'L' + h3 + ',' + (-h3) + ' ' + (-h3) + ',' + (-h3) + 'Z') + .on('mouseover', function() { + dispatch.elementMouseover({ + value: markerz[0], + label: markerLabelz[0] || 'Previous', + pos: [x1(markerz[0]), availableHeight/2] + }) + }) + .on('mouseout', function() { + dispatch.elementMouseout({ + value: markerz[0], + label: markerLabelz[0] || 'Previous' + }) + }); + } else { + g.selectAll('path.nv-markerTriangle').remove(); + } - tickEnter.append('text') - .attr('text-anchor', 'middle') - .attr('dy', '1em') - .attr('y', availableHeight * 7 / 6) - .text(format); + wrap.selectAll('.nv-range') + .on('mouseover', function(d,i) { + var label = rangeLabelz[i] || (!i ? "Maximum" : i == 1 ? "Mean" : "Minimum"); - // Transition the updating ticks to the new scale, x1. - var tickUpdate = d3.transition(tick) - .attr('transform', function(d) { return 'translate(' + x1(d) + ',0)' }) - .style('opacity', 1); + dispatch.elementMouseover({ + value: d, + label: label, + pos: [x1(d), availableHeight/2] + }) + }) + .on('mouseout', function(d,i) { + var label = rangeLabelz[i] || (!i ? "Maximum" : i == 1 ? "Mean" : "Minimum"); - tickUpdate.select('line') - .attr('y1', availableHeight) - .attr('y2', availableHeight * 7 / 6); + dispatch.elementMouseout({ + value: d, + label: label + }) + }) - tickUpdate.select('text') - .attr('y', availableHeight * 7 / 6); +/* // THIS IS THE PREVIOUS BULLET IMPLEMENTATION, WILL REMOVE SHORTLY + // Update the range rects. + var range = g.selectAll('rect.nv-range') + .data(rangez); - // Transition the exiting ticks to the new scale, x1. - d3.transition(tick.exit()) - .attr('transform', function(d) { return 'translate(' + x1(d) + ',0)' }) - .style('opacity', 1e-6) - .remove(); + range.enter().append('rect') + .attr('class', function(d, i) { return 'nv-range nv-s' + i; }) + .attr('width', w0) + .attr('height', availableHeight) + .attr('x', reverse ? x0 : 0) + .on('mouseover', function(d,i) { + dispatch.elementMouseover({ + value: d, + label: (i <= 0) ? 'Maximum' : (i > 1) ? 'Minimum' : 'Mean', //TODO: make these labels a variable + pos: [x1(d), availableHeight/2] + }) + }) + .on('mouseout', function(d,i) { + dispatch.elementMouseout({ + value: d, + label: (i <= 0) ? 'Minimum' : (i >=1) ? 'Maximum' : 'Mean' //TODO: make these labels a variable + }) + }) + d3.transition(range) + .attr('x', reverse ? x1 : 0) + .attr('width', w1) + .attr('height', availableHeight); - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - dispatch.on('tooltipShow', function(e) { - e.key = d.title; - if (tooltips) showTooltip(e, that.parentNode); - }); + // Update the measure rects. + var measure = g.selectAll('rect.nv-measure') + .data(measurez); - //============================================================ + measure.enter().append('rect') + .attr('class', function(d, i) { return 'nv-measure nv-s' + i; }) + .style('fill', function(d,i) { return color(d,i ) }) + .attr('width', w0) + .attr('height', availableHeight / 3) + .attr('x', reverse ? x0 : 0) + .attr('y', availableHeight / 3) + .on('mouseover', function(d) { + dispatch.elementMouseover({ + value: d, + label: 'Current', //TODO: make these labels a variable + pos: [x1(d), availableHeight/2] + }) + }) + .on('mouseout', function(d) { + dispatch.elementMouseout({ + value: d, + label: 'Current' //TODO: make these labels a variable + }) + }) - }); + d3.transition(measure) + .attr('width', w1) + .attr('height', availableHeight / 3) + .attr('x', reverse ? x1 : 0) + .attr('y', availableHeight / 3); - d3.timer.flush(); - return chart; - } + // Update the marker lines. + var marker = g.selectAll('path.nv-markerTriangle') + .data(markerz); - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ + var h3 = availableHeight / 6; + marker.enter().append('path') + .attr('class', 'nv-markerTriangle') + .attr('transform', function(d) { return 'translate(' + x0(d) + ',' + (availableHeight / 2) + ')' }) + .attr('d', 'M0,' + h3 + 'L' + h3 + ',' + (-h3) + ' ' + (-h3) + ',' + (-h3) + 'Z') + .on('mouseover', function(d,i) { + dispatch.elementMouseover({ + value: d, + label: 'Previous', + pos: [x1(d), availableHeight/2] + }) + }) + .on('mouseout', function(d,i) { + dispatch.elementMouseout({ + value: d, + label: 'Previous' + }) + }); - bullet.dispatch.on('elementMouseover.tooltip', function(e) { - dispatch.tooltipShow(e); - }); + d3.transition(marker) + .attr('transform', function(d) { return 'translate(' + (x1(d) - x1(0)) + ',' + (availableHeight / 2) + ')' }); - bullet.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); + marker.exit().remove(); +*/ - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); + }); - //============================================================ + // d3.timer.flush(); // Not needed? + + return chart; + } //============================================================ @@ -2061,50 +2058,53 @@ nv.models.bulletChart = function() { //------------------------------------------------------------ chart.dispatch = dispatch; - chart.bullet = bullet; - - d3.rebind(chart, bullet, 'color'); chart.options = nv.utils.optionsFunc.bind(chart); // left, right, top, bottom - chart.orient = function(x) { + chart.orient = function(_) { if (!arguments.length) return orient; - orient = x; + orient = _; reverse = orient == 'right' || orient == 'bottom'; return chart; }; // ranges (bad, satisfactory, good) - chart.ranges = function(x) { + chart.ranges = function(_) { if (!arguments.length) return ranges; - ranges = x; + ranges = _; return chart; }; // markers (previous, goal) - chart.markers = function(x) { + chart.markers = function(_) { if (!arguments.length) return markers; - markers = x; + markers = _; return chart; }; // measures (actual, forecast) - chart.measures = function(x) { + chart.measures = function(_) { if (!arguments.length) return measures; - measures = x; + measures = _; return chart; }; - chart.width = function(x) { + chart.forceX = function(_) { + if (!arguments.length) return forceX; + forceX = _; + return chart; + }; + + chart.width = function(_) { if (!arguments.length) return width; - width = x; + width = _; return chart; }; - chart.height = function(x) { + chart.height = function(_) { if (!arguments.length) return height; - height = x; + height = _; return chart; }; @@ -2117,27 +2117,15 @@ nv.models.bulletChart = function() { return chart; }; - chart.tickFormat = function(x) { + chart.tickFormat = function(_) { if (!arguments.length) return tickFormat; - tickFormat = x; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; + tickFormat = _; return chart; }; - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; + chart.color = function(_) { + if (!arguments.length) return color; + color = nv.utils.getColor(_); return chart; }; @@ -2149,164 +2137,71 @@ nv.models.bulletChart = function() { -nv.models.cumulativeLineChart = function() { +// Chart design based on the recommendations of Stephen Few. Implementation +// based on the work of Clint Ivy, Jamie Love, and Jason Davies. +// http://projects.instantcognition.com/protovis/bulletchart/ +nv.models.bulletChart = function() { "use strict"; //============================================================ // Public Variables with Default Settings //------------------------------------------------------------ - var lines = nv.models.line() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , legend = nv.models.legend() - , controls = nv.models.legend() - , interactiveLayer = nv.interactiveGuideline() + var bullet = nv.models.bullet() ; - var margin = {top: 30, right: 30, bottom: 50, left: 60} - , color = nv.utils.defaultColor() + var orient = 'left' // TODO top & bottom + , reverse = false + , margin = {top: 5, right: 40, bottom: 20, left: 120} + , ranges = function(d) { return d.ranges } + , markers = function(d) { return d.markers } + , measures = function(d) { return d.measures } , width = null - , height = null - , showLegend = true - , showXAxis = true - , showYAxis = true - , rightAlignYAxis = false + , height = 55 + , tickFormat = null , tooltips = true - , showControls = true - , useInteractiveGuideline = false - , rescaleY = true , tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' + return '

' + x + '

' + + '

' + y + '

' } - , x //can be accessed via chart.xScale() - , y //can be accessed via chart.yScale() - , id = lines.id() - , state = { index: 0, rescaleY: rescaleY } - , defaultState = null , noData = 'No Data Available.' - , average = function(d) { return d.average } - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - , transitionDuration = 250 - ; - - xAxis - .orient('bottom') - .tickPadding(7) - ; - yAxis - .orient((rightAlignYAxis) ? 'right' : 'left') + , dispatch = d3.dispatch('tooltipShow', 'tooltipHide') ; //============================================================ - controls.updateState(false); + //============================================================ // Private Variables //------------------------------------------------------------ - var dx = d3.scale.linear() - , index = {i: 0, x: 0} - ; - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); + var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ) + margin.left, + top = e.pos[1] + ( offsetElement.offsetTop || 0) + margin.top, + content = tooltip(e.key, e.label, e.value, e, chart); - nv.tooltip.show([left, top], content, null, null, offsetElement); + nv.tooltip.show([left, top], content, e.value < 0 ? 'e' : 'w', null, offsetElement); }; -/* - //Moved to see if we can get better behavior to fix issue #315 - var indexDrag = d3.behavior.drag() - .on('dragstart', dragStart) - .on('drag', dragMove) - .on('dragend', dragEnd); - - function dragStart(d,i) { - d3.select(chart.container) - .style('cursor', 'ew-resize'); - } - - function dragMove(d,i) { - d.x += d3.event.dx; - d.i = Math.round(dx.invert(d.x)); - - d3.select(this).attr('transform', 'translate(' + dx(d.i) + ',0)'); - chart.update(); - } - - function dragEnd(d,i) { - d3.select(chart.container) - .style('cursor', 'auto'); - chart.update(); - } -*/ - - //============================================================ + //============================================================ function chart(selection) { - selection.each(function(data) { - var container = d3.select(this).classed('nv-chart-' + id, true), - that = this; + selection.each(function(d, i) { + 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; + availableHeight = height - margin.top - margin.bottom, + that = this; - chart.update = function() { container.transition().duration(transitionDuration).call(chart) }; + chart.update = function() { chart(selection) }; chart.container = this; - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - var indexDrag = d3.behavior.drag() - .on('dragstart', dragStart) - .on('drag', dragMove) - .on('dragend', dragEnd); - - - function dragStart(d,i) { - d3.select(chart.container) - .style('cursor', 'ew-resize'); - } - - function dragMove(d,i) { - index.x = d3.event.x; - index.i = Math.round(dx.invert(index.x)); - updateZero(); - } - - function dragEnd(d,i) { - d3.select(chart.container) - .style('cursor', 'auto'); - - // update state and send stateChange with new index - state.index = index.i; - dispatch.stateChange(state); - } - //------------------------------------------------------------ // Display No Data message if there's nothing to show. - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { + if (!d || !ranges.call(this, d, i)) { var noDataText = container.selectAll('.nv-noData').data([noData]); noDataText.enter().append('text') @@ -2316,7 +2211,7 @@ nv.models.cumulativeLineChart = function() { noDataText .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) + .attr('y', 18 + margin.top + availableHeight / 2) .text(function(d) { return d }); return chart; @@ -2327,414 +2222,148 @@ nv.models.cumulativeLineChart = function() { //------------------------------------------------------------ + + var rangez = ranges.call(this, d, i).slice().sort(d3.descending), + markerz = markers.call(this, d, i).slice().sort(d3.descending), + measurez = measures.call(this, d, i).slice().sort(d3.descending); + + //------------------------------------------------------------ - // Setup Scales + // Setup containers and skeleton of chart - x = lines.xScale(); - y = lines.yScale(); + var wrap = container.selectAll('g.nv-wrap.nv-bulletChart').data([d]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-bulletChart'); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g'); + gEnter.append('g').attr('class', 'nv-bulletWrap'); + gEnter.append('g').attr('class', 'nv-titles'); - if (!rescaleY) { - var seriesDomains = data - .filter(function(series) { return !series.disabled }) - .map(function(series,i) { - var initialDomain = d3.extent(series.values, lines.y()); + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - //account for series being disabled when losing 95% or more - if (initialDomain[0] < -.95) initialDomain[0] = -.95; + //------------------------------------------------------------ - return [ - (initialDomain[0] - initialDomain[1]) / (1 + initialDomain[1]), - (initialDomain[1] - initialDomain[0]) / (1 + initialDomain[0]) - ]; - }); - var completeDomain = [ - d3.min(seriesDomains, function(d) { return d[0] }), - d3.max(seriesDomains, function(d) { return d[1] }) - ] + // Compute the new x-scale. + var x1 = d3.scale.linear() + .domain([0, Math.max(rangez[0], markerz[0], measurez[0])]) // TODO: need to allow forceX and forceY, and xDomain, yDomain + .range(reverse ? [availableWidth, 0] : [0, availableWidth]); - lines.yDomain(completeDomain); - } else { - lines.yDomain(null); - } + // Retrieve the old x-scale, if this is an update. + var x0 = this.__chart__ || d3.scale.linear() + .domain([0, Infinity]) + .range(x1.range()); + // Stash the new scale. + this.__chart__ = x1; - dx .domain([0, data[0].values.length - 1]) //Assumes all series have same length - .range([0, availableWidth]) - .clamp(true); + /* + // Derive width-scales from the x-scales. + var w0 = bulletWidth(x0), + w1 = bulletWidth(x1); - //------------------------------------------------------------ + function bulletWidth(x) { + var x0 = x(0); + return function(d) { + return Math.abs(x(d) - x(0)); + }; + } + function bulletTranslate(x) { + return function(d) { + return 'translate(' + x(d) + ',0)'; + }; + } + */ - var data = indexify(index.i, data); + var w0 = function(d) { return Math.abs(x0(d) - x0(0)) }, // TODO: could optimize by precalculating x0(0) and x1(0) + w1 = function(d) { return Math.abs(x1(d) - x1(0)) }; - //------------------------------------------------------------ - // Setup containers and skeleton of chart - var interactivePointerEvents = (useInteractiveGuideline) ? "none" : "all"; - var wrap = container.selectAll('g.nv-wrap.nv-cumulativeLine').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-cumulativeLine').append('g'); - var g = wrap.select('g'); + var title = gEnter.select('.nv-titles').append('g') + .attr('text-anchor', 'end') + .attr('transform', 'translate(-6,' + (height - margin.top - margin.bottom) / 2 + ')'); + title.append('text') + .attr('class', 'nv-title') + .text(function(d) { return d.title; }); - gEnter.append('g').attr('class', 'nv-interactive'); - gEnter.append('g').attr('class', 'nv-x nv-axis').style("pointer-events","none"); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-background'); - gEnter.append('g').attr('class', 'nv-linesWrap').style("pointer-events",interactivePointerEvents); - gEnter.append('g').attr('class', 'nv-avgLinesWrap').style("pointer-events","none"); - gEnter.append('g').attr('class', 'nv-legendWrap'); - gEnter.append('g').attr('class', 'nv-controlsWrap'); - + title.append('text') + .attr('class', 'nv-subtitle') + .attr('dy', '1em') + .text(function(d) { return d.subtitle; }); - //------------------------------------------------------------ - // Legend - if (showLegend) { - legend.width(availableWidth); - g.select('.nv-legendWrap') - .datum(data) - .call(legend); + bullet + .width(availableWidth) + .height(availableHeight) - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } + var bulletWrap = g.select('.nv-bulletWrap'); - g.select('.nv-legendWrap') - .attr('transform', 'translate(0,' + (-margin.top) +')') - } + d3.transition(bulletWrap).call(bullet); - //------------------------------------------------------------ - //------------------------------------------------------------ - // Controls + // Compute the tick format. + var format = tickFormat || x1.tickFormat( availableWidth / 100 ); - if (showControls) { - var controlsData = [ - { key: 'Re-scale y-axis', disabled: !rescaleY } - ]; + // Update the tick groups. + var tick = g.selectAll('g.nv-tick') + .data(x1.ticks( availableWidth / 50 ), function(d) { + return this.textContent || format(d); + }); - controls.width(140).color(['#444', '#444', '#444']); - g.select('.nv-controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); - } + // Initialize the ticks with the old scale, x0. + var tickEnter = tick.enter().append('g') + .attr('class', 'nv-tick') + .attr('transform', function(d) { return 'translate(' + x0(d) + ',0)' }) + .style('opacity', 1e-6); - //------------------------------------------------------------ + tickEnter.append('line') + .attr('y1', availableHeight) + .attr('y2', availableHeight * 7 / 6); + tickEnter.append('text') + .attr('text-anchor', 'middle') + .attr('dy', '1em') + .attr('y', availableHeight * 7 / 6) + .text(format); - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - if (rightAlignYAxis) { - g.select(".nv-y.nv-axis") - .attr("transform", "translate(" + availableWidth + ",0)"); - } + // Transition the updating ticks to the new scale, x1. + var tickUpdate = d3.transition(tick) + .attr('transform', function(d) { return 'translate(' + x1(d) + ',0)' }) + .style('opacity', 1); - // Show error if series goes below 100% - var tempDisabled = data.filter(function(d) { return d.tempDisabled }); + tickUpdate.select('line') + .attr('y1', availableHeight) + .attr('y2', availableHeight * 7 / 6); + + tickUpdate.select('text') + .attr('y', availableHeight * 7 / 6); + + // Transition the exiting ticks to the new scale, x1. + d3.transition(tick.exit()) + .attr('transform', function(d) { return 'translate(' + x1(d) + ',0)' }) + .style('opacity', 1e-6) + .remove(); - wrap.select('.tempDisabled').remove(); //clean-up and prevent duplicates - if (tempDisabled.length) { - wrap.append('text').attr('class', 'tempDisabled') - .attr('x', availableWidth / 2) - .attr('y', '-.71em') - .style('text-anchor', 'end') - .text(tempDisabled.map(function(d) { return d.key }).join(', ') + ' values cannot be calculated for this time period.'); - } + //============================================================ + // Event Handling/Dispatching (in chart's scope) //------------------------------------------------------------ - // Main Chart Component(s) - - //------------------------------------------------------------ - //Set up interactive layer - if (useInteractiveGuideline) { - interactiveLayer - .width(availableWidth) - .height(availableHeight) - .margin({left:margin.left,top:margin.top}) - .svgContainer(container) - .xScale(x); - wrap.select(".nv-interactive").call(interactiveLayer); - } - - gEnter.select('.nv-background') - .append('rect'); - - g.select('.nv-background rect') - .attr('width', availableWidth) - .attr('height', availableHeight); - - lines - //.x(function(d) { return d.x }) - .y(function(d) { return d.display.y }) - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled && !data[i].tempDisabled; })); - - - - var linesWrap = g.select('.nv-linesWrap') - .datum(data.filter(function(d) { return !d.disabled && !d.tempDisabled })); - - //d3.transition(linesWrap).call(lines); - linesWrap.call(lines); - - /*Handle average lines [AN-612] ----------------------------*/ - - //Store a series index number in the data array. - data.forEach(function(d,i) { - d.seriesIndex = i; - }); - - var avgLineData = data.filter(function(d) { - return !d.disabled && !!average(d); - }); - - var avgLines = g.select(".nv-avgLinesWrap").selectAll("line") - .data(avgLineData, function(d) { return d.key; }); - - var getAvgLineY = function(d) { - //If average lines go off the svg element, clamp them to the svg bounds. - var yVal = y(average(d)); - if (yVal < 0) return 0; - if (yVal > availableHeight) return availableHeight; - return yVal; - }; - - avgLines.enter() - .append('line') - .style('stroke-width',2) - .style('stroke-dasharray','10,10') - .style('stroke',function (d,i) { - return lines.color()(d,d.seriesIndex); - }) - .attr('x1',0) - .attr('x2',availableWidth) - .attr('y1', getAvgLineY) - .attr('y2', getAvgLineY); - - avgLines - .style('stroke-opacity',function(d){ - //If average lines go offscreen, make them transparent - var yVal = y(average(d)); - if (yVal < 0 || yVal > availableHeight) return 0; - return 1; - }) - .attr('x1',0) - .attr('x2',availableWidth) - .attr('y1', getAvgLineY) - .attr('y2', getAvgLineY); - - avgLines.exit().remove(); - - //Create index line ----------------------------------------- - - var indexLine = linesWrap.selectAll('.nv-indexLine') - .data([index]); - indexLine.enter().append('rect').attr('class', 'nv-indexLine') - .attr('width', 3) - .attr('x', -2) - .attr('fill', 'red') - .attr('fill-opacity', .5) - .style("pointer-events","all") - .call(indexDrag) - - indexLine - .attr('transform', function(d) { return 'translate(' + dx(d.i) + ',0)' }) - .attr('height', availableHeight) - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - - if (showXAxis) { - xAxis - .scale(x) - //Suggest how many ticks based on the chart width and D3 should listen (70 is the optimal number for MM/DD/YY dates) - .ticks( Math.min(data[0].values.length,availableWidth/70) ) - .tickSize(-availableHeight, 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - d3.transition(g.select('.nv-x.nv-axis')) - .call(xAxis); - } - - - if (showYAxis) { - yAxis - .scale(y) - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - d3.transition(g.select('.nv-y.nv-axis')) - .call(yAxis); - } - //------------------------------------------------------------ - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - - function updateZero() { - indexLine - .data([index]); - - //When dragging the index line, turn off line transitions. - // Then turn them back on when done dragging. - var oldDuration = chart.transitionDuration(); - chart.transitionDuration(0); - chart.update(); - chart.transitionDuration(oldDuration); - } - - g.select('.nv-background rect') - .on('click', function() { - index.x = d3.mouse(this)[0]; - index.i = Math.round(dx.invert(index.x)); - - // update state and send stateChange with new index - state.index = index.i; - dispatch.stateChange(state); - - updateZero(); - }); - - lines.dispatch.on('elementClick', function(e) { - index.i = e.pointIndex; - index.x = dx(index.i); - - // update state and send stateChange with new index - state.index = index.i; - dispatch.stateChange(state); - - updateZero(); - }); - - controls.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - rescaleY = !d.disabled; - - state.rescaleY = rescaleY; - dispatch.stateChange(state); - chart.update(); - }); - - - legend.dispatch.on('stateChange', function(newState) { - state.disabled = newState.disabled; - dispatch.stateChange(state); - chart.update(); - }); - - interactiveLayer.dispatch.on('elementMousemove', function(e) { - lines.clearHighlights(); - var singlePoint, pointIndex, pointXLocation, allData = []; - - - data - .filter(function(series, i) { - series.seriesIndex = i; - return !series.disabled; - }) - .forEach(function(series,i) { - pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x()); - lines.highlightPoint(i, pointIndex, true); - var point = series.values[pointIndex]; - if (typeof point === 'undefined') return; - if (typeof singlePoint === 'undefined') singlePoint = point; - if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex)); - allData.push({ - key: series.key, - value: chart.y()(point, pointIndex), - color: color(series,series.seriesIndex) - }); - }); - - //Highlight the tooltip entry based on which point the mouse is closest to. - if (allData.length > 2) { - var yValue = chart.yScale().invert(e.mouseY); - var domainExtent = Math.abs(chart.yScale().domain()[0] - chart.yScale().domain()[1]); - var threshold = 0.03 * domainExtent; - var indexToHighlight = nv.nearestValueIndex(allData.map(function(d){return d.value}),yValue,threshold); - if (indexToHighlight !== null) - allData[indexToHighlight].highlight = true; - } - - var xValue = xAxis.tickFormat()(chart.x()(singlePoint,pointIndex), pointIndex); - interactiveLayer.tooltip - .position({left: pointXLocation + margin.left, top: e.mouseY + margin.top}) - .chartContainer(that.parentNode) - .enabled(tooltips) - .valueFormatter(function(d,i) { - return yAxis.tickFormat()(d); - }) - .data( - { - value: xValue, - series: allData - } - )(); - - interactiveLayer.renderGuideLine(pointXLocation); - - }); - - interactiveLayer.dispatch.on("elementMouseout",function(e) { - dispatch.tooltipHide(); - lines.clearHighlights(); - }); dispatch.on('tooltipShow', function(e) { + e.key = d.title; if (tooltips) showTooltip(e, that.parentNode); }); - - // Update chart from a state object passed to event handler - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined') { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - - if (typeof e.index !== 'undefined') { - index.i = e.index; - index.x = dx(index.i); - - state.index = e.index; - - indexLine - .data([index]); - } - - - if (typeof e.rescaleY !== 'undefined') { - rescaleY = e.rescaleY; - } - - chart.update(); - }); - //============================================================ }); + d3.timer.flush(); + return chart; } @@ -2743,12 +2372,11 @@ nv.models.cumulativeLineChart = function() { // Event Handling/Dispatching (out of chart's scope) //------------------------------------------------------------ - lines.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + bullet.dispatch.on('elementMouseover.tooltip', function(e) { dispatch.tooltipShow(e); }); - lines.dispatch.on('elementMouseout.tooltip', function(e) { + bullet.dispatch.on('elementMouseout.tooltip', function(e) { dispatch.tooltipHide(e); }); @@ -2763,90 +2391,66 @@ nv.models.cumulativeLineChart = function() { // Expose Public Variables //------------------------------------------------------------ - // expose chart's sub-components chart.dispatch = dispatch; - chart.lines = lines; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - chart.interactiveLayer = interactiveLayer; + chart.bullet = bullet; - d3.rebind(chart, lines, 'defined', 'isArea', 'x', 'y', 'xScale','yScale', 'size', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi','useVoronoi', 'id'); + d3.rebind(chart, bullet, 'color'); chart.options = nv.utils.optionsFunc.bind(chart); - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - 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 = nv.utils.getColor(_); - legend.color(color); + // left, right, top, bottom + chart.orient = function(x) { + if (!arguments.length) return orient; + orient = x; + reverse = orient == 'right' || orient == 'bottom'; return chart; }; - chart.rescaleY = function(_) { - if (!arguments.length) return rescaleY; - rescaleY = _; + // ranges (bad, satisfactory, good) + chart.ranges = function(x) { + if (!arguments.length) return ranges; + ranges = x; return chart; }; - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; + // markers (previous, goal) + chart.markers = function(x) { + if (!arguments.length) return markers; + markers = x; return chart; }; - chart.useInteractiveGuideline = function(_) { - if(!arguments.length) return useInteractiveGuideline; - useInteractiveGuideline = _; - if (_ === true) { - chart.interactive(false); - chart.useVoronoi(false); - } + // measures (actual, forecast) + chart.measures = function(x) { + if (!arguments.length) return measures; + measures = x; return chart; }; - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; + chart.width = function(x) { + if (!arguments.length) return width; + width = x; return chart; }; - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; + chart.height = function(x) { + if (!arguments.length) return height; + height = x; return chart; }; - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; + chart.margin = function(_) { + if (!arguments.length) return margin; + margin.top = typeof _.top != 'undefined' ? _.top : margin.top; + margin.right = typeof _.right != 'undefined' ? _.right : margin.right; + margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; + margin.left = typeof _.left != 'undefined' ? _.left : margin.left; return chart; }; - chart.rightAlignYAxis = function(_) { - if(!arguments.length) return rightAlignYAxis; - rightAlignYAxis = _; - yAxis.orient( (_) ? 'right' : 'left'); + chart.tickFormat = function(x) { + if (!arguments.length) return tickFormat; + tickFormat = x; return chart; }; @@ -2862,650 +2466,620 @@ nv.models.cumulativeLineChart = function() { return chart; }; - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - chart.noData = function(_) { if (!arguments.length) return noData; noData = _; return chart; }; - chart.average = function(_) { - if(!arguments.length) return average; - average = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - //============================================================ - //============================================================ - // Functions - //------------------------------------------------------------ - - /* Normalize the data according to an index point. */ - function indexify(idx, data) { - return data.map(function(line, i) { - if (!line.values) { - return line; - } - var v = lines.y()(line.values[idx], idx); - - //TODO: implement check below, and disable series if series loses 100% or more cause divide by 0 issue - if (v < -.95) { - //if a series loses more than 100%, calculations fail.. anything close can cause major distortion (but is mathematically correct till it hits 100) - line.tempDisabled = true; - return line; - } - - line.tempDisabled = false; - - line.values = line.values.map(function(point, pointIndex) { - point.display = {'y': (lines.y()(point, pointIndex) - v) / (1 + v) }; - return point; - }) - - return line; - }) - } + return chart; +}; - //============================================================ - return chart; -} -//TODO: consider deprecating by adding necessary features to multiBar model -nv.models.discreteBar = function() { +nv.models.cumulativeLineChart = function() { "use strict"; //============================================================ // Public Variables with Default Settings //------------------------------------------------------------ - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one - , x = d3.scale.ordinal() - , y = d3.scale.linear() - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove + var lines = nv.models.line() + , xAxis = nv.models.axis() + , yAxis = nv.models.axis() + , legend = nv.models.legend() + , controls = nv.models.legend() + , interactiveLayer = nv.interactiveGuideline() + ; + + var margin = {top: 30, right: 30, bottom: 50, left: 60} , color = nv.utils.defaultColor() - , showValues = false - , valueFormat = d3.format(',.2f') - , xDomain - , yDomain - , xRange - , yRange - , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout') - , rectClass = 'discreteBar' + , width = null + , height = null + , showLegend = true + , showXAxis = true + , showYAxis = true + , rightAlignYAxis = false + , tooltips = true + , showControls = true + , useInteractiveGuideline = false + , rescaleY = true + , tooltip = function(key, x, y, e, graph) { + return '

' + key + '

' + + '

' + y + ' at ' + x + '

' + } + , x //can be accessed via chart.xScale() + , y //can be accessed via chart.yScale() + , id = lines.id() + , state = { index: 0, rescaleY: rescaleY } + , defaultState = null + , noData = 'No Data Available.' + , average = function(d) { return d.average } + , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') + , transitionDuration = 250 ; - //============================================================ + xAxis + .orient('bottom') + .tickPadding(7) + ; + yAxis + .orient((rightAlignYAxis) ? 'right' : 'left') + ; + //============================================================ + controls.updateState(false); //============================================================ // Private Variables //------------------------------------------------------------ - var x0, y0; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - - //add series index to each data point for reference - data.forEach(function(series, i) { - series.values.forEach(function(point) { - point.series = i; - }); - }); - + var dx = d3.scale.linear() + , index = {i: 0, x: 0} + ; - //------------------------------------------------------------ - // Setup Scales + var showTooltip = function(e, offsetElement) { + var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), + top = e.pos[1] + ( offsetElement.offsetTop || 0), + x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), + y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)), + content = tooltip(e.series.key, x, y, e, chart); - // remap and flatten the data for use in calculating the scales' domains - var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate - data.map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i), y0: d.y0 } - }) - }); + nv.tooltip.show([left, top], content, null, null, offsetElement); + }; - x .domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x })) - .rangeBands(xRange || [0, availableWidth], .1); +/* + //Moved to see if we can get better behavior to fix issue #315 + var indexDrag = d3.behavior.drag() + .on('dragstart', dragStart) + .on('drag', dragMove) + .on('dragend', dragEnd); - y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return d.y }).concat(forceY))); + function dragStart(d,i) { + d3.select(chart.container) + .style('cursor', 'ew-resize'); + } + function dragMove(d,i) { + d.x += d3.event.dx; + d.i = Math.round(dx.invert(d.x)); - // If showValues, pad the Y axis range to account for label height - if (showValues) y.range(yRange || [availableHeight - (y.domain()[0] < 0 ? 12 : 0), y.domain()[1] > 0 ? 12 : 0]); - else y.range(yRange || [availableHeight, 0]); + d3.select(this).attr('transform', 'translate(' + dx(d.i) + ',0)'); + chart.update(); + } - //store old scales if they exist - x0 = x0 || x; - y0 = y0 || y.copy().range([y(0),y(0)]); + function dragEnd(d,i) { + d3.select(chart.container) + .style('cursor', 'auto'); + chart.update(); + } +*/ - //------------------------------------------------------------ + //============================================================ - //------------------------------------------------------------ - // Setup containers and skeleton of chart + function chart(selection) { + selection.each(function(data) { + var container = d3.select(this).classed('nv-chart-' + id, true), + that = this; - var wrap = container.selectAll('g.nv-wrap.nv-discretebar').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-discretebar'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right, + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; - gEnter.append('g').attr('class', 'nv-groups'); - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + chart.update = function() { container.transition().duration(transitionDuration).call(chart) }; + chart.container = this; - //------------------------------------------------------------ + //set state.disabled + state.disabled = data.map(function(d) { return !!d.disabled }); + if (!defaultState) { + var key; + defaultState = {}; + for (key in state) { + if (state[key] instanceof Array) + defaultState[key] = state[key].slice(0); + else + defaultState[key] = state[key]; + } + } + var indexDrag = d3.behavior.drag() + .on('dragstart', dragStart) + .on('drag', dragMove) + .on('dragend', dragEnd); - //TODO: by definition, the discrete bar should not have multiple groups, will modify/remove later - var groups = wrap.select('.nv-groups').selectAll('.nv-group') - .data(function(d) { return d }, function(d) { return d.key }); - groups.enter().append('g') - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6); - groups.exit() - .transition() - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6) - .remove(); - groups - .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) - .classed('hover', function(d) { return d.hover }); - groups - .transition() - .style('stroke-opacity', 1) - .style('fill-opacity', .75); + function dragStart(d,i) { + d3.select(chart.container) + .style('cursor', 'ew-resize'); + } - var bars = groups.selectAll('g.nv-bar') - .data(function(d) { return d.values }); + function dragMove(d,i) { + index.x = d3.event.x; + index.i = Math.round(dx.invert(index.x)); + updateZero(); + } - bars.exit().remove(); + function dragEnd(d,i) { + d3.select(chart.container) + .style('cursor', 'auto'); + // update state and send stateChange with new index + state.index = index.i; + dispatch.stateChange(state); + } - var barsEnter = bars.enter().append('g') - .attr('transform', function(d,i,j) { - return 'translate(' + (x(getX(d,i)) + x.rangeBand() * .05 ) + ', ' + y(0) + ')' - }) - .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here - d3.select(this).classed('hover', true); - dispatch.elementMouseover({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - }) - .on('mouseout', function(d,i) { - d3.select(this).classed('hover', false); - dispatch.elementMouseout({ - value: getY(d,i), - point: d, - series: data[d.series], - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - }) - .on('click', function(d,i) { - dispatch.elementClick({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - d3.event.stopPropagation(); - }) - .on('dblclick', function(d,i) { - dispatch.elementDblClick({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - d3.event.stopPropagation(); - }); + //------------------------------------------------------------ + // Display No Data message if there's nothing to show. - barsEnter.append('rect') - .attr('height', 0) - .attr('width', x.rangeBand() * .9 / data.length ) + if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { + var noDataText = container.selectAll('.nv-noData').data([noData]); - if (showValues) { - barsEnter.append('text') - .attr('text-anchor', 'middle') - ; + noDataText.enter().append('text') + .attr('class', 'nvd3 nv-noData') + .attr('dy', '-.7em') + .style('text-anchor', 'middle'); - bars.select('text') - .text(function(d,i) { return valueFormat(getY(d,i)) }) - .transition() - .attr('x', x.rangeBand() * .9 / 2) - .attr('y', function(d,i) { return getY(d,i) < 0 ? y(getY(d,i)) - y(0) + 12 : -4 }) + noDataText + .attr('x', margin.left + availableWidth / 2) + .attr('y', margin.top + availableHeight / 2) + .text(function(d) { return d }); - ; + return chart; } else { - bars.selectAll('text').remove(); + container.selectAll('.nv-noData').remove(); } - bars - .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive' }) - .style('fill', function(d,i) { return d.color || color(d,i) }) - .style('stroke', function(d,i) { return d.color || color(d,i) }) - .select('rect') - .attr('class', rectClass) - .transition() - .attr('width', x.rangeBand() * .9 / data.length); - bars.transition() - //.delay(function(d,i) { return i * 1200 / data[0].values.length }) - .attr('transform', function(d,i) { - var left = x(getX(d,i)) + x.rangeBand() * .05, - top = getY(d,i) < 0 ? - y(0) : - y(0) - y(getY(d,i)) < 1 ? - y(0) - 1 : //make 1 px positive bars show up above y=0 - y(getY(d,i)); + //------------------------------------------------------------ + - return 'translate(' + left + ', ' + top + ')' - }) - .select('rect') - .attr('height', function(d,i) { - return Math.max(Math.abs(y(getY(d,i)) - y((yDomain && yDomain[0]) || 0)) || 1) - }); + //------------------------------------------------------------ + // Setup Scales + x = lines.xScale(); + y = lines.yScale(); - //store old scales for use in transitions on update - x0 = x.copy(); - y0 = y.copy(); - }); + if (!rescaleY) { + var seriesDomains = data + .filter(function(series) { return !series.disabled }) + .map(function(series,i) { + var initialDomain = d3.extent(series.values, lines.y()); - return chart; - } + //account for series being disabled when losing 95% or more + if (initialDomain[0] < -.95) initialDomain[0] = -.95; + return [ + (initialDomain[0] - initialDomain[1]) / (1 + initialDomain[1]), + (initialDomain[1] - initialDomain[0]) / (1 + initialDomain[0]) + ]; + }); - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ + var completeDomain = [ + d3.min(seriesDomains, function(d) { return d[0] }), + d3.max(seriesDomains, function(d) { return d[1] }) + ] - chart.dispatch = dispatch; + lines.yDomain(completeDomain); + } else { + lines.yDomain(null); + } - chart.options = nv.utils.optionsFunc.bind(chart); - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - return chart; - }; + dx .domain([0, data[0].values.length - 1]) //Assumes all series have same length + .range([0, availableWidth]) + .clamp(true); - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - return chart; - }; + //------------------------------------------------------------ - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; + var data = indexify(index.i, data); - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - chart.xScale = function(_) { - if (!arguments.length) return x; - x = _; - return chart; - }; + //------------------------------------------------------------ + // Setup containers and skeleton of chart + var interactivePointerEvents = (useInteractiveGuideline) ? "none" : "all"; + var wrap = container.selectAll('g.nv-wrap.nv-cumulativeLine').data([data]); + var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-cumulativeLine').append('g'); + var g = wrap.select('g'); - chart.yScale = function(_) { - if (!arguments.length) return y; - y = _; - return chart; - }; + gEnter.append('g').attr('class', 'nv-interactive'); + gEnter.append('g').attr('class', 'nv-x nv-axis').style("pointer-events","none"); + gEnter.append('g').attr('class', 'nv-y nv-axis'); + gEnter.append('g').attr('class', 'nv-background'); + gEnter.append('g').attr('class', 'nv-linesWrap').style("pointer-events",interactivePointerEvents); + gEnter.append('g').attr('class', 'nv-avgLinesWrap').style("pointer-events","none"); + gEnter.append('g').attr('class', 'nv-legendWrap'); + gEnter.append('g').attr('class', 'nv-controlsWrap'); + - chart.xDomain = function(_) { - if (!arguments.length) return xDomain; - xDomain = _; - return chart; - }; + //------------------------------------------------------------ + // Legend - chart.yDomain = function(_) { - if (!arguments.length) return yDomain; - yDomain = _; - return chart; - }; + if (showLegend) { + legend.width(availableWidth); - chart.xRange = function(_) { - if (!arguments.length) return xRange; - xRange = _; - return chart; - }; + g.select('.nv-legendWrap') + .datum(data) + .call(legend); - chart.yRange = function(_) { - if (!arguments.length) return yRange; - yRange = _; - return chart; - }; + if ( margin.top != legend.height()) { + margin.top = legend.height(); + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + } - chart.forceY = function(_) { - if (!arguments.length) return forceY; - forceY = _; - return chart; - }; + g.select('.nv-legendWrap') + .attr('transform', 'translate(0,' + (-margin.top) +')') + } - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; + //------------------------------------------------------------ - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - chart.showValues = function(_) { - if (!arguments.length) return showValues; - showValues = _; - return chart; - }; + //------------------------------------------------------------ + // Controls - chart.valueFormat= function(_) { - if (!arguments.length) return valueFormat; - valueFormat = _; - return chart; - }; + if (showControls) { + var controlsData = [ + { key: 'Re-scale y-axis', disabled: !rescaleY } + ]; - chart.rectClass= function(_) { - if (!arguments.length) return rectClass; - rectClass = _; - return chart; - }; - //============================================================ + controls.width(140).color(['#444', '#444', '#444']); + g.select('.nv-controlsWrap') + .datum(controlsData) + .attr('transform', 'translate(0,' + (-margin.top) +')') + .call(controls); + } + //------------------------------------------------------------ - return chart; -} -nv.models.discreteBarChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - var discretebar = nv.models.discreteBar() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - ; + if (rightAlignYAxis) { + g.select(".nv-y.nv-axis") + .attr("transform", "translate(" + availableWidth + ",0)"); + } - var margin = {top: 15, right: 10, bottom: 50, left: 60} - , width = null - , height = null - , color = nv.utils.getColor() - , showXAxis = true - , showYAxis = true - , rightAlignYAxis = false - , staggerLabels = false - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + x + '

' + - '

' + y + '

' + // Show error if series goes below 100% + var tempDisabled = data.filter(function(d) { return d.tempDisabled }); + + wrap.select('.tempDisabled').remove(); //clean-up and prevent duplicates + if (tempDisabled.length) { + wrap.append('text').attr('class', 'tempDisabled') + .attr('x', availableWidth / 2) + .attr('y', '-.71em') + .style('text-anchor', 'end') + .text(tempDisabled.map(function(d) { return d.key }).join(', ') + ' values cannot be calculated for this time period.'); } - , x - , y - , noData = "No Data Available." - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'beforeUpdate') - , transitionDuration = 250 - ; - xAxis - .orient('bottom') - .highlightZero(false) - .showMaxMin(false) - .tickFormat(function(d) { return d }) - ; - yAxis - .orient((rightAlignYAxis) ? 'right' : 'left') - .tickFormat(d3.format(',.1f')) - ; + //------------------------------------------------------------ + // Main Chart Component(s) + + //------------------------------------------------------------ + //Set up interactive layer + if (useInteractiveGuideline) { + interactiveLayer + .width(availableWidth) + .height(availableHeight) + .margin({left:margin.left,top:margin.top}) + .svgContainer(container) + .xScale(x); + wrap.select(".nv-interactive").call(interactiveLayer); + } - //============================================================ + gEnter.select('.nv-background') + .append('rect'); + + g.select('.nv-background rect') + .attr('width', availableWidth) + .attr('height', availableHeight); + lines + //.x(function(d) { return d.x }) + .y(function(d) { return d.display.y }) + .width(availableWidth) + .height(availableHeight) + .color(data.map(function(d,i) { + return d.color || color(d, i); + }).filter(function(d,i) { return !data[i].disabled && !data[i].tempDisabled; })); - //============================================================ - // Private Variables - //------------------------------------------------------------ - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(discretebar.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(discretebar.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); - }; + var linesWrap = g.select('.nv-linesWrap') + .datum(data.filter(function(d) { return !d.disabled && !d.tempDisabled })); - //============================================================ + //d3.transition(linesWrap).call(lines); + linesWrap.call(lines); + /*Handle average lines [AN-612] ----------------------------*/ - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; + //Store a series index number in the data array. + data.forEach(function(d,i) { + d.seriesIndex = i; + }); - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; + var avgLineData = data.filter(function(d) { + return !d.disabled && !!average(d); + }); + var avgLines = g.select(".nv-avgLinesWrap").selectAll("line") + .data(avgLineData, function(d) { return d.key; }); - chart.update = function() { - dispatch.beforeUpdate(); - container.transition().duration(transitionDuration).call(chart); + var getAvgLineY = function(d) { + //If average lines go off the svg element, clamp them to the svg bounds. + var yVal = y(average(d)); + if (yVal < 0) return 0; + if (yVal > availableHeight) return availableHeight; + return yVal; }; - chart.container = this; + avgLines.enter() + .append('line') + .style('stroke-width',2) + .style('stroke-dasharray','10,10') + .style('stroke',function (d,i) { + return lines.color()(d,d.seriesIndex); + }) + .attr('x1',0) + .attr('x2',availableWidth) + .attr('y1', getAvgLineY) + .attr('y2', getAvgLineY); - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. + avgLines + .style('stroke-opacity',function(d){ + //If average lines go offscreen, make them transparent + var yVal = y(average(d)); + if (yVal < 0 || yVal > availableHeight) return 0; + return 1; + }) + .attr('x1',0) + .attr('x2',availableWidth) + .attr('y1', getAvgLineY) + .attr('y2', getAvgLineY); - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); + avgLines.exit().remove(); - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); + //Create index line ----------------------------------------- - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); + var indexLine = linesWrap.selectAll('.nv-indexLine') + .data([index]); + indexLine.enter().append('rect').attr('class', 'nv-indexLine') + .attr('width', 3) + .attr('x', -2) + .attr('fill', 'red') + .attr('fill-opacity', .5) + .style("pointer-events","all") + .call(indexDrag) - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } + indexLine + .attr('transform', function(d) { return 'translate(' + dx(d.i) + ',0)' }) + .attr('height', availableHeight) //------------------------------------------------------------ //------------------------------------------------------------ - // Setup Scales + // Setup Axes - x = discretebar.xScale(); - y = discretebar.yScale().clamp(true); + if (showXAxis) { + xAxis + .scale(x) + //Suggest how many ticks based on the chart width and D3 should listen (70 is the optimal number for MM/DD/YY dates) + .ticks( Math.min(data[0].values.length,availableWidth/70) ) + .tickSize(-availableHeight, 0); - //------------------------------------------------------------ + g.select('.nv-x.nv-axis') + .attr('transform', 'translate(0,' + y.range()[0] + ')'); + d3.transition(g.select('.nv-x.nv-axis')) + .call(xAxis); + } + if (showYAxis) { + yAxis + .scale(y) + .ticks( availableHeight / 36 ) + .tickSize( -availableWidth, 0); + + d3.transition(g.select('.nv-y.nv-axis')) + .call(yAxis); + } //------------------------------------------------------------ - // Setup containers and skeleton of chart - var wrap = container.selectAll('g.nv-wrap.nv-discreteBarWithAxes').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-discreteBarWithAxes').append('g'); - var defsEnter = gEnter.append('defs'); - var g = wrap.select('g'); - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-barsWrap'); + //============================================================ + // Event Handling/Dispatching (in chart's scope) + //------------------------------------------------------------ - g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - if (rightAlignYAxis) { - g.select(".nv-y.nv-axis") - .attr("transform", "translate(" + availableWidth + ",0)"); + function updateZero() { + indexLine + .data([index]); + + //When dragging the index line, turn off line transitions. + // Then turn them back on when done dragging. + var oldDuration = chart.transitionDuration(); + chart.transitionDuration(0); + chart.update(); + chart.transitionDuration(oldDuration); } - //------------------------------------------------------------ + g.select('.nv-background rect') + .on('click', function() { + index.x = d3.mouse(this)[0]; + index.i = Math.round(dx.invert(index.x)); + // update state and send stateChange with new index + state.index = index.i; + dispatch.stateChange(state); - //------------------------------------------------------------ - // Main Chart Component(s) + updateZero(); + }); - discretebar - .width(availableWidth) - .height(availableHeight); + lines.dispatch.on('elementClick', function(e) { + index.i = e.pointIndex; + index.x = dx(index.i); + // update state and send stateChange with new index + state.index = index.i; + dispatch.stateChange(state); - var barsWrap = g.select('.nv-barsWrap') - .datum(data.filter(function(d) { return !d.disabled })) + updateZero(); + }); - barsWrap.transition().call(discretebar); + controls.dispatch.on('legendClick', function(d,i) { + d.disabled = !d.disabled; + rescaleY = !d.disabled; - //------------------------------------------------------------ + state.rescaleY = rescaleY; + dispatch.stateChange(state); + chart.update(); + }); + legend.dispatch.on('stateChange', function(newState) { + state.disabled = newState.disabled; + dispatch.stateChange(state); + chart.update(); + }); - defsEnter.append('clipPath') - .attr('id', 'nv-x-label-clip-' + discretebar.id()) - .append('rect'); + interactiveLayer.dispatch.on('elementMousemove', function(e) { + lines.clearHighlights(); + var singlePoint, pointIndex, pointXLocation, allData = []; + + + data + .filter(function(series, i) { + series.seriesIndex = i; + return !series.disabled; + }) + .forEach(function(series,i) { + pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x()); + lines.highlightPoint(i, pointIndex, true); + var point = series.values[pointIndex]; + if (typeof point === 'undefined') return; + if (typeof singlePoint === 'undefined') singlePoint = point; + if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex)); + allData.push({ + key: series.key, + value: chart.y()(point, pointIndex), + color: color(series,series.seriesIndex) + }); + }); - g.select('#nv-x-label-clip-' + discretebar.id() + ' rect') - .attr('width', x.rangeBand() * (staggerLabels ? 2 : 1)) - .attr('height', 16) - .attr('x', -x.rangeBand() / (staggerLabels ? 1 : 2 )); + //Highlight the tooltip entry based on which point the mouse is closest to. + if (allData.length > 2) { + var yValue = chart.yScale().invert(e.mouseY); + var domainExtent = Math.abs(chart.yScale().domain()[0] - chart.yScale().domain()[1]); + var threshold = 0.03 * domainExtent; + var indexToHighlight = nv.nearestValueIndex(allData.map(function(d){return d.value}),yValue,threshold); + if (indexToHighlight !== null) + allData[indexToHighlight].highlight = true; + } + + var xValue = xAxis.tickFormat()(chart.x()(singlePoint,pointIndex), pointIndex); + interactiveLayer.tooltip + .position({left: pointXLocation + margin.left, top: e.mouseY + margin.top}) + .chartContainer(that.parentNode) + .enabled(tooltips) + .valueFormatter(function(d,i) { + return yAxis.tickFormat()(d); + }) + .data( + { + value: xValue, + series: allData + } + )(); + interactiveLayer.renderGuideLine(pointXLocation); - //------------------------------------------------------------ - // Setup Axes + }); + + interactiveLayer.dispatch.on("elementMouseout",function(e) { + dispatch.tooltipHide(); + lines.clearHighlights(); + }); + + dispatch.on('tooltipShow', function(e) { + if (tooltips) showTooltip(e, that.parentNode); + }); - if (showXAxis) { - xAxis - .scale(x) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight, 0); - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + (y.range()[0] + ((discretebar.showValues() && y.domain()[0] < 0) ? 16 : 0)) + ')'); - //d3.transition(g.select('.nv-x.nv-axis')) - g.select('.nv-x.nv-axis').transition() - .call(xAxis); + // Update chart from a state object passed to event handler + dispatch.on('changeState', function(e) { + if (typeof e.disabled !== 'undefined') { + data.forEach(function(series,i) { + series.disabled = e.disabled[i]; + }); - var xTicks = g.select('.nv-x.nv-axis').selectAll('g'); + state.disabled = e.disabled; + } - if (staggerLabels) { - xTicks - .selectAll('text') - .attr('transform', function(d,i,j) { return 'translate(0,' + (j % 2 == 0 ? '5' : '17') + ')' }) - } - } - if (showYAxis) { - yAxis - .scale(y) - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); + if (typeof e.index !== 'undefined') { + index.i = e.index; + index.x = dx(index.i); - g.select('.nv-y.nv-axis').transition() - .call(yAxis); - } + state.index = e.index; - //------------------------------------------------------------ + indexLine + .data([index]); + } - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ + if (typeof e.rescaleY !== 'undefined') { + rescaleY = e.rescaleY; + } - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); + chart.update(); }); //============================================================ - }); return chart; } + //============================================================ // Event Handling/Dispatching (out of chart's scope) //------------------------------------------------------------ - discretebar.dispatch.on('elementMouseover.tooltip', function(e) { + lines.dispatch.on('elementMouseover.tooltip', function(e) { e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; dispatch.tooltipShow(e); }); - discretebar.dispatch.on('elementMouseout.tooltip', function(e) { + lines.dispatch.on('elementMouseout.tooltip', function(e) { dispatch.tooltipHide(e); }); @@ -3522,11 +3096,13 @@ nv.models.discreteBarChart = function() { // expose chart's sub-components chart.dispatch = dispatch; - chart.discretebar = discretebar; + chart.lines = lines; + chart.legend = legend; chart.xAxis = xAxis; chart.yAxis = yAxis; + chart.interactiveLayer = interactiveLayer; - d3.rebind(chart, discretebar, 'x', 'y', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'id', 'showValues', 'valueFormat'); + d3.rebind(chart, lines, 'defined', 'isArea', 'x', 'y', 'xScale','yScale', 'size', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi','useVoronoi', 'id'); chart.options = nv.utils.optionsFunc.bind(chart); @@ -3554,7 +3130,35 @@ nv.models.discreteBarChart = function() { chart.color = function(_) { if (!arguments.length) return color; color = nv.utils.getColor(_); - discretebar.color(color); + legend.color(color); + return chart; + }; + + chart.rescaleY = function(_) { + if (!arguments.length) return rescaleY; + rescaleY = _; + return chart; + }; + + chart.showControls = function(_) { + if (!arguments.length) return showControls; + showControls = _; + return chart; + }; + + chart.useInteractiveGuideline = function(_) { + if(!arguments.length) return useInteractiveGuideline; + useInteractiveGuideline = _; + if (_ === true) { + chart.interactive(false); + chart.useVoronoi(false); + } + return chart; + }; + + chart.showLegend = function(_) { + if (!arguments.length) return showLegend; + showLegend = _; return chart; }; @@ -3577,12 +3181,6 @@ nv.models.discreteBarChart = function() { return chart; }; - chart.staggerLabels = function(_) { - if (!arguments.length) return staggerLabels; - staggerLabels = _; - return chart; - }; - chart.tooltips = function(_) { if (!arguments.length) return tooltips; tooltips = _; @@ -3595,12 +3193,30 @@ nv.models.discreteBarChart = function() { return chart; }; + chart.state = function(_) { + if (!arguments.length) return state; + state = _; + return chart; + }; + + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; return chart; }; + chart.average = function(_) { + if(!arguments.length) return average; + average = _; + return chart; + }; + chart.transitionDuration = function(_) { if (!arguments.length) return transitionDuration; transitionDuration = _; @@ -3610,23 +3226,66 @@ nv.models.discreteBarChart = function() { //============================================================ + //============================================================ + // Functions + //------------------------------------------------------------ + + /* Normalize the data according to an index point. */ + function indexify(idx, data) { + return data.map(function(line, i) { + if (!line.values) { + return line; + } + var v = lines.y()(line.values[idx], idx); + + //TODO: implement check below, and disable series if series loses 100% or more cause divide by 0 issue + if (v < -.95) { + //if a series loses more than 100%, calculations fail.. anything close can cause major distortion (but is mathematically correct till it hits 100) + line.tempDisabled = true; + return line; + } + + line.tempDisabled = false; + + line.values = line.values.map(function(point, pointIndex) { + point.display = {'y': (lines.y()(point, pointIndex) - v) / (1 + v) }; + return point; + }) + + return line; + }) + } + + //============================================================ + + return chart; } - -nv.models.distribution = function() { +//TODO: consider deprecating by adding necessary features to multiBar model +nv.models.discreteBar = function() { "use strict"; //============================================================ // Public Variables with Default Settings //------------------------------------------------------------ var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 400 //technically width or height depending on x or y.... - , size = 8 - , axis = 'x' // 'x' or 'y'... horizontal or vertical - , getData = function(d) { return d[axis] } // defaults d.x or d.y + , width = 960 + , height = 500 + , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one + , x = d3.scale.ordinal() + , y = d3.scale.linear() + , getX = function(d) { return d.x } + , getY = function(d) { return d.y } + , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove , color = nv.utils.defaultColor() - , scale = d3.scale.linear() - , domain + , showValues = false + , valueFormat = d3.format(',.2f') + , xDomain + , yDomain + , xRange + , yRange + , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout') + , rectClass = 'discreteBar' ; //============================================================ @@ -3636,22 +3295,50 @@ nv.models.distribution = function() { // Private Variables //------------------------------------------------------------ - var scale0; + var x0, y0; //============================================================ function chart(selection) { selection.each(function(data) { - var availableLength = width - (axis === 'x' ? margin.left + margin.right : margin.top + margin.bottom), - naxis = axis == 'x' ? 'y' : 'x', + var availableWidth = width - margin.left - margin.right, + availableHeight = height - margin.top - margin.bottom, container = d3.select(this); + //add series index to each data point for reference + data.forEach(function(series, i) { + series.values.forEach(function(point) { + point.series = i; + }); + }); + + //------------------------------------------------------------ // Setup Scales - scale0 = scale0 || scale; + // remap and flatten the data for use in calculating the scales' domains + var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate + data.map(function(d) { + return d.values.map(function(d,i) { + return { x: getX(d,i), y: getY(d,i), y0: d.y0 } + }) + }); + + x .domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x })) + .rangeBands(xRange || [0, availableWidth], .1); + + y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return d.y }).concat(forceY))); + + + // If showValues, pad the Y axis range to account for label height + if (showValues) y.range(yRange || [availableHeight - (y.domain()[0] < 0 ? 12 : 0), y.domain()[1] > 0 ? 12 : 0]); + else y.range(yRange || [availableHeight, 0]); + + //store old scales if they exist + x0 = x0 || x; + y0 = y0 || y.copy().range([y(0),y(0)]); //------------------------------------------------------------ @@ -3659,46 +3346,146 @@ nv.models.distribution = function() { //------------------------------------------------------------ // Setup containers and skeleton of chart - var wrap = container.selectAll('g.nv-distribution').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-distribution'); + var wrap = container.selectAll('g.nv-wrap.nv-discretebar').data([data]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-discretebar'); var gEnter = wrapEnter.append('g'); var g = wrap.select('g'); - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')') + gEnter.append('g').attr('class', 'nv-groups'); + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + //------------------------------------------------------------ + + + + //TODO: by definition, the discrete bar should not have multiple groups, will modify/remove later + var groups = wrap.select('.nv-groups').selectAll('.nv-group') + .data(function(d) { return d }, function(d) { return d.key }); + groups.enter().append('g') + .style('stroke-opacity', 1e-6) + .style('fill-opacity', 1e-6); + groups.exit() + .transition() + .style('stroke-opacity', 1e-6) + .style('fill-opacity', 1e-6) + .remove(); + groups + .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) + .classed('hover', function(d) { return d.hover }); + groups + .transition() + .style('stroke-opacity', 1) + .style('fill-opacity', .75); + + + var bars = groups.selectAll('g.nv-bar') + .data(function(d) { return d.values }); + + bars.exit().remove(); + + + var barsEnter = bars.enter().append('g') + .attr('transform', function(d,i,j) { + return 'translate(' + (x(getX(d,i)) + x.rangeBand() * .05 ) + ', ' + y(0) + ')' + }) + .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here + d3.select(this).classed('hover', true); + dispatch.elementMouseover({ + value: getY(d,i), + point: d, + series: data[d.series], + pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted + pointIndex: i, + seriesIndex: d.series, + e: d3.event + }); + }) + .on('mouseout', function(d,i) { + d3.select(this).classed('hover', false); + dispatch.elementMouseout({ + value: getY(d,i), + point: d, + series: data[d.series], + pointIndex: i, + seriesIndex: d.series, + e: d3.event + }); + }) + .on('click', function(d,i) { + dispatch.elementClick({ + value: getY(d,i), + point: d, + series: data[d.series], + pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted + pointIndex: i, + seriesIndex: d.series, + e: d3.event + }); + d3.event.stopPropagation(); + }) + .on('dblclick', function(d,i) { + dispatch.elementDblClick({ + value: getY(d,i), + point: d, + series: data[d.series], + pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted + pointIndex: i, + seriesIndex: d.series, + e: d3.event + }); + d3.event.stopPropagation(); + }); - //------------------------------------------------------------ + barsEnter.append('rect') + .attr('height', 0) + .attr('width', x.rangeBand() * .9 / data.length ) + if (showValues) { + barsEnter.append('text') + .attr('text-anchor', 'middle') + ; - var distWrap = g.selectAll('g.nv-dist') - .data(function(d) { return d }, function(d) { return d.key }); + bars.select('text') + .text(function(d,i) { return valueFormat(getY(d,i)) }) + .transition() + .attr('x', x.rangeBand() * .9 / 2) + .attr('y', function(d,i) { return getY(d,i) < 0 ? y(getY(d,i)) - y(0) + 12 : -4 }) - distWrap.enter().append('g'); - distWrap - .attr('class', function(d,i) { return 'nv-dist nv-series-' + i }) - .style('stroke', function(d,i) { return color(d, i) }); + ; + } else { + bars.selectAll('text').remove(); + } - var dist = distWrap.selectAll('line.nv-dist' + axis) - .data(function(d) { return d.values }) - dist.enter().append('line') - .attr(axis + '1', function(d,i) { return scale0(getData(d,i)) }) - .attr(axis + '2', function(d,i) { return scale0(getData(d,i)) }) - distWrap.exit().selectAll('line.nv-dist' + axis) - .transition() - .attr(axis + '1', function(d,i) { return scale(getData(d,i)) }) - .attr(axis + '2', function(d,i) { return scale(getData(d,i)) }) - .style('stroke-opacity', 0) - .remove(); - dist - .attr('class', function(d,i) { return 'nv-dist' + axis + ' nv-dist' + axis + '-' + i }) - .attr(naxis + '1', 0) - .attr(naxis + '2', size); - dist + bars + .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive' }) + .style('fill', function(d,i) { return d.color || color(d,i) }) + .style('stroke', function(d,i) { return d.color || color(d,i) }) + .select('rect') + .attr('class', rectClass) .transition() - .attr(axis + '1', function(d,i) { return scale(getData(d,i)) }) - .attr(axis + '2', function(d,i) { return scale(getData(d,i)) }) + .attr('width', x.rangeBand() * .9 / data.length); + bars.transition() + //.delay(function(d,i) { return i * 1200 / data[0].values.length }) + .attr('transform', function(d,i) { + var left = x(getX(d,i)) + x.rangeBand() * .05, + top = getY(d,i) < 0 ? + y(0) : + y(0) - y(getY(d,i)) < 1 ? + y(0) - 1 : //make 1 px positive bars show up above y=0 + y(getY(d,i)); + return 'translate(' + left + ', ' + top + ')' + }) + .select('rect') + .attr('height', function(d,i) { + return Math.max(Math.abs(y(getY(d,i)) - y((yDomain && yDomain[0]) || 0)) || 1) + }); - scale0 = scale.copy(); + + //store old scales for use in transitions on update + x0 = x.copy(); + y0 = y.copy(); }); @@ -3709,8 +3496,23 @@ nv.models.distribution = function() { //============================================================ // Expose Public Variables //------------------------------------------------------------ + + chart.dispatch = dispatch; + chart.options = nv.utils.optionsFunc.bind(chart); - + + chart.x = function(_) { + if (!arguments.length) return getX; + getX = _; + return chart; + }; + + chart.y = function(_) { + if (!arguments.length) return getY; + getY = _; + return chart; + }; + chart.margin = function(_) { if (!arguments.length) return margin; margin.top = typeof _.top != 'undefined' ? _.top : margin.top; @@ -3726,27 +3528,51 @@ nv.models.distribution = function() { return chart; }; - chart.axis = function(_) { - if (!arguments.length) return axis; - axis = _; + chart.height = function(_) { + if (!arguments.length) return height; + height = _; return chart; }; - chart.size = function(_) { - if (!arguments.length) return size; - size = _; + chart.xScale = function(_) { + if (!arguments.length) return x; + x = _; return chart; }; - chart.getData = function(_) { - if (!arguments.length) return getData; - getData = d3.functor(_); + chart.yScale = function(_) { + if (!arguments.length) return y; + y = _; return chart; }; - chart.scale = function(_) { - if (!arguments.length) return scale; - scale = _; + chart.xDomain = function(_) { + if (!arguments.length) return xDomain; + xDomain = _; + return chart; + }; + + chart.yDomain = function(_) { + if (!arguments.length) return yDomain; + yDomain = _; + return chart; + }; + + chart.xRange = function(_) { + if (!arguments.length) return xRange; + xRange = _; + return chart; + }; + + chart.yRange = function(_) { + if (!arguments.length) return yRange; + yRange = _; + return chart; + }; + + chart.forceY = function(_) { + if (!arguments.length) return forceY; + forceY = _; return chart; }; @@ -3755,73 +3581,145 @@ nv.models.distribution = function() { color = nv.utils.getColor(_); return chart; }; + + chart.id = function(_) { + if (!arguments.length) return id; + id = _; + return chart; + }; + + chart.showValues = function(_) { + if (!arguments.length) return showValues; + showValues = _; + return chart; + }; + + chart.valueFormat= function(_) { + if (!arguments.length) return valueFormat; + valueFormat = _; + return chart; + }; + + chart.rectClass= function(_) { + if (!arguments.length) return rectClass; + rectClass = _; + return chart; + }; //============================================================ return chart; } -//TODO: consider deprecating and using multibar with single series for this -nv.models.historicalBar = function() { + +nv.models.discreteBarChart = function() { "use strict"; //============================================================ // Public Variables with Default Settings //------------------------------------------------------------ - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one - , x = d3.scale.linear() - , y = d3.scale.linear() - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , forceX = [] - , forceY = [0] - , padData = false - , clipEdge = true - , color = nv.utils.defaultColor() - , xDomain - , yDomain - , xRange - , yRange - , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout') - , interactive = true + var discretebar = nv.models.discreteBar() + , xAxis = nv.models.axis() + , yAxis = nv.models.axis() + ; + + var margin = {top: 15, right: 10, bottom: 50, left: 60} + , width = null + , height = null + , color = nv.utils.getColor() + , showXAxis = true + , showYAxis = true + , rightAlignYAxis = false + , staggerLabels = false + , tooltips = true + , tooltip = function(key, x, y, e, graph) { + return '

' + x + '

' + + '

' + y + '

' + } + , x + , y + , noData = "No Data Available." + , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'beforeUpdate') + , transitionDuration = 250 + ; + + xAxis + .orient('bottom') + .highlightZero(false) + .showMaxMin(false) + .tickFormat(function(d) { return d }) + ; + yAxis + .orient((rightAlignYAxis) ? 'right' : 'left') + .tickFormat(d3.format(',.1f')) ; //============================================================ + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var showTooltip = function(e, offsetElement) { + var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), + top = e.pos[1] + ( offsetElement.offsetTop || 0), + x = xAxis.tickFormat()(discretebar.x()(e.point, e.pointIndex)), + y = yAxis.tickFormat()(discretebar.y()(e.point, e.pointIndex)), + content = tooltip(e.series.key, x, y, e, chart); + + nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); + }; + + //============================================================ + + function chart(selection) { selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); + var container = d3.select(this), + that = this; + + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right, + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + + + chart.update = function() { + dispatch.beforeUpdate(); + container.transition().duration(transitionDuration).call(chart); + }; + chart.container = this; //------------------------------------------------------------ - // Setup Scales + // Display No Data message if there's nothing to show. - x .domain(xDomain || d3.extent(data[0].values.map(getX).concat(forceX) )) + if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { + var noDataText = container.selectAll('.nv-noData').data([noData]); - if (padData) - x.range(xRange || [availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5) / data[0].values.length ]); - else - x.range(xRange || [0, availableWidth]); + noDataText.enter().append('text') + .attr('class', 'nvd3 nv-noData') + .attr('dy', '-.7em') + .style('text-anchor', 'middle'); - y .domain(yDomain || d3.extent(data[0].values.map(getY).concat(forceY) )) - .range(yRange || [availableHeight, 0]); + noDataText + .attr('x', margin.left + availableWidth / 2) + .attr('y', margin.top + availableHeight / 2) + .text(function(d) { return d }); - // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point + return chart; + } else { + container.selectAll('.nv-noData').remove(); + } - if (x.domain()[0] === x.domain()[1]) - x.domain()[0] ? - x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01]) - : x.domain([-1,1]); + //------------------------------------------------------------ - if (y.domain()[0] === y.domain()[1]) - y.domain()[0] ? - y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01]) - : y.domain([-1,1]); + + //------------------------------------------------------------ + // Setup Scales + + x = discretebar.xScale(); + y = discretebar.yScale().clamp(true); //------------------------------------------------------------ @@ -3829,164 +3727,140 @@ nv.models.historicalBar = function() { //------------------------------------------------------------ // Setup containers and skeleton of chart - var wrap = container.selectAll('g.nv-wrap.nv-historicalBar-' + id).data([data[0].values]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-historicalBar-' + id); - var defsEnter = wrapEnter.append('defs'); - var gEnter = wrapEnter.append('g'); + var wrap = container.selectAll('g.nv-wrap.nv-discreteBarWithAxes').data([data]); + var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-discreteBarWithAxes').append('g'); + var defsEnter = gEnter.append('defs'); var g = wrap.select('g'); - gEnter.append('g').attr('class', 'nv-bars'); + gEnter.append('g').attr('class', 'nv-x nv-axis'); + gEnter.append('g').attr('class', 'nv-y nv-axis'); + gEnter.append('g').attr('class', 'nv-barsWrap'); - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + if (rightAlignYAxis) { + g.select(".nv-y.nv-axis") + .attr("transform", "translate(" + availableWidth + ",0)"); + } //------------------------------------------------------------ - container - .on('click', function(d,i) { - dispatch.chartClick({ - data: d, - index: i, - pos: d3.event, - id: id - }); - }); + //------------------------------------------------------------ + // Main Chart Component(s) + + discretebar + .width(availableWidth) + .height(availableHeight); + + + var barsWrap = g.select('.nv-barsWrap') + .datum(data.filter(function(d) { return !d.disabled })) + + barsWrap.transition().call(discretebar); + + //------------------------------------------------------------ + defsEnter.append('clipPath') - .attr('id', 'nv-chart-clip-path-' + id) + .attr('id', 'nv-x-label-clip-' + discretebar.id()) .append('rect'); - wrap.select('#nv-chart-clip-path-' + id + ' rect') - .attr('width', availableWidth) - .attr('height', availableHeight); + g.select('#nv-x-label-clip-' + discretebar.id() + ' rect') + .attr('width', x.rangeBand() * (staggerLabels ? 2 : 1)) + .attr('height', 16) + .attr('x', -x.rangeBand() / (staggerLabels ? 1 : 2 )); - g .attr('clip-path', clipEdge ? 'url(#nv-chart-clip-path-' + id + ')' : ''); + //------------------------------------------------------------ + // Setup Axes + if (showXAxis) { + xAxis + .scale(x) + .ticks( availableWidth / 100 ) + .tickSize(-availableHeight, 0); - var bars = wrap.select('.nv-bars').selectAll('.nv-bar') - .data(function(d) { return d }, function(d,i) {return getX(d,i)}); + g.select('.nv-x.nv-axis') + .attr('transform', 'translate(0,' + (y.range()[0] + ((discretebar.showValues() && y.domain()[0] < 0) ? 16 : 0)) + ')'); + //d3.transition(g.select('.nv-x.nv-axis')) + g.select('.nv-x.nv-axis').transition() + .call(xAxis); - bars.exit().remove(); + var xTicks = g.select('.nv-x.nv-axis').selectAll('g'); - var barsEnter = bars.enter().append('rect') - //.attr('class', function(d,i,j) { return (getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive') + ' nv-bar-' + j + '-' + i }) - .attr('x', 0 ) - .attr('y', function(d,i) { return nv.utils.NaNtoZero(y(Math.max(0, getY(d,i)))) }) - .attr('height', function(d,i) { return nv.utils.NaNtoZero(Math.abs(y(getY(d,i)) - y(0))) }) - .attr('transform', function(d,i) { return 'translate(' + (x(getX(d,i)) - availableWidth / data[0].values.length * .45) + ',0)'; }) - .on('mouseover', function(d,i) { - if (!interactive) return; - d3.select(this).classed('hover', true); - dispatch.elementMouseover({ - point: d, - series: data[0], - pos: [x(getX(d,i)), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: 0, - e: d3.event - }); + if (staggerLabels) { + xTicks + .selectAll('text') + .attr('transform', function(d,i,j) { return 'translate(0,' + (j % 2 == 0 ? '5' : '17') + ')' }) + } + } - }) - .on('mouseout', function(d,i) { - if (!interactive) return; - d3.select(this).classed('hover', false); - dispatch.elementMouseout({ - point: d, - series: data[0], - pointIndex: i, - seriesIndex: 0, - e: d3.event - }); - }) - .on('click', function(d,i) { - if (!interactive) return; - dispatch.elementClick({ - //label: d[label], - value: getY(d,i), - data: d, - index: i, - pos: [x(getX(d,i)), y(getY(d,i))], - e: d3.event, - id: id - }); - d3.event.stopPropagation(); - }) - .on('dblclick', function(d,i) { - if (!interactive) return; - dispatch.elementDblClick({ - //label: d[label], - value: getY(d,i), - data: d, - index: i, - pos: [x(getX(d,i)), y(getY(d,i))], - e: d3.event, - id: id - }); - d3.event.stopPropagation(); - }); + if (showYAxis) { + yAxis + .scale(y) + .ticks( availableHeight / 36 ) + .tickSize( -availableWidth, 0); - bars - .attr('fill', function(d,i) { return color(d, i); }) - .attr('class', function(d,i,j) { return (getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive') + ' nv-bar-' + j + '-' + i }) - .transition() - .attr('transform', function(d,i) { return 'translate(' + (x(getX(d,i)) - availableWidth / data[0].values.length * .45) + ',0)'; }) - //TODO: better width calculations that don't assume always uniform data spacing;w - .attr('width', (availableWidth / data[0].values.length) * .9 ); + g.select('.nv-y.nv-axis').transition() + .call(yAxis); + } + //------------------------------------------------------------ - bars.transition() - .attr('y', function(d,i) { - var rval = getY(d,i) < 0 ? - y(0) : - y(0) - y(getY(d,i)) < 1 ? - y(0) - 1 : - y(getY(d,i)); - return nv.utils.NaNtoZero(rval); - }) - .attr('height', function(d,i) { return nv.utils.NaNtoZero(Math.max(Math.abs(y(getY(d,i)) - y(0)),1)) }); - }); + //============================================================ + // Event Handling/Dispatching (in chart's scope) + //------------------------------------------------------------ + + dispatch.on('tooltipShow', function(e) { + if (tooltips) showTooltip(e, that.parentNode); + }); + + //============================================================ + + + }); + + return chart; + } + + //============================================================ + // Event Handling/Dispatching (out of chart's scope) + //------------------------------------------------------------ + + discretebar.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + discretebar.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); - return chart; - } + dispatch.on('tooltipHide', function() { + if (tooltips) nv.tooltip.cleanup(); + }); + + //============================================================ - //Create methods to allow outside functions to highlight a specific bar. - chart.highlightPoint = function(pointIndex, isHoverOver) { - d3.select(".nv-historicalBar-" + id) - .select(".nv-bars .nv-bar-0-" + pointIndex) - .classed("hover", isHoverOver) - ; - }; - chart.clearHighlights = function() { - d3.select(".nv-historicalBar-" + id) - .select(".nv-bars .nv-bar.hover") - .classed("hover", false) - ; - }; //============================================================ // Expose Public Variables //------------------------------------------------------------ + // expose chart's sub-components chart.dispatch = dispatch; + chart.discretebar = discretebar; + chart.xAxis = xAxis; + chart.yAxis = yAxis; + + d3.rebind(chart, discretebar, 'x', 'y', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'id', 'showValues', 'valueFormat'); chart.options = nv.utils.optionsFunc.bind(chart); - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - return chart; - }; - chart.margin = function(_) { if (!arguments.length) return margin; margin.top = typeof _.top != 'undefined' ? _.top : margin.top; @@ -4008,84 +3882,210 @@ nv.models.historicalBar = function() { return chart; }; - chart.xScale = function(_) { - if (!arguments.length) return x; - x = _; + chart.color = function(_) { + if (!arguments.length) return color; + color = nv.utils.getColor(_); + discretebar.color(color); return chart; }; - chart.yScale = function(_) { - if (!arguments.length) return y; - y = _; + chart.showXAxis = function(_) { + if (!arguments.length) return showXAxis; + showXAxis = _; return chart; }; - chart.xDomain = function(_) { - if (!arguments.length) return xDomain; - xDomain = _; + chart.showYAxis = function(_) { + if (!arguments.length) return showYAxis; + showYAxis = _; return chart; }; - chart.yDomain = function(_) { - if (!arguments.length) return yDomain; - yDomain = _; + chart.rightAlignYAxis = function(_) { + if(!arguments.length) return rightAlignYAxis; + rightAlignYAxis = _; + yAxis.orient( (_) ? 'right' : 'left'); return chart; }; - chart.xRange = function(_) { - if (!arguments.length) return xRange; - xRange = _; + chart.staggerLabels = function(_) { + if (!arguments.length) return staggerLabels; + staggerLabels = _; return chart; }; - chart.yRange = function(_) { - if (!arguments.length) return yRange; - yRange = _; + chart.tooltips = function(_) { + if (!arguments.length) return tooltips; + tooltips = _; return chart; }; - chart.forceX = function(_) { - if (!arguments.length) return forceX; - forceX = _; + chart.tooltipContent = function(_) { + if (!arguments.length) return tooltip; + tooltip = _; return chart; }; - chart.forceY = function(_) { - if (!arguments.length) return forceY; - forceY = _; + chart.noData = function(_) { + if (!arguments.length) return noData; + noData = _; return chart; }; - chart.padData = function(_) { - if (!arguments.length) return padData; - padData = _; + chart.transitionDuration = function(_) { + if (!arguments.length) return transitionDuration; + transitionDuration = _; return chart; }; - chart.clipEdge = function(_) { - if (!arguments.length) return clipEdge; - clipEdge = _; + //============================================================ + + + return chart; +} + +nv.models.distribution = function() { + "use strict"; + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var margin = {top: 0, right: 0, bottom: 0, left: 0} + , width = 400 //technically width or height depending on x or y.... + , size = 8 + , axis = 'x' // 'x' or 'y'... horizontal or vertical + , getData = function(d) { return d[axis] } // defaults d.x or d.y + , color = nv.utils.defaultColor() + , scale = d3.scale.linear() + , domain + ; + + //============================================================ + + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var scale0; + + //============================================================ + + + function chart(selection) { + selection.each(function(data) { + var availableLength = width - (axis === 'x' ? margin.left + margin.right : margin.top + margin.bottom), + naxis = axis == 'x' ? 'y' : 'x', + container = d3.select(this); + + + //------------------------------------------------------------ + // Setup Scales + + scale0 = scale0 || scale; + + //------------------------------------------------------------ + + + //------------------------------------------------------------ + // Setup containers and skeleton of chart + + var wrap = container.selectAll('g.nv-distribution').data([data]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-distribution'); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g'); + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')') + + //------------------------------------------------------------ + + + var distWrap = g.selectAll('g.nv-dist') + .data(function(d) { return d }, function(d) { return d.key }); + + distWrap.enter().append('g'); + distWrap + .attr('class', function(d,i) { return 'nv-dist nv-series-' + i }) + .style('stroke', function(d,i) { return color(d, i) }); + + var dist = distWrap.selectAll('line.nv-dist' + axis) + .data(function(d) { return d.values }) + dist.enter().append('line') + .attr(axis + '1', function(d,i) { return scale0(getData(d,i)) }) + .attr(axis + '2', function(d,i) { return scale0(getData(d,i)) }) + distWrap.exit().selectAll('line.nv-dist' + axis) + .transition() + .attr(axis + '1', function(d,i) { return scale(getData(d,i)) }) + .attr(axis + '2', function(d,i) { return scale(getData(d,i)) }) + .style('stroke-opacity', 0) + .remove(); + dist + .attr('class', function(d,i) { return 'nv-dist' + axis + ' nv-dist' + axis + '-' + i }) + .attr(naxis + '1', 0) + .attr(naxis + '2', size); + dist + .transition() + .attr(axis + '1', function(d,i) { return scale(getData(d,i)) }) + .attr(axis + '2', function(d,i) { return scale(getData(d,i)) }) + + + scale0 = scale.copy(); + + }); + + return chart; + } + + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + chart.options = nv.utils.optionsFunc.bind(chart); + + chart.margin = function(_) { + if (!arguments.length) return margin; + margin.top = typeof _.top != 'undefined' ? _.top : margin.top; + margin.right = typeof _.right != 'undefined' ? _.right : margin.right; + margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; + margin.left = typeof _.left != 'undefined' ? _.left : margin.left; return chart; }; - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); + chart.width = function(_) { + if (!arguments.length) return width; + width = _; return chart; }; - chart.id = function(_) { - if (!arguments.length) return id; - id = _; + chart.axis = function(_) { + if (!arguments.length) return axis; + axis = _; return chart; }; - chart.interactive = function(_) { - if(!arguments.length) return interactive; - interactive = false; + chart.size = function(_) { + if (!arguments.length) return size; + size = _; + return chart; + }; + + chart.getData = function(_) { + if (!arguments.length) return getData; + getData = d3.functor(_); + return chart; + }; + + chart.scale = function(_) { + if (!arguments.length) return scale; + scale = _; return chart; }; + chart.color = function(_) { + if (!arguments.length) return color; + color = nv.utils.getColor(_); + return chart; + }; //============================================================ @@ -4325,7 +4325,7 @@ nv.models.historicalBarChart = function() { // Event Handling/Dispatching (in chart's scope) //------------------------------------------------------------ - 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) { @@ -4347,7 +4347,7 @@ nv.models.historicalBarChart = function() { data.forEach(function(d) { d.disabled = true; }); - d.disabled = false; + d.disabled = false; state.disabled = data.map(function(d) { return !!d.disabled }); dispatch.stateChange(state); @@ -4369,7 +4369,7 @@ nv.models.historicalBarChart = function() { state.disabled = e.disabled; } - selection.call(chart); + chart.update(); }); //============================================================ @@ -4411,11 +4411,11 @@ nv.models.historicalBarChart = function() { chart.xAxis = xAxis; chart.yAxis = yAxis; - d3.rebind(chart, bars, 'defined', 'isArea', 'x', 'y', 'size', 'xScale', 'yScale', + d3.rebind(chart, bars, 'defined', 'isArea', 'x', 'y', 'size', 'xScale', 'yScale', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id', 'interpolate','highlightPoint','clearHighlights', 'interactive'); chart.options = nv.utils.optionsFunc.bind(chart); - + chart.margin = function(_) { if (!arguments.length) return margin; margin.top = typeof _.top != 'undefined' ? _.top : margin.top; @@ -9183,7 +9183,7 @@ nv.models.multiBarHorizontalChart = function() { // Event Handling/Dispatching (in chart's scope) //------------------------------------------------------------ - legend.dispatch.on('stateChange', function(newState) { + legend.dispatch.on('stateChange', function(newState) { state = newState; dispatch.stateChange(state); chart.update(); @@ -9232,7 +9232,7 @@ nv.models.multiBarHorizontalChart = function() { state.stacked = e.stacked; } - selection.call(chart); + chart.update(); }); //============================================================ @@ -9276,7 +9276,7 @@ nv.models.multiBarHorizontalChart = function() { d3.rebind(chart, multibar, 'x', 'y', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'clipEdge', 'id', 'delay', 'showValues', 'valueFormat', 'stacked', 'barColor'); chart.options = nv.utils.optionsFunc.bind(chart); - + chart.margin = function(_) { if (!arguments.length) return margin; margin.top = typeof _.top != 'undefined' ? _.top : margin.top; diff --git a/nv.d3.min.css b/nv.d3.min.css index e69de29..d46f7eb 100644 --- a/nv.d3.min.css +++ b/nv.d3.min.css @@ -0,0 +1 @@ +.chartWrap{margin:0;padding:0;overflow:hidden}.nvtooltip.with-3d-shadow,.with-3d-shadow .nvtooltip{-moz-box-shadow:0 5px 10px rgba(0,0,0,.2);-webkit-box-shadow:0 5px 10px rgba(0,0,0,.2);box-shadow:0 5px 10px rgba(0,0,0,.2);-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.nvtooltip{position:absolute;background-color:rgba(255,255,255,1);padding:1px;border:1px solid rgba(0,0,0,.2);z-index:10000;font-family:Arial;font-size:13px;text-align:left;pointer-events:none;white-space:nowrap;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.nvtooltip.with-transitions,.with-transitions .nvtooltip{transition:opacity 250ms linear;-moz-transition:opacity 250ms linear;-webkit-transition:opacity 250ms linear;transition-delay:250ms;-moz-transition-delay:250ms;-webkit-transition-delay:250ms}.nvtooltip.x-nvtooltip,.nvtooltip.y-nvtooltip{padding:8px}.nvtooltip h3{margin:0;padding:4px 14px;line-height:18px;font-weight:400;background-color:rgba(247,247,247,.75);text-align:center;border-bottom:1px solid #ebebeb;-webkit-border-radius:5px 5px 0 0;-moz-border-radius:5px 5px 0 0;border-radius:5px 5px 0 0}.nvtooltip p{margin:0;padding:5px 14px;text-align:center}.nvtooltip span{display:inline-block;margin:2px 0}.nvtooltip table{margin:6px;border-spacing:0}.nvtooltip table td{padding:2px 9px 2px 0;vertical-align:middle}.nvtooltip table td.key{font-weight:400}.nvtooltip table td.value{text-align:right;font-weight:700}.nvtooltip table tr.highlight td{padding:1px 9px 1px 0;border-bottom-style:solid;border-bottom-width:1px;border-top-style:solid;border-top-width:1px}.nvtooltip table td.legend-color-guide div{width:8px;height:8px;vertical-align:middle}.nvtooltip .footer{padding:3px;text-align:center}.nvtooltip-pending-removal{position:absolute;pointer-events:none}svg{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:block;width:100%;height:100%}svg text{font:400 12px Arial}svg .title{font:700 14px Arial}.nvd3 .nv-background{fill:#fff;fill-opacity:0}.nvd3.nv-noData{font-size:18px;font-weight:700}.nv-brush .extent{fill-opacity:.125;shape-rendering:crispEdges}.nvd3 .nv-legend .nv-series{cursor:pointer}.nvd3 .nv-legend .disabled circle{fill-opacity:0}.nvd3 .nv-axis{pointer-events:none}.nvd3 .nv-axis path{fill:none;stroke:#000;stroke-opacity:.75;shape-rendering:crispEdges}.nvd3 .nv-axis path.domain{stroke-opacity:.75}.nvd3 .nv-axis.nv-x path.domain{stroke-opacity:0}.nvd3 .nv-axis line{fill:none;stroke:#e5e5e5;shape-rendering:crispEdges}.nvd3 .nv-axis .zero line,.nvd3 .nv-axis line.zero{stroke-opacity:.75}.nvd3 .nv-axis .nv-axisMaxMin text{font-weight:700}.nvd3 .x .nv-axis .nv-axisMaxMin text,.nvd3 .x2 .nv-axis .nv-axisMaxMin text,.nvd3 .x3 .nv-axis .nv-axisMaxMin text{text-anchor:middle}.nv-brush .resize path{fill:#eee;stroke:#666}.nvd3 .nv-bars .negative rect{zfill:brown}.nvd3 .nv-bars rect{zfill:#4682b4;fill-opacity:.75;transition:fill-opacity 250ms linear;-moz-transition:fill-opacity 250ms linear;-webkit-transition:fill-opacity 250ms linear}.nvd3 .nv-bars rect.hover{fill-opacity:1}.nvd3 .nv-bars .hover rect{fill:#add8e6}.nvd3 .nv-bars text{fill:rgba(0,0,0,0)}.nvd3 .nv-bars .hover text{fill:rgba(0,0,0,1)}.nvd3 .nv-multibar .nv-groups rect,.nvd3 .nv-multibarHorizontal .nv-groups rect,.nvd3 .nv-discretebar .nv-groups rect{stroke-opacity:0;transition:fill-opacity 250ms linear;-moz-transition:fill-opacity 250ms linear;-webkit-transition:fill-opacity 250ms linear}.nvd3 .nv-multibar .nv-groups rect:hover,.nvd3 .nv-multibarHorizontal .nv-groups rect:hover,.nvd3 .nv-discretebar .nv-groups rect:hover{fill-opacity:1}.nvd3 .nv-discretebar .nv-groups text,.nvd3 .nv-multibarHorizontal .nv-groups text{font-weight:700;fill:rgba(0,0,0,1);stroke:rgba(0,0,0,0)}.nvd3.nv-pie path{stroke-opacity:0;transition:fill-opacity 250ms linear,stroke-width 250ms linear,stroke-opacity 250ms linear;-moz-transition:fill-opacity 250ms linear,stroke-width 250ms linear,stroke-opacity 250ms linear;-webkit-transition:fill-opacity 250ms linear,stroke-width 250ms linear,stroke-opacity 250ms linear}.nvd3.nv-pie .nv-slice text{stroke:#000;stroke-width:0}.nvd3.nv-pie path{stroke:#fff;stroke-width:1px;stroke-opacity:1}.nvd3.nv-pie .hover path{fill-opacity:.7}.nvd3.nv-pie .nv-label{pointer-events:none}.nvd3.nv-pie .nv-label rect{fill-opacity:0;stroke-opacity:0}.nvd3 .nv-groups path.nv-line{fill:none;stroke-width:1.5px}.nvd3 .nv-groups path.nv-line.nv-thin-line{stroke-width:1px}.nvd3 .nv-groups path.nv-area{stroke:none}.nvd3 .nv-line.hover path{stroke-width:6px}.nvd3.nv-line .nvd3.nv-scatter .nv-groups .nv-point{fill-opacity:0;stroke-opacity:0}.nvd3.nv-scatter.nv-single-point .nv-groups .nv-point{fill-opacity:.5!important;stroke-opacity:.5!important}.with-transitions .nvd3 .nv-groups .nv-point{transition:stroke-width 250ms linear,stroke-opacity 250ms linear;-moz-transition:stroke-width 250ms linear,stroke-opacity 250ms linear;-webkit-transition:stroke-width 250ms linear,stroke-opacity 250ms linear}.nvd3.nv-scatter .nv-groups .nv-point.hover,.nvd3 .nv-groups .nv-point.hover{stroke-width:7px;fill-opacity:.95!important;stroke-opacity:.95!important}.nvd3 .nv-point-paths path{stroke:#aaa;stroke-opacity:0;fill:#eee;fill-opacity:0}.nvd3 .nv-indexLine{cursor:ew-resize}.nvd3 .nv-distribution{pointer-events:none}.nvd3 .nv-groups .nv-point.hover{stroke-width:20px;stroke-opacity:.5}.nvd3 .nv-scatter .nv-point.hover{fill-opacity:1}.nvd3.nv-stackedarea path.nv-area{fill-opacity:.7;stroke-opacity:0;transition:fill-opacity 250ms linear,stroke-opacity 250ms linear;-moz-transition:fill-opacity 250ms linear,stroke-opacity 250ms linear;-webkit-transition:fill-opacity 250ms linear,stroke-opacity 250ms linear}.nvd3.nv-stackedarea path.nv-area.hover{fill-opacity:.9}.nvd3.nv-stackedarea .nv-groups .nv-point{stroke-opacity:0;fill-opacity:0}.nvd3.nv-linePlusBar .nv-bar rect{fill-opacity:.75}.nvd3.nv-linePlusBar .nv-bar rect:hover{fill-opacity:1}.nvd3.nv-bullet{font:10px sans-serif}.nvd3.nv-bullet .nv-measure{fill-opacity:.8}.nvd3.nv-bullet .nv-measure:hover{fill-opacity:1}.nvd3.nv-bullet .nv-marker{stroke:#000;stroke-width:2px}.nvd3.nv-bullet .nv-markerTriangle{stroke:#000;fill:#fff;stroke-width:1.5px}.nvd3.nv-bullet .nv-tick line{stroke:#666;stroke-width:.5px}.nvd3.nv-bullet .nv-range.nv-s0{fill:#eee}.nvd3.nv-bullet .nv-range.nv-s1{fill:#ddd}.nvd3.nv-bullet .nv-range.nv-s2{fill:#ccc}.nvd3.nv-bullet .nv-title{font-size:14px;font-weight:700}.nvd3.nv-bullet .nv-subtitle{fill:#999}.nvd3.nv-bullet .nv-range{fill:#bababa;fill-opacity:.4}.nvd3.nv-bullet .nv-range:hover{fill-opacity:.7}.nvd3.nv-sparkline path{fill:none}.nvd3.nv-sparklineplus g.nv-hoverValue{pointer-events:none}.nvd3.nv-sparklineplus .nv-hoverValue line{stroke:#333;stroke-width:1.5px}.nvd3.nv-sparklineplus,.nvd3.nv-sparklineplus g{pointer-events:all}.nvd3 .nv-hoverArea{fill-opacity:0;stroke-opacity:0}.nvd3.nv-sparklineplus .nv-xValue,.nvd3.nv-sparklineplus .nv-yValue{stroke-width:0;font-size:.9em;font-weight:400}.nvd3.nv-sparklineplus .nv-yValue{stroke:#f66}.nvd3.nv-sparklineplus .nv-maxValue{stroke:#2ca02c;fill:#2ca02c}.nvd3.nv-sparklineplus .nv-minValue{stroke:#d62728;fill:#d62728}.nvd3.nv-sparklineplus .nv-currentValue{font-weight:700;font-size:1.1em}.nvd3.nv-ohlcBar .nv-ticks .nv-tick{stroke-width:2px}.nvd3.nv-ohlcBar .nv-ticks .nv-tick.hover{stroke-width:4px}.nvd3.nv-ohlcBar .nv-ticks .nv-tick.positive{stroke:#2ca02c}.nvd3.nv-ohlcBar .nv-ticks .nv-tick.negative{stroke:#d62728}.nvd3.nv-historicalStockChart .nv-axis .nv-axislabel{font-weight:700}.nvd3.nv-historicalStockChart .nv-dragTarget{fill-opacity:0;stroke:none;cursor:move}.nvd3 .nv-brush .extent{fill-opacity:0!important}.nvd3 .nv-brushBackground rect{stroke:#000;stroke-width:.4;fill:#fff;fill-opacity:.7}.nvd3.nv-indentedtree .name{margin-left:5px}.nvd3.nv-indentedtree .clickable{color:#08C;cursor:pointer}.nvd3.nv-indentedtree span.clickable:hover{color:#005580;text-decoration:underline}.nvd3.nv-indentedtree .nv-childrenCount{display:inline-block;margin-left:5px}.nvd3.nv-indentedtree .nv-treeicon{cursor:pointer}.nvd3.nv-indentedtree .nv-treeicon.nv-folded{cursor:pointer}.nvd3 .background path{fill:none;stroke:#ccc;stroke-opacity:.4;shape-rendering:crispEdges}.nvd3 .foreground path{fill:none;stroke:#4682b4;stroke-opacity:.7}.nvd3 .brush .extent{fill-opacity:.3;stroke:#fff;shape-rendering:crispEdges}.nvd3 .axis line,.axis path{fill:none;stroke:#000;shape-rendering:crispEdges}.nvd3 .axis text{text-shadow:0 1px 0 #fff}.nvd3 .nv-interactiveGuideLine{pointer-events:none}.nvd3 line.nv-guideline{stroke:#ccc} \ No newline at end of file diff --git a/nv.d3.min.js b/nv.d3.min.js index 52c3fa5..528d62a 100644 --- a/nv.d3.min.js +++ b/nv.d3.min.js @@ -1,6 +1,6 @@ -(function(){function t(e,t){return(new Date(t,e+1,0)).getDate()}function n(e,t,n){return function(r,i,s){var o=e(r),u=[];o1)while(op||r>d||d3.event.relatedTarget&&d3.event.relatedTarget.ownerSVGElement===undefined||a){if(l&&d3.event.relatedTarget&&d3.event.relatedTarget.ownerSVGElement===undefined&&d3.event.relatedTarget.className.match(t.nvPointerEventsClass))return;u.elementMouseout({mouseX:n,mouseY:r}),c.renderGuideLine(null);return}var f=s.invert(n);u.elementMousemove({mouseX:n,mouseY:r,pointXValue:f}),d3.event.type==="dblclick"&&u.elementDblclick({mouseX:n,mouseY:r,pointXValue:f})}var h=d3.select(this),p=n||960,d=r||400,v=h.selectAll("g.nv-wrap.nv-interactiveLineLayer").data([o]),m=v.enter().append("g").attr("class"," nv-wrap nv-interactiveLineLayer");m.append("g").attr("class","nv-interactiveGuideLine");if(!f)return;f.on("mousemove",g,!0).on("mouseout",g,!0).on("dblclick",g),c.renderGuideLine=function(t){if(!a)return;var n=v.select(".nv-interactiveGuideLine").selectAll("line").data(t!=null?[e.utils.NaNtoZero(t)]:[],String);n.enter().append("line").attr("class","nv-guideline").attr("x1",function(e){return e}).attr("x2",function(e){return e}).attr("y1",d).attr("y2",0),n.exit().remove()}})}var t=e.models.tooltip(),n=null,r=null,i={left:0,top:0},s=d3.scale.linear(),o=d3.scale.linear(),u=d3.dispatch("elementMousemove","elementMouseout","elementDblclick"),a=!0,f=null,l=navigator.userAgent.indexOf("MSIE")!==-1;return c.dispatch=u,c.tooltip=t,c.margin=function(e){return arguments.length?(i.top=typeof e.top!="undefined"?e.top:i.top,i.left=typeof e.left!="undefined"?e.left:i.left,c):i},c.width=function(e){return arguments.length?(n=e,c):n},c.height=function(e){return arguments.length?(r=e,c):r},c.xScale=function(e){return arguments.length?(s=e,c):s},c.showGuideLine=function(e){return arguments.length?(a=e,c):a},c.svgContainer=function(e){return arguments.length?(f=e,c):f},c},e.interactiveBisect=function(e,t,n){"use strict";if(!e instanceof Array)return null;typeof n!="function"&&(n=function(e,t){return e.x});var r=d3.bisector(n).left,i=d3.max([0,r(e,t)-1]),s=n(e[i],i);typeof s=="undefined"&&(s=i);if(s===t)return i;var o=d3.min([i+1,e.length-1]),u=n(e[o],o);return typeof u=="undefined"&&(u=o),Math.abs(u-t)>=Math.abs(s-t)?i:o},e.nearestValueIndex=function(e,t,n){"use strict";var r=Infinity,i=null;return e.forEach(function(e,s){var o=Math.abs(t-e);o<=r&&oT.height?0:x}v.top=Math.abs(x-S.top),v.left=Math.abs(E.left-S.left)}t+=a.offsetLeft+v.left-2*a.scrollLeft,u+=a.offsetTop+v.top-2*a.scrollTop}return s&&s>0&&(u=Math.floor(u/s)*s),e.tooltip.calcTooltipPosition([t,u],r,i,h),w}var t=null,n=null,r="w",i=50,s=25,o=null,u=null,a=null,f=null,l={left:null,top:null},c=!0,h="nvtooltip-"+Math.floor(Math.random()*1e5),p="nv-pointer-events-none",d=function(e,t){return e},v=function(e){return e},m=function(e){if(t!=null)return t;if(e==null)return"";var n=d3.select(document.createElement("table")),r=n.selectAll("thead").data([e]).enter().append("thead");r.append("tr").append("td").attr("colspan",3).append("strong").classed("x-value",!0).html(v(e.value));var i=n.selectAll("tbody").data([e]).enter().append("tbody"),s=i.selectAll("tr").data(function(e){return e.series}).enter().append("tr").classed("highlight",function(e){return e.highlight});s.append("td").classed("legend-color-guide",!0).append("div").style("background-color",function(e){return e.color}),s.append("td").classed("key",!0).html(function(e){return e.key}),s.append("td").classed("value",!0).html(function(e,t){return d(e.value,t)}),s.selectAll("td").each(function(e){if(e.highlight){var t=d3.scale.linear().domain([0,1]).range(["#fff",e.color]),n=.6;d3.select(this).style("border-bottom-color",t(n)).style("border-top-color",t(n))}});var o=n.node().outerHTML;return e.footer!==undefined&&(o+=""),o},g=function(e){return e&&e.series&&e.series.length>0?!0:!1};return w.nvPointerEventsClass=p,w.content=function(e){return arguments.length?(t=e,w):t},w.tooltipElem=function(){return f},w.contentGenerator=function(e){return arguments.length?(typeof e=="function"&&(m=e),w):m},w.data=function(e){return arguments.length?(n=e,w):n},w.gravity=function(e){return arguments.length?(r=e,w):r},w.distance=function(e){return arguments.length?(i=e,w):i},w.snapDistance=function(e){return arguments.length?(s=e,w):s},w.classes=function(e){return arguments.length?(u=e,w):u},w.chartContainer=function(e){return arguments.length?(a=e,w):a},w.position=function(e){return arguments.length?(l.left=typeof e.left!="undefined"?e.left:l.left,l.top=typeof e.top!="undefined"?e.top:l.top,w):l},w.fixedTop=function(e){return arguments.length?(o=e,w):o},w.enabled=function(e){return arguments.length?(c=e,w):c},w.valueFormatter=function(e){return arguments.length?(typeof e=="function"&&(d=e),w):d},w.headerFormatter=function(e){return arguments.length?(typeof e=="function"&&(v=e),w):v},w.id=function(){return h},w},e.tooltip.show=function(t,n,r,i,s,o){var u=document.createElement("div");u.className="nvtooltip "+(o?o:"xy-tooltip");var a=s;if(!s||s.tagName.match(/g|svg/i))a=document.getElementsByTagName("body")[0];u.style.left=0,u.style.top=0,u.style.opacity=0,u.innerHTML=n,a.appendChild(u),s&&(t[0]=t[0]-s.scrollLeft,t[1]=t[1]-s.scrollTop),e.tooltip.calcTooltipPosition(t,r,i,u)},e.tooltip.findFirstNonSVGParent=function(e){while(e.tagName.match(/^g|svg$/i)!==null)e=e.parentNode;return e},e.tooltip.findTotalOffsetTop=function(e,t){var n=t;do isNaN(e.offsetTop)||(n+=e.offsetTop);while(e=e.offsetParent);return n},e.tooltip.findTotalOffsetLeft=function(e,t){var n=t;do isNaN(e.offsetLeft)||(n+=e.offsetLeft);while(e=e.offsetParent);return n},e.tooltip.calcTooltipPosition=function(t,n,r,i){var s=parseInt(i.offsetHeight),o=parseInt(i.offsetWidth),u=e.utils.windowSize().width,a=e.utils.windowSize().height,f=window.pageYOffset,l=window.pageXOffset,c,h;a=window.innerWidth>=document.body.scrollWidth?a:a-16,u=window.innerHeight>=document.body.scrollHeight?u:u-16,n=n||"s",r=r||20;var p=function(t){return e.tooltip.findTotalOffsetTop(t,h)},d=function(t){return e.tooltip.findTotalOffsetLeft(t,c)};switch(n){case"e":c=t[0]-o-r,h=t[1]-s/2;var v=d(i),m=p(i);vl?t[0]+r:l-v+c),mf+a&&(h=f+a-m+h-s);break;case"w":c=t[0]+r,h=t[1]-s/2;var v=d(i),m=p(i);v+o>u&&(c=t[0]-o-r),mf+a&&(h=f+a-m+h-s);break;case"n":c=t[0]-o/2-5,h=t[1]+r;var v=d(i),m=p(i);vu&&(c=c-o/2+5),m+s>f+a&&(h=f+a-m+h-s);break;case"s":c=t[0]-o/2,h=t[1]-s-r;var v=d(i),m=p(i);vu&&(c=c-o/2+5),f>m&&(h=f);break;case"none":c=t[0],h=t[1]-r;var v=d(i),m=p(i)}return i.style.left=c+"px",i.style.top=h+"px",i.style.opacity=1,i.style.position="absolute",i},e.tooltip.cleanup=function(){var e=document.getElementsByClassName("nvtooltip"),t=[];while(e.length)t.push(e[0]),e[0].style.transitionDelay="0 !important",e[0].style.opacity=0,e[0].className="nvtooltip-pending-removal";setTimeout(function(){while(t.length){var e=t.pop();e.parentNode.removeChild(e)}},500)}}(),e.utils.windowSize=function(){var e={width:640,height:480};return document.body&&document.body.offsetWidth&&(e.width=document.body.offsetWidth,e.height=document.body.offsetHeight),document.compatMode=="CSS1Compat"&&document.documentElement&&document.documentElement.offsetWidth&&(e.width=document.documentElement.offsetWidth,e.height=document.documentElement.offsetHeight),window.innerWidth&&window.innerHeight&&(e.width=window.innerWidth,e.height=window.innerHeight),e},e.utils.windowResize=function(e){if(e===undefined)return;var t=window.onresize;window.onresize=function(n){typeof t=="function"&&t(n),e(n)}},e.utils.getColor=function(t){return arguments.length?Object.prototype.toString.call(t)==="[object Array]"?function(e,n){return e.color||t[n%t.length]}:t:e.utils.defaultColor()},e.utils.defaultColor=function(){var e=d3.scale.category20().range();return function(t,n){return t.color||e[n%e.length]}},e.utils.customTheme=function(e,t,n){t=t||function(e){return e.key},n=n||d3.scale.category20().range();var r=n.length;return function(i,s){var o=t(i);return r||(r=n.length),typeof e[o]!="undefined"?typeof e[o]=="function"?e[o]():e[o]:n[--r]}},e.utils.pjax=function(t,n){function r(r){d3.html(r,function(r){var i=d3.select(n).node();i.parentNode.replaceChild(d3.select(r).select(n).node(),i),e.utils.pjax(t,n)})}d3.selectAll(t).on("click",function(){history.pushState(this.href,this.textContent,this.href),r(this.href),d3.event.preventDefault()}),d3.select(window).on("popstate",function(){d3.event.state&&r(d3.event.state)})},e.utils.calcApproxTextWidth=function(e){if(e instanceof d3.selection){var t=parseInt(e.style("font-size").replace("px","")),n=e.text().length;return n*t*.5}return 0},e.utils.NaNtoZero=function(e){return typeof e!="number"||isNaN(e)||e===null||e===Infinity?0:e},e.utils.optionsFunc=function(e){return e&&d3.map(e).forEach(function(e,t){typeof this[e]=="function"&&this[e](t)}.bind(this)),this},e.models.axis=function(){"use strict";function m(e){return e.each(function(e){var i=d3.select(this),m=i.selectAll("g.nv-wrap.nv-axis").data([e]),g=m.enter().append("g").attr("class","nvd3 nv-wrap nv-axis"),y=g.append("g"),b=m.select("g");p!==null?t.ticks(p):(t.orient()=="top"||t.orient()=="bottom")&&t.ticks(Math.abs(s.range()[1]-s.range()[0])/100),b.transition().call(t),v=v||t.scale();var w=t.tickFormat();w==null&&(w=v.tickFormat());var E=b.selectAll("text.nv-axislabel").data([o||null]);E.exit().remove();switch(t.orient()){case"top":E.enter().append("text").attr("class","nv-axislabel");var S=s.range().length==2?s.range()[1]:s.range()[s.range().length-1]+(s.range()[1]-s.range()[0]);E.attr("text-anchor","middle").attr("y",0).attr("x",S/2);if(u){var x=m.selectAll("g.nv-axisMaxMin").data(s.domain());x.enter().append("g").attr("class","nv-axisMaxMin").append("text"),x.exit().remove(),x.attr("transform",function(e,t){return"translate("+s(e)+",0)"}).select("text").attr("dy","-0.5em").attr("y",-t.tickPadding()).attr("text-anchor","middle").text(function(e,t){var n=w(e);return(""+n).match("NaN")?"":n}),x.transition().attr("transform",function(e,t){return"translate("+s.range()[t]+",0)"})}break;case"bottom":var T=36,N=30,C=b.selectAll("g").select("text");if(f%360){C.each(function(e,t){var n=this.getBBox().width;n>N&&(N=n)});var k=Math.abs(Math.sin(f*Math.PI/180)),T=(k?k*N:N)+30;C.attr("transform",function(e,t,n){return"rotate("+f+" 0,0)"}).style("text-anchor",f%360>0?"start":"end")}E.enter().append("text").attr("class","nv-axislabel");var S=s.range().length==2?s.range()[1]:s.range()[s.range().length-1]+(s.range()[1]-s.range()[0]);E.attr("text-anchor","middle").attr("y",T).attr("x",S/2);if(u){var x=m.selectAll("g.nv-axisMaxMin").data([s.domain()[0],s.domain()[s.domain().length-1]]);x.enter().append("g").attr("class","nv-axisMaxMin").append("text"),x.exit().remove(),x.attr("transform",function(e,t){return"translate("+(s(e)+(h?s.rangeBand()/2:0))+",0)"}).select("text").attr("dy",".71em").attr("y",t.tickPadding()).attr("transform",function(e,t,n){return"rotate("+f+" 0,0)"}).style("text-anchor",f?f%360>0?"start":"end":"middle").text(function(e,t){var n=w(e);return(""+n).match("NaN")?"":n}),x.transition().attr("transform",function(e,t){return"translate("+(s(e)+(h?s.rangeBand()/2:0))+",0)"})}c&&C.attr("transform",function(e,t){return"translate(0,"+(t%2==0?"0":"12")+")"});break;case"right":E.enter().append("text").attr("class","nv-axislabel"),E.style("text-anchor",l?"middle":"begin").attr("transform",l?"rotate(90)":"").attr("y",l?-Math.max(n.right,r)+12:-10).attr("x",l?s.range()[0]/2:t.tickPadding());if(u){var x=m.selectAll("g.nv-axisMaxMin").data(s.domain());x.enter().append("g").attr("class","nv-axisMaxMin").append("text").style("opacity",0),x.exit().remove(),x.attr("transform",function(e,t){return"translate(0,"+s(e)+")"}).select("text").attr("dy",".32em").attr("y",0).attr("x",t.tickPadding()).style("text-anchor","start").text(function(e,t){var n=w(e);return(""+n).match("NaN")?"":n}),x.transition().attr("transform",function(e,t){return"translate(0,"+s.range()[t]+")"}).select("text").style("opacity",1)}break;case"left":E.enter().append("text").attr("class","nv-axislabel"),E.style("text-anchor",l?"middle":"end").attr("transform",l?"rotate(-90)":"").attr("y",l?-Math.max(n.left,r)+d:-10).attr("x",l?-s.range()[0]/2:-t.tickPadding());if(u){var x=m.selectAll("g.nv-axisMaxMin").data(s.domain());x.enter().append("g").attr("class","nv-axisMaxMin").append("text").style("opacity",0),x.exit().remove(),x.attr("transform",function(e,t){return"translate(0,"+v(e)+")"}).select("text").attr("dy",".32em").attr("y",0).attr("x",-t.tickPadding()).attr("text-anchor","end").text(function(e,t){var n=w(e);return(""+n).match("NaN")?"":n}),x.transition().attr("transform",function(e,t){return"translate(0,"+s.range()[t]+")"}).select("text").style("opacity",1)}}E.text(function(e){return e}),u&&(t.orient()==="left"||t.orient()==="right")&&(b.selectAll("g").each(function(e,t){d3.select(this).select("text").attr("opacity",1);if(s(e)s.range()[0]-10)(e>1e-10||e<-1e-10)&&d3.select(this).attr("opacity",0),d3.select(this).select("text").attr("opacity",0)}),s.domain()[0]==s.domain()[1]&&s.domain()[0]==0&&m.selectAll("g.nv-axisMaxMin").style("opacity",function(e,t){return t?0:1}));if(u&&(t.orient()==="top"||t.orient()==="bottom")){var L=[];m.selectAll("g.nv-axisMaxMin").each(function(e,t){try{t?L.push(s(e)-this.getBBox().width-4):L.push(s(e)+this.getBBox().width+4)}catch(n){t?L.push(s(e)-4):L.push(s(e)+4)}}),b.selectAll("g").each(function(e,t){if(s(e)L[1])e>1e-10||e<-1e-10?d3.select(this).remove():d3.select(this).select("text").remove()})}a&&b.selectAll(".tick").filter(function(e){return!parseFloat(Math.round(e.__data__*1e5)/1e6)&&e.__data__!==undefined}).classed("zero",!0),v=s.copy()}),m}var t=d3.svg.axis(),n={top:0,right:0,bottom:0,left:0},r=75,i=60,s=d3.scale.linear(),o=null,u=!0,a=!0,f=0,l=!0,c=!1,h=!1,p=null,d=12;t.scale(s).orient("bottom").tickFormat(function(e){return e});var v;return m.axis=t,d3.rebind(m,t,"orient","tickValues","tickSubdivide","tickSize","tickPadding","tickFormat"),d3.rebind(m,s,"domain","range","rangeBand","rangeBands"),m.options=e.utils.optionsFunc.bind(m),m.margin=function(e){return arguments.length?(n.top=typeof e.top!="undefined"?e.top:n.top,n.right=typeof e.right!="undefined"?e.right:n.right,n.bottom=typeof e.bottom!="undefined"?e.bottom:n.bottom,n.left=typeof e.left!="undefined"?e.left:n.left,m):n},m.width=function(e){return arguments.length?(r=e,m):r},m.ticks=function(e){return arguments.length?(p=e,m):p},m.height=function(e){return arguments.length?(i=e,m):i},m.axisLabel=function(e){return arguments.length?(o=e,m):o},m.showMaxMin=function(e){return arguments.length?(u=e,m):u},m.highlightZero=function(e){return arguments.length?(a=e,m):a},m.scale=function(e){return arguments.length?(s=e,t.scale(s),h=typeof s.rangeBands=="function",d3.rebind(m,s,"domain","range","rangeBand","rangeBands"),m):s},m.rotateYLabel=function(e){return arguments.length?(l=e,m):l},m.rotateLabels=function(e){return arguments.length?(f=e,m):f},m.staggerLabels=function(e){return arguments.length?(c=e,m):c},m.axisLabelDistance=function(e){return arguments.length?(d=e,m):d},m},e.models.bullet=function(){"use strict";function m(e){return e.each(function(e,n){var p=c-t.left-t.right,m=h-t.top-t.bottom,g=d3.select(this),y=i.call(this,e,n).slice().sort(d3.descending),b=s.call(this,e,n).slice().sort(d3.descending),w=o.call(this,e,n).slice().sort(d3.descending),E=u.call(this,e,n).slice(),S=a.call(this,e,n).slice(),x=f.call(this,e,n).slice(),T=d3.scale.linear().domain(d3.extent(d3.merge([l,y]))).range(r?[p,0]:[0,p]),N=this.__chart__||d3.scale.linear().domain([0,Infinity]).range(T.range());this.__chart__=T;var C=d3.min(y),k=d3.max(y),L=y[1],A=g.selectAll("g.nv-wrap.nv-bullet").data([e]),O=A.enter().append("g").attr("class","nvd3 nv-wrap nv-bullet"),M=O.append("g"),_=A.select("g");M.append("rect").attr("class","nv-range nv-rangeMax"),M.append("rect").attr("class","nv-range nv-rangeAvg"),M.append("rect").attr("class","nv-range nv-rangeMin"),M.append("rect").attr("class","nv-measure"),M.append("path").attr("class","nv-markerTriangle"),A.attr("transform","translate("+t.left+","+t.top+")");var D=function(e){return Math.abs(N(e)-N(0))},P=function(e){return Math.abs(T(e)-T(0))},H=function(e){return e<0?N(e):N(0)},B=function(e){return e<0?T(e):T(0)};_.select("rect.nv-rangeMax").attr("height",m).attr("width",P(k>0?k:C)).attr("x",B(k>0?k:C)).datum(k>0?k:C),_.select("rect.nv-rangeAvg").attr("height",m).attr("width",P(L)).attr("x",B(L)).datum(L),_.select("rect.nv-rangeMin").attr("height",m).attr("width",P(k)).attr("x",B(k)).attr("width",P(k>0?C:k)).attr("x",B(k>0?C:k)).datum(k>0?C:k),_.select("rect.nv-measure").style("fill",d).attr("height",m/3).attr("y",m/3).attr("width",w<0?T(0)-T(w[0]):T(w[0])-T(0)).attr("x",B(w)).on("mouseover",function(){v.elementMouseover({value:w[0],label:x[0]||"Current",pos:[T(w[0]),m/2]})}).on("mouseout",function(){v.elementMouseout({value:w[0],label:x[0]||"Current"})});var j=m/6;b[0]?_.selectAll("path.nv-markerTriangle").attr("transform",function(e){return"translate("+T(b[0])+","+m/2+")"}).attr("d","M0,"+j+"L"+j+","+ -j+" "+ -j+","+ -j+"Z").on("mouseover",function(){v.elementMouseover({value:b[0],label:S[0]||"Previous",pos:[T(b[0]),m/2]})}).on("mouseout",function(){v.elementMouseout({value:b[0],label:S[0]||"Previous"})}):_.selectAll("path.nv-markerTriangle").remove(),A.selectAll(".nv-range").on("mouseover",function(e,t){var n=E[t]||(t?t==1?"Mean":"Minimum":"Maximum");v.elementMouseover({value:e,label:n,pos:[T(e),m/2]})}).on("mouseout",function(e,t){var n=E[t]||(t?t==1?"Mean":"Minimum":"Maximum");v.elementMouseout({value:e,label:n})})}),m}var t={top:0,right:0,bottom:0,left:0},n="left",r=!1,i=function(e){return e.ranges},s=function(e){return e.markers},o=function(e){return e.measures},u=function(e){return e.rangeLabels?e.rangeLabels:[]},a=function(e){return e.markerLabels?e.markerLabels:[]},f=function(e){return e.measureLabels?e.measureLabels:[]},l=[0],c=380,h=30,p=null,d=e.utils.getColor(["#1f77b4"]),v=d3.dispatch("elementMouseover","elementMouseout");return m.dispatch=v,m.options=e.utils.optionsFunc.bind(m),m.orient=function(e){return arguments.length?(n=e,r=n=="right"||n=="bottom",m):n},m.ranges=function(e){return arguments.length?(i=e,m):i},m.markers=function(e){return arguments.length?(s=e,m):s},m.measures=function(e){return arguments.length?(o=e,m):o},m.forceX=function(e){return arguments.length?(l=e,m):l},m.width=function(e){return arguments.length?(c=e,m):c},m.height=function(e){return arguments.length?(h=e,m):h},m.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,m):t},m.tickFormat=function(e){return arguments.length?(p=e,m):p},m.color=function(t){return arguments.length?(d=e.utils.getColor(t),m):d},m},e.models.bulletChart=function(){"use strict";function m(e){return e.each(function(n,h){var g=d3.select(this),y=(a||parseInt(g.style("width"))||960)-i.left-i.right,b=f-i.top-i.bottom,w=this;m.update=function(){m(e)},m.container=this;if(!n||!s.call(this,n,h)){var E=g.selectAll(".nv-noData").data([p]);return E.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),E.attr("x",i.left+y/2).attr("y",18+i.top+b/2).text(function(e){return e}),m}g.selectAll(".nv-noData").remove();var S=s.call(this,n,h).slice().sort(d3.descending),x=o.call(this,n,h).slice().sort(d3.descending),T=u.call(this,n,h).slice().sort(d3.descending),N=g.selectAll("g.nv-wrap.nv-bulletChart").data([n]),C=N.enter().append("g").attr("class","nvd3 nv-wrap nv-bulletChart"),k=C.append("g"),L=N.select("g");k.append("g").attr("class","nv-bulletWrap"),k.append("g").attr("class","nv-titles"),N.attr("transform","translate("+i.left+","+i.top+")");var A=d3.scale.linear().domain([0,Math.max(S[0],x[0],T[0])]).range(r?[y,0]:[0,y]),O=this.__chart__||d3.scale.linear().domain([0,Infinity]).range(A.range());this.__chart__=A;var M=function(e){return Math.abs(O(e)-O(0))},_=function(e){return Math.abs(A(e)-A(0))},D=k.select(".nv-titles").append("g").attr("text-anchor","end").attr("transform","translate(-6,"+(f-i.top-i.bottom)/2+")");D.append("text").attr("class","nv-title").text(function(e){return e.title}),D.append("text").attr("class","nv-subtitle").attr("dy","1em").text(function(e){return e.subtitle}),t.width(y).height(b);var P=L.select(".nv-bulletWrap");d3.transition(P).call(t);var H=l||A.tickFormat(y/100),B=L.selectAll("g.nv-tick").data(A.ticks(y/50),function(e){return this.textContent||H(e)}),j=B.enter().append("g").attr("class","nv-tick").attr("transform",function(e){return"translate("+O(e)+",0)"}).style("opacity",1e-6);j.append("line").attr("y1",b).attr("y2",b*7/6),j.append("text").attr("text-anchor","middle").attr("dy","1em").attr("y",b*7/6).text(H);var F=d3.transition(B).attr("transform",function(e){return"translate("+A(e)+",0)"}).style("opacity",1);F.select("line").attr("y1",b).attr("y2",b*7/6),F.select("text").attr("y",b*7/6),d3.transition(B.exit()).attr("transform",function(e){return"translate("+A(e)+",0)"}).style("opacity",1e-6).remove(),d.on("tooltipShow",function(e){e.key=n.title,c&&v(e,w.parentNode)})}),d3.timer.flush(),m}var t=e.models.bullet(),n="left",r=!1,i={top:5,right:40,bottom:20,left:120},s=function(e){return e.ranges},o=function(e){return e.markers},u=function(e){return e.measures},a=null,f=55,l=null,c=!0,h=function(e,t,n,r,i){return"

"+t+"

"+"

"+n+"

"},p="No Data Available.",d=d3.dispatch("tooltipShow","tooltipHide"),v=function(t,n){var r=t.pos[0]+(n.offsetLeft||0)+i.left,s=t.pos[1]+(n.offsetTop||0)+i.top,o=h(t.key,t.label,t.value,t,m);e.tooltip.show([r,s],o,t.value<0?"e":"w",null,n)};return t.dispatch.on("elementMouseover.tooltip",function(e){d.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){d.tooltipHide(e)}),d.on("tooltipHide",function(){c&&e.tooltip.cleanup()}),m.dispatch=d,m.bullet=t,d3.rebind(m,t,"color"),m.options=e.utils.optionsFunc.bind(m),m.orient=function(e){return arguments.length?(n=e,r=n=="right"||n=="bottom",m):n},m.ranges=function(e){return arguments.length?(s=e,m):s},m.markers=function(e){return arguments.length?(o=e,m):o},m.measures=function(e){return arguments.length?(u=e,m):u},m.width=function(e){return arguments.length?(a=e,m):a},m.height=function(e){return arguments.length?(f=e,m):f},m.margin=function(e){return arguments.length?(i.top=typeof e.top!="undefined"?e.top:i.top,i.right=typeof e.right!="undefined"?e.right:i.right,i.bottom=typeof e.bottom!="undefined"?e.bottom:i.bottom,i.left=typeof e.left!="undefined"?e.left:i.left,m):i},m.tickFormat=function(e){return arguments.length?(l=e,m):l},m.tooltips=function(e){return arguments.length?(c=e,m):c},m.tooltipContent=function(e){return arguments.length?(h=e,m):h},m.noData=function(e){return arguments.length?(p=e,m):p},m},e.models.cumulativeLineChart=function(){"use strict";function _(b){return b.each(function(b){function q(e,t){d3.select(_.container).style("cursor","ew-resize")}function R(e,t){O.x=d3.event.x,O.i=Math.round(A.invert(O.x)),rt()}function U(e,t){d3.select(_.container).style("cursor","auto"),x.index=O.i,k.stateChange(x)}function rt(){nt.data([O]);var e=_.transitionDuration();_.transitionDuration(0),_.update(),_.transitionDuration(e)}var P=d3.select(this).classed("nv-chart-"+S,!0),H=this,B=(f||parseInt(P.style("width"))||960)-u.left-u.right,j=(l||parseInt(P.style("height"))||400)-u.top-u.bottom;_.update=function(){P.transition().duration(L).call(_)},_.container=this,x.disabled=b.map(function(e){return!!e.disabled});if(!T){var F;T={};for(F in x)x[F]instanceof Array?T[F]=x[F].slice(0):T[F]=x[F]}var I=d3.behavior.drag().on("dragstart",q).on("drag",R).on("dragend",U);if(!b||!b.length||!b.filter(function(e){return e.values.length}).length){var z=P.selectAll(".nv-noData").data([N]);return z.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),z.attr("x",u.left+B/2).attr("y",u.top+j/2).text(function(e){return e}),_}P.selectAll(".nv-noData").remove(),w=t.xScale(),E=t.yScale();if(!y){var W=b.filter(function(e){return!e.disabled}).map(function(e,n){var r=d3.extent(e.values,t.y());return r[0]<-0.95&&(r[0]=-0.95),[(r[0]-r[1])/(1+r[1]),(r[1]-r[0])/(1+r[0])]}),X=[d3.min(W,function(e){return e[0]}),d3.max(W,function(e){return e[1]})];t.yDomain(X)}else t.yDomain(null);A.domain([0,b[0].values.length-1]).range([0,B]).clamp(!0);var b=D(O.i,b),V=g?"none":"all",$=P.selectAll("g.nv-wrap.nv-cumulativeLine").data([b]),J=$.enter().append("g").attr("class","nvd3 nv-wrap nv-cumulativeLine").append("g"),K=$.select("g");J.append("g").attr("class","nv-interactive"),J.append("g").attr("class","nv-x nv-axis").style("pointer-events","none"),J.append("g").attr("class","nv-y nv-axis"),J.append("g").attr("class","nv-background"),J.append("g").attr("class","nv-linesWrap").style("pointer-events",V),J.append("g").attr("class","nv-avgLinesWrap").style("pointer-events","none"),J.append("g").attr("class","nv-legendWrap"),J.append("g").attr("class","nv-controlsWrap"),c&&(i.width(B),K.select(".nv-legendWrap").datum(b).call(i),u.top!=i.height()&&(u.top=i.height(),j=(l||parseInt(P.style("height"))||400)-u.top-u.bottom),K.select(".nv-legendWrap").attr("transform","translate(0,"+ -u.top+")"));if(m){var Q=[{key:"Re-scale y-axis",disabled:!y}];s.width(140).color(["#444","#444","#444"]),K.select(".nv-controlsWrap").datum(Q).attr("transform","translate(0,"+ -u.top+")").call(s)}$.attr("transform","translate("+u.left+","+u.top+")"),d&&K.select(".nv-y.nv-axis").attr("transform","translate("+B+",0)");var G=b.filter(function(e){return e.tempDisabled});$.select(".tempDisabled").remove(),G.length&&$.append("text").attr("class","tempDisabled").attr("x",B/2).attr("y","-.71em").style("text-anchor","end").text(G.map(function(e){return e.key}).join(", ")+" values cannot be calculated for this time period."),g&&(o.width(B).height(j).margin({left:u.left,top:u.top}).svgContainer(P).xScale(w),$.select(".nv-interactive").call(o)),J.select(".nv-background").append("rect"),K.select(".nv-background rect").attr("width",B).attr("height",j),t.y(function(e){return e.display.y}).width(B).height(j).color(b.map(function(e,t){return e.color||a(e,t)}).filter(function(e,t){return!b[t].disabled&&!b[t].tempDisabled}));var Y=K.select(".nv-linesWrap").datum(b.filter(function(e){return!e.disabled&&!e.tempDisabled}));Y.call(t),b.forEach(function(e,t){e.seriesIndex=t});var Z=b.filter(function(e){return!e.disabled&&!!C(e)}),et=K.select(".nv-avgLinesWrap").selectAll("line").data(Z,function(e){return e.key}),tt=function(e){var t=E(C(e));return t<0?0:t>j?j:t};et.enter().append("line").style("stroke-width",2).style("stroke-dasharray","10,10").style("stroke",function(e,n){return t.color()(e,e.seriesIndex)}).attr("x1",0).attr("x2",B).attr("y1",tt).attr("y2",tt),et.style("stroke-opacity",function(e){var t=E(C(e));return t<0||t>j?0:1}).attr("x1",0).attr("x2",B).attr("y1",tt).attr("y2",tt),et.exit().remove();var nt=Y.selectAll(".nv-indexLine").data([O]);nt.enter().append("rect").attr("class","nv-indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).style("pointer-events","all").call(I),nt.attr("transform",function(e){return"translate("+A(e.i)+",0)"}).attr("height",j),h&&(n.scale(w).ticks(Math.min(b[0].values.length,B/70)).tickSize(-j,0),K.select(".nv-x.nv-axis").attr("transform","translate(0,"+E.range()[0]+")"),d3.transition(K.select(".nv-x.nv-axis")).call(n)),p&&(r.scale(E).ticks(j/36).tickSize(-B,0),d3.transition(K.select(".nv-y.nv-axis")).call(r)),K.select(".nv-background rect").on("click",function(){O.x=d3.mouse(this)[0],O.i=Math.round(A.invert(O.x)),x.index=O.i,k.stateChange(x),rt()}),t.dispatch.on("elementClick",function(e){O.i=e.pointIndex,O.x=A(O.i),x.index=O.i,k.stateChange(x),rt()}),s.dispatch.on("legendClick",function(e,t){e.disabled=!e.disabled,y=!e.disabled,x.rescaleY=y,k.stateChange(x),_.update()}),i.dispatch.on("stateChange",function(e){x.disabled=e.disabled,k.stateChange(x),_.update()}),o.dispatch.on("elementMousemove",function(i){t.clearHighlights();var s,f,l,c=[];b.filter(function(e,t){return e.seriesIndex=t,!e.disabled}).forEach(function(n,r){f=e.interactiveBisect(n.values,i.pointXValue,_.x()),t.highlightPoint(r,f,!0);var o=n.values[f];if(typeof o=="undefined")return;typeof s=="undefined"&&(s=o),typeof l=="undefined"&&(l=_.xScale()(_.x()(o,f))),c.push({key:n.key,value:_.y()(o,f),color:a(n,n.seriesIndex)})});if(c.length>2){var h=_.yScale().invert(i.mouseY),p=Math.abs(_.yScale().domain()[0]-_.yScale().domain()[1]),d=.03*p,m=e.nearestValueIndex(c.map(function(e){return e.value}),h,d);m!==null&&(c[m].highlight=!0)}var g=n.tickFormat()(_.x()(s,f),f);o.tooltip.position({left:l+u.left,top:i.mouseY+u.top}).chartContainer(H.parentNode).enabled(v).valueFormatter(function(e,t){return r.tickFormat()(e)}).data({value:g,series:c})(),o.renderGuideLine(l)}),o.dispatch.on("elementMouseout",function(e){k.tooltipHide(),t.clearHighlights()}),k.on("tooltipShow",function(e){v&&M(e,H.parentNode)}),k.on("changeState",function(e){typeof e.disabled!="undefined"&&(b.forEach(function(t,n){t.disabled=e.disabled[n]}),x.disabled=e.disabled),typeof e.index!="undefined"&&(O.i=e.index,O.x=A(O.i),x.index=e.index,nt.data([O])),typeof e.rescaleY!="undefined"&&(y=e.rescaleY),_.update()})}),_}function D(e,n){return n.map(function(n,r){if(!n.values)return n;var i=t.y()(n.values[e],e);return i<-0.95?(n.tempDisabled=!0,n):(n.tempDisabled=!1,n.values=n.values.map(function(e,n){return e.display={y:(t.y()(e,n)-i)/(1+i)},e}),n)})}var t= -e.models.line(),n=e.models.axis(),r=e.models.axis(),i=e.models.legend(),s=e.models.legend(),o=e.interactiveGuideline(),u={top:30,right:30,bottom:50,left:60},a=e.utils.defaultColor(),f=null,l=null,c=!0,h=!0,p=!0,d=!1,v=!0,m=!0,g=!1,y=!0,b=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},w,E,S=t.id(),x={index:0,rescaleY:y},T=null,N="No Data Available.",C=function(e){return e.average},k=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),L=250;n.orient("bottom").tickPadding(7),r.orient(d?"right":"left"),s.updateState(!1);var A=d3.scale.linear(),O={i:0,x:0},M=function(i,s){var o=i.pos[0]+(s.offsetLeft||0),u=i.pos[1]+(s.offsetTop||0),a=n.tickFormat()(t.x()(i.point,i.pointIndex)),f=r.tickFormat()(t.y()(i.point,i.pointIndex)),l=b(i.series.key,a,f,i,_);e.tooltip.show([o,u],l,null,null,s)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+u.left,e.pos[1]+u.top],k.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){k.tooltipHide(e)}),k.on("tooltipHide",function(){v&&e.tooltip.cleanup()}),_.dispatch=k,_.lines=t,_.legend=i,_.xAxis=n,_.yAxis=r,_.interactiveLayer=o,d3.rebind(_,t,"defined","isArea","x","y","xScale","yScale","size","xDomain","yDomain","xRange","yRange","forceX","forceY","interactive","clipEdge","clipVoronoi","useVoronoi","id"),_.options=e.utils.optionsFunc.bind(_),_.margin=function(e){return arguments.length?(u.top=typeof e.top!="undefined"?e.top:u.top,u.right=typeof e.right!="undefined"?e.right:u.right,u.bottom=typeof e.bottom!="undefined"?e.bottom:u.bottom,u.left=typeof e.left!="undefined"?e.left:u.left,_):u},_.width=function(e){return arguments.length?(f=e,_):f},_.height=function(e){return arguments.length?(l=e,_):l},_.color=function(t){return arguments.length?(a=e.utils.getColor(t),i.color(a),_):a},_.rescaleY=function(e){return arguments.length?(y=e,_):y},_.showControls=function(e){return arguments.length?(m=e,_):m},_.useInteractiveGuideline=function(e){return arguments.length?(g=e,e===!0&&(_.interactive(!1),_.useVoronoi(!1)),_):g},_.showLegend=function(e){return arguments.length?(c=e,_):c},_.showXAxis=function(e){return arguments.length?(h=e,_):h},_.showYAxis=function(e){return arguments.length?(p=e,_):p},_.rightAlignYAxis=function(e){return arguments.length?(d=e,r.orient(e?"right":"left"),_):d},_.tooltips=function(e){return arguments.length?(v=e,_):v},_.tooltipContent=function(e){return arguments.length?(b=e,_):b},_.state=function(e){return arguments.length?(x=e,_):x},_.defaultState=function(e){return arguments.length?(T=e,_):T},_.noData=function(e){return arguments.length?(N=e,_):N},_.average=function(e){return arguments.length?(C=e,_):C},_.transitionDuration=function(e){return arguments.length?(L=e,_):L},_},e.models.discreteBar=function(){"use strict";function E(e){return e.each(function(e){var i=n-t.left-t.right,E=r-t.top-t.bottom,S=d3.select(this);e.forEach(function(e,t){e.values.forEach(function(e){e.series=t})});var T=p&&d?[]:e.map(function(e){return e.values.map(function(e,t){return{x:u(e,t),y:a(e,t),y0:e.y0}})});s.domain(p||d3.merge(T).map(function(e){return e.x})).rangeBands(v||[0,i],.1),o.domain(d||d3.extent(d3.merge(T).map(function(e){return e.y}).concat(f))),c?o.range(m||[E-(o.domain()[0]<0?12:0),o.domain()[1]>0?12:0]):o.range(m||[E,0]),b=b||s,w=w||o.copy().range([o(0),o(0)]);var N=S.selectAll("g.nv-wrap.nv-discretebar").data([e]),C=N.enter().append("g").attr("class","nvd3 nv-wrap nv-discretebar"),k=C.append("g"),L=N.select("g");k.append("g").attr("class","nv-groups"),N.attr("transform","translate("+t.left+","+t.top+")");var A=N.select(".nv-groups").selectAll(".nv-group").data(function(e){return e},function(e){return e.key});A.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),A.exit().transition().style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),A.attr("class",function(e,t){return"nv-group nv-series-"+t}).classed("hover",function(e){return e.hover}),A.transition().style("stroke-opacity",1).style("fill-opacity",.75);var O=A.selectAll("g.nv-bar").data(function(e){return e.values});O.exit().remove();var M=O.enter().append("g").attr("transform",function(e,t,n){return"translate("+(s(u(e,t))+s.rangeBand()*.05)+", "+o(0)+")"}).on("mouseover",function(t,n){d3.select(this).classed("hover",!0),g.elementMouseover({value:a(t,n),point:t,series:e[t.series],pos:[s(u(t,n))+s.rangeBand()*(t.series+.5)/e.length,o(a(t,n))],pointIndex:n,seriesIndex:t.series,e:d3.event})}).on("mouseout",function(t,n){d3.select(this).classed("hover",!1),g.elementMouseout({value:a(t,n),point:t,series:e[t.series],pointIndex:n,seriesIndex:t.series,e:d3.event})}).on("click",function(t,n){g.elementClick({value:a(t,n),point:t,series:e[t.series],pos:[s(u(t,n))+s.rangeBand()*(t.series+.5)/e.length,o(a(t,n))],pointIndex:n,seriesIndex:t.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(t,n){g.elementDblClick({value:a(t,n),point:t,series:e[t.series],pos:[s(u(t,n))+s.rangeBand()*(t.series+.5)/e.length,o(a(t,n))],pointIndex:n,seriesIndex:t.series,e:d3.event}),d3.event.stopPropagation()});M.append("rect").attr("height",0).attr("width",s.rangeBand()*.9/e.length),c?(M.append("text").attr("text-anchor","middle"),O.select("text").text(function(e,t){return h(a(e,t))}).transition().attr("x",s.rangeBand()*.9/2).attr("y",function(e,t){return a(e,t)<0?o(a(e,t))-o(0)+12:-4})):O.selectAll("text").remove(),O.attr("class",function(e,t){return a(e,t)<0?"nv-bar negative":"nv-bar positive"}).style("fill",function(e,t){return e.color||l(e,t)}).style("stroke",function(e,t){return e.color||l(e,t)}).select("rect").attr("class",y).transition().attr("width",s.rangeBand()*.9/e.length),O.transition().attr("transform",function(e,t){var n=s(u(e,t))+s.rangeBand()*.05,r=a(e,t)<0?o(0):o(0)-o(a(e,t))<1?o(0)-1:o(a(e,t));return"translate("+n+", "+r+")"}).select("rect").attr("height",function(e,t){return Math.max(Math.abs(o(a(e,t))-o(d&&d[0]||0))||1)}),b=s.copy(),w=o.copy()}),E}var t={top:0,right:0,bottom:0,left:0},n=960,r=500,i=Math.floor(Math.random()*1e4),s=d3.scale.ordinal(),o=d3.scale.linear(),u=function(e){return e.x},a=function(e){return e.y},f=[0],l=e.utils.defaultColor(),c=!1,h=d3.format(",.2f"),p,d,v,m,g=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout"),y="discreteBar",b,w;return E.dispatch=g,E.options=e.utils.optionsFunc.bind(E),E.x=function(e){return arguments.length?(u=e,E):u},E.y=function(e){return arguments.length?(a=e,E):a},E.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,E):t},E.width=function(e){return arguments.length?(n=e,E):n},E.height=function(e){return arguments.length?(r=e,E):r},E.xScale=function(e){return arguments.length?(s=e,E):s},E.yScale=function(e){return arguments.length?(o=e,E):o},E.xDomain=function(e){return arguments.length?(p=e,E):p},E.yDomain=function(e){return arguments.length?(d=e,E):d},E.xRange=function(e){return arguments.length?(v=e,E):v},E.yRange=function(e){return arguments.length?(m=e,E):m},E.forceY=function(e){return arguments.length?(f=e,E):f},E.color=function(t){return arguments.length?(l=e.utils.getColor(t),E):l},E.id=function(e){return arguments.length?(i=e,E):i},E.showValues=function(e){return arguments.length?(c=e,E):c},E.valueFormat=function(e){return arguments.length?(h=e,E):h},E.rectClass=function(e){return arguments.length?(y=e,E):y},E},e.models.discreteBarChart=function(){"use strict";function w(e){return e.each(function(e){var u=d3.select(this),p=this,E=(s||parseInt(u.style("width"))||960)-i.left-i.right,S=(o||parseInt(u.style("height"))||400)-i.top-i.bottom;w.update=function(){g.beforeUpdate(),u.transition().duration(y).call(w)},w.container=this;if(!e||!e.length||!e.filter(function(e){return e.values.length}).length){var T=u.selectAll(".nv-noData").data([m]);return T.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),T.attr("x",i.left+E/2).attr("y",i.top+S/2).text(function(e){return e}),w}u.selectAll(".nv-noData").remove(),d=t.xScale(),v=t.yScale().clamp(!0);var N=u.selectAll("g.nv-wrap.nv-discreteBarWithAxes").data([e]),C=N.enter().append("g").attr("class","nvd3 nv-wrap nv-discreteBarWithAxes").append("g"),k=C.append("defs"),L=N.select("g");C.append("g").attr("class","nv-x nv-axis"),C.append("g").attr("class","nv-y nv-axis"),C.append("g").attr("class","nv-barsWrap"),L.attr("transform","translate("+i.left+","+i.top+")"),l&&L.select(".nv-y.nv-axis").attr("transform","translate("+E+",0)"),t.width(E).height(S);var A=L.select(".nv-barsWrap").datum(e.filter(function(e){return!e.disabled}));A.transition().call(t),k.append("clipPath").attr("id","nv-x-label-clip-"+t.id()).append("rect"),L.select("#nv-x-label-clip-"+t.id()+" rect").attr("width",d.rangeBand()*(c?2:1)).attr("height",16).attr("x",-d.rangeBand()/(c?1:2));if(a){n.scale(d).ticks(E/100).tickSize(-S,0),L.select(".nv-x.nv-axis").attr("transform","translate(0,"+(v.range()[0]+(t.showValues()&&v.domain()[0]<0?16:0))+")"),L.select(".nv-x.nv-axis").transition().call(n);var O=L.select(".nv-x.nv-axis").selectAll("g");c&&O.selectAll("text").attr("transform",function(e,t,n){return"translate(0,"+(n%2==0?"5":"17")+")"})}f&&(r.scale(v).ticks(S/36).tickSize(-E,0),L.select(".nv-y.nv-axis").transition().call(r)),g.on("tooltipShow",function(e){h&&b(e,p.parentNode)})}),w}var t=e.models.discreteBar(),n=e.models.axis(),r=e.models.axis(),i={top:15,right:10,bottom:50,left:60},s=null,o=null,u=e.utils.getColor(),a=!0,f=!0,l=!1,c=!1,h=!0,p=function(e,t,n,r,i){return"

"+t+"

"+"

"+n+"

"},d,v,m="No Data Available.",g=d3.dispatch("tooltipShow","tooltipHide","beforeUpdate"),y=250;n.orient("bottom").highlightZero(!1).showMaxMin(!1).tickFormat(function(e){return e}),r.orient(l?"right":"left").tickFormat(d3.format(",.1f"));var b=function(i,s){var o=i.pos[0]+(s.offsetLeft||0),u=i.pos[1]+(s.offsetTop||0),a=n.tickFormat()(t.x()(i.point,i.pointIndex)),f=r.tickFormat()(t.y()(i.point,i.pointIndex)),l=p(i.series.key,a,f,i,w);e.tooltip.show([o,u],l,i.value<0?"n":"s",null,s)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+i.left,e.pos[1]+i.top],g.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){g.tooltipHide(e)}),g.on("tooltipHide",function(){h&&e.tooltip.cleanup()}),w.dispatch=g,w.discretebar=t,w.xAxis=n,w.yAxis=r,d3.rebind(w,t,"x","y","xDomain","yDomain","xRange","yRange","forceX","forceY","id","showValues","valueFormat"),w.options=e.utils.optionsFunc.bind(w),w.margin=function(e){return arguments.length?(i.top=typeof e.top!="undefined"?e.top:i.top,i.right=typeof e.right!="undefined"?e.right:i.right,i.bottom=typeof e.bottom!="undefined"?e.bottom:i.bottom,i.left=typeof e.left!="undefined"?e.left:i.left,w):i},w.width=function(e){return arguments.length?(s=e,w):s},w.height=function(e){return arguments.length?(o=e,w):o},w.color=function(n){return arguments.length?(u=e.utils.getColor(n),t.color(u),w):u},w.showXAxis=function(e){return arguments.length?(a=e,w):a},w.showYAxis=function(e){return arguments.length?(f=e,w):f},w.rightAlignYAxis=function(e){return arguments.length?(l=e,r.orient(e?"right":"left"),w):l},w.staggerLabels=function(e){return arguments.length?(c=e,w):c},w.tooltips=function(e){return arguments.length?(h=e,w):h},w.tooltipContent=function(e){return arguments.length?(p=e,w):p},w.noData=function(e){return arguments.length?(m=e,w):m},w.transitionDuration=function(e){return arguments.length?(y=e,w):y},w},e.models.distribution=function(){"use strict";function l(e){return e.each(function(e){var a=n-(i==="x"?t.left+t.right:t.top+t.bottom),l=i=="x"?"y":"x",c=d3.select(this);f=f||u;var h=c.selectAll("g.nv-distribution").data([e]),p=h.enter().append("g").attr("class","nvd3 nv-distribution"),d=p.append("g"),v=h.select("g");h.attr("transform","translate("+t.left+","+t.top+")");var m=v.selectAll("g.nv-dist").data(function(e){return e},function(e){return e.key});m.enter().append("g"),m.attr("class",function(e,t){return"nv-dist nv-series-"+t}).style("stroke",function(e,t){return o(e,t)});var g=m.selectAll("line.nv-dist"+i).data(function(e){return e.values});g.enter().append("line").attr(i+"1",function(e,t){return f(s(e,t))}).attr(i+"2",function(e,t){return f(s(e,t))}),m.exit().selectAll("line.nv-dist"+i).transition().attr(i+"1",function(e,t){return u(s(e,t))}).attr(i+"2",function(e,t){return u(s(e,t))}).style("stroke-opacity",0).remove(),g.attr("class",function(e,t){return"nv-dist"+i+" nv-dist"+i+"-"+t}).attr(l+"1",0).attr(l+"2",r),g.transition().attr(i+"1",function(e,t){return u(s(e,t))}).attr(i+"2",function(e,t){return u(s(e,t))}),f=u.copy()}),l}var t={top:0,right:0,bottom:0,left:0},n=400,r=8,i="x",s=function(e){return e[i]},o=e.utils.defaultColor(),u=d3.scale.linear(),a,f;return l.options=e.utils.optionsFunc.bind(l),l.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,l):t},l.width=function(e){return arguments.length?(n=e,l):n},l.axis=function(e){return arguments.length?(i=e,l):i},l.size=function(e){return arguments.length?(r=e,l):r},l.getData=function(e){return arguments.length?(s=d3.functor(e),l):s},l.scale=function(e){return arguments.length?(u=e,l):u},l.color=function(t){return arguments.length?(o=e.utils.getColor(t),l):o},l},e.models.historicalBar=function(){"use strict";function w(E){return E.each(function(w){var E=n-t.left-t.right,S=r-t.top-t.bottom,T=d3.select(this);s.domain(d||d3.extent(w[0].values.map(u).concat(f))),c?s.range(m||[E*.5/w[0].values.length,E*(w[0].values.length-.5)/w[0].values.length]):s.range(m||[0,E]),o.domain(v||d3.extent(w[0].values.map(a).concat(l))).range(g||[S,0]),s.domain()[0]===s.domain()[1]&&(s.domain()[0]?s.domain([s.domain()[0]-s.domain()[0]*.01,s.domain()[1]+s.domain()[1]*.01]):s.domain([-1,1])),o.domain()[0]===o.domain()[1]&&(o.domain()[0]?o.domain([o.domain()[0]+o.domain()[0]*.01,o.domain()[1]-o.domain()[1]*.01]):o.domain([-1,1]));var N=T.selectAll("g.nv-wrap.nv-historicalBar-"+i).data([w[0].values]),C=N.enter().append("g").attr("class","nvd3 nv-wrap nv-historicalBar-"+i),k=C.append("defs"),L=C.append("g"),A=N.select("g");L.append("g").attr("class","nv-bars"),N.attr("transform","translate("+t.left+","+t.top+")"),T.on("click",function(e,t){y.chartClick({data:e,index:t,pos:d3.event,id:i})}),k.append("clipPath").attr("id","nv-chart-clip-path-"+i).append("rect"),N.select("#nv-chart-clip-path-"+i+" rect").attr("width",E).attr("height",S),A.attr("clip-path",h?"url(#nv-chart-clip-path-"+i+")":"");var O=N.select(".nv-bars").selectAll(".nv-bar").data(function(e){return e},function(e,t){return u(e,t)});O.exit().remove();var M=O.enter().append("rect").attr("x",0).attr("y",function(t,n){return e.utils.NaNtoZero(o(Math.max(0,a(t,n))))}).attr("height",function(t,n){return e.utils.NaNtoZero(Math.abs(o(a(t,n))-o(0)))}).attr("transform",function(e,t){return"translate("+(s(u(e,t))-E/w[0].values.length*.45)+",0)"}).on("mouseover",function(e,t){if(!b)return;d3.select(this).classed("hover",!0),y.elementMouseover({point:e,series:w[0],pos:[s(u(e,t)),o(a(e,t))],pointIndex:t,seriesIndex:0,e:d3.event})}).on("mouseout",function(e,t){if(!b)return;d3.select(this).classed("hover",!1),y.elementMouseout({point:e,series:w[0],pointIndex:t,seriesIndex:0,e:d3.event})}).on("click",function(e,t){if(!b)return;y.elementClick({value:a(e,t),data:e,index:t,pos:[s(u(e,t)),o(a(e,t))],e:d3.event,id:i}),d3.event.stopPropagation()}).on("dblclick",function(e,t){if(!b)return;y.elementDblClick({value:a(e,t),data:e,index:t,pos:[s(u(e,t)),o(a(e,t))],e:d3.event,id:i}),d3.event.stopPropagation()});O.attr("fill",function(e,t){return p(e,t)}).attr("class",function(e,t,n){return(a(e,t)<0?"nv-bar negative":"nv-bar positive")+" nv-bar-"+n+"-"+t}).transition().attr("transform",function(e,t){return"translate("+(s(u(e,t))-E/w[0].values.length*.45)+",0)"}).attr("width",E/w[0].values.length*.9),O.transition().attr("y",function(t,n){var r=a(t,n)<0?o(0):o(0)-o(a(t,n))<1?o(0)-1:o(a(t,n));return e.utils.NaNtoZero(r)}).attr("height",function(t,n){return e.utils.NaNtoZero(Math.max(Math.abs(o(a(t,n))-o(0)),1))})}),w}var t={top:0,right:0,bottom:0,left:0},n=960,r=500,i=Math.floor(Math.random()*1e4),s=d3.scale.linear(),o=d3.scale.linear(),u=function(e){return e.x},a=function(e){return e.y},f=[],l=[0],c=!1,h=!0,p=e.utils.defaultColor(),d,v,m,g,y=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout"),b=!0;return w.highlightPoint=function(e,t){d3.select(".nv-historicalBar-"+i).select(".nv-bars .nv-bar-0-"+e).classed("hover",t)},w.clearHighlights=function(){d3.select(".nv-historicalBar-"+i).select(".nv-bars .nv-bar.hover").classed("hover",!1)},w.dispatch=y,w.options=e.utils.optionsFunc.bind(w),w.x=function(e){return arguments.length?(u=e,w):u},w.y=function(e){return arguments.length?(a=e,w):a},w.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,w):t},w.width=function(e){return arguments.length?(n=e,w):n},w.height=function(e){return arguments.length?(r=e,w):r},w.xScale=function(e){return arguments.length?(s=e,w):s},w.yScale=function(e){return arguments.length?(o=e,w):o},w.xDomain=function(e){return arguments.length?(d=e,w):d},w.yDomain=function(e){return arguments.length?(v=e,w):v},w.xRange=function(e){return arguments.length?(m=e,w):m},w.yRange=function(e){return arguments.length?(g=e,w):g},w.forceX=function(e){return arguments.length?(f=e,w):f},w.forceY=function(e){return arguments.length?(l=e,w):l},w.padData=function(e){return arguments.length?(c=e,w):c},w.clipEdge=function(e){return arguments.length?(h=e,w):h},w.color=function(t){return arguments.length?(p=e.utils.getColor(t),w):p},w.id=function(e){return arguments.length?(i=e,w):i},w.interactive=function(e){return arguments.length?(b=!1,w):b},w},e.models.historicalBarChart=function(){"use strict";function x(e){return e.each(function(d){var T=d3.select(this),N=this,C=(u||parseInt(T.style("width"))||960)-s.left-s.right,k=(a||parseInt(T.style("height"))||400)-s.top-s.bottom;x.update=function(){T.transition().duration(E).call(x)},x.container=this,g.disabled=d.map(function(e){return!!e.disabled});if(!y){var L;y={};for(L in g)g[L]instanceof Array?y[L]=g[L].slice(0):y[L]=g[L]}if(!d||!d.length||!d.filter(function(e){return e.values.length}).length){var A=T.selectAll(".nv-noData").data([b]);return A.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),A.attr("x",s.left+C/2).attr("y",s.top+k/2).text(function(e){return e}),x}T.selectAll(".nv-noData").remove(),v=t.xScale(),m=t.yScale();var O=T.selectAll("g.nv-wrap.nv-historicalBarChart").data([d]),M=O.enter().append("g").attr("class","nvd3 nv-wrap nv-historicalBarChart").append("g"),_=O.select("g");M.append("g").attr("class","nv-x nv-axis"),M.append("g").attr("class","nv-y nv-axis"),M.append("g").attr("class","nv-barsWrap"),M.append("g").attr("class","nv-legendWrap"),f&&(i.width(C),_.select(".nv-legendWrap").datum(d).call(i),s.top!=i.height()&&(s.top=i.height(),k=(a||parseInt(T.style("height"))||400)-s.top-s.bottom),O.select(".nv-legendWrap").attr("transform","translate(0,"+ -s.top+")")),O.attr("transform","translate("+s.left+","+s.top+")"),h&&_.select(".nv-y.nv-axis").attr("transform","translate("+C+",0)"),t.width(C).height(k).color(d.map(function(e,t){return e.color||o(e,t)}).filter(function(e,t){return!d[t].disabled}));var D=_.select(".nv-barsWrap").datum(d.filter(function(e){return!e.disabled}));D.transition().call(t),l&&(n.scale(v).tickSize(-k,0),_.select(".nv-x.nv-axis").attr("transform","translate(0,"+m.range()[0]+")"),_.select(".nv-x.nv-axis").transition().call(n)),c&&(r.scale(m).ticks(k/36).tickSize(-C,0),_.select(".nv-y.nv-axis").transition().call(r)),i.dispatch.on("legendClick",function(t,n){t.disabled=!t.disabled,d.filter(function(e){return!e.disabled}).length||d.map(function(e){return e.disabled=!1,O.selectAll(".nv-series").classed("disabled",!1),e}),g.disabled=d.map(function(e){return!!e.disabled}),w.stateChange(g),e.transition().call(x)}),i.dispatch.on("legendDblclick",function(e){d.forEach(function(e){e.disabled=!0}),e.disabled=!1,g.disabled=d.map(function(e){return!!e.disabled}),w.stateChange(g),x.update()}),w.on("tooltipShow",function(e){p&&S(e,N.parentNode)}),w.on("changeState",function(t){typeof t.disabled!="undefined"&&(d.forEach(function(e,n){e.disabled=t.disabled[n]}),g.disabled=t.disabled),e.call(x)})}),x}var t=e.models.historicalBar(),n=e.models.axis(),r=e.models.axis(),i=e.models.legend(),s={top:30,right:90,bottom:50,left:90},o=e.utils.defaultColor(),u=null,a=null,f=!1,l=!0,c=!0,h=!1,p=!0,d=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},v,m,g={},y=null,b="No Data Available.",w=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),E=250;n.orient("bottom").tickPadding(7),r.orient(h?"right":"left");var S=function(i,s){if(s){var o=d3.select(s).select("svg"),u=o.node()?o.attr("viewBox"):null;if(u){u=u.split(" ");var a=parseInt(o.style("width"))/u[2];i.pos[0]=i.pos[0]*a,i.pos[1]=i.pos[1]*a}}var f=i.pos[0]+(s.offsetLeft||0),l=i.pos[1]+(s.offsetTop||0),c=n.tickFormat()(t.x()(i.point,i.pointIndex)),h=r.tickFormat()(t.y()(i.point,i.pointIndex)),p=d(i.series.key,c,h,i,x);e.tooltip.show([f,l],p,null,null,s)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+s.left,e.pos[1]+s.top],w.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){w.tooltipHide(e)}),w.on("tooltipHide",function(){p&&e.tooltip.cleanup()}),x.dispatch=w,x.bars=t,x.legend=i,x.xAxis=n,x.yAxis=r,d3.rebind(x,t,"defined","isArea","x","y","size","xScale","yScale","xDomain","yDomain","xRange","yRange","forceX","forceY","interactive","clipEdge","clipVoronoi","id","interpolate","highlightPoint","clearHighlights","interactive"),x.options=e.utils.optionsFunc.bind(x),x.margin=function(e){return arguments.length?(s.top=typeof e.top!="undefined"?e.top:s.top,s.right=typeof e.right!="undefined"?e.right:s.right,s.bottom=typeof e.bottom!="undefined"?e.bottom:s.bottom,s.left=typeof e.left!="undefined"?e.left:s.left,x):s},x.width=function(e){return arguments.length?(u=e,x):u},x.height=function(e){return arguments.length?(a=e,x):a},x.color=function(t){return arguments.length?(o=e.utils.getColor(t),i.color(o),x):o},x.showLegend=function(e){return arguments.length?(f=e,x):f},x.showXAxis=function(e){return arguments.length?(l=e,x):l},x.showYAxis=function(e){return arguments.length?(c=e,x):c},x.rightAlignYAxis=function(e){return arguments.length?(h=e,r.orient(e?"right":"left"),x):h},x.tooltips=function(e){return arguments.length?(p=e,x):p},x.tooltipContent=function(e){return arguments.length?(d=e,x):d},x.state=function(e){return arguments.length?(g=e,x):g},x.defaultState=function(e){return arguments.length?(y=e,x):y},x.noData=function(e){return arguments.length?(b=e,x):b},x.transitionDuration=function(e){return arguments.length?(E=e,x):E},x},e.models.indentedTree=function(){"use strict";function g(e){return e.each(function(e){function k(e,t,n){d3.event.stopPropagation();if(d3.event.shiftKey&&!n)return d3.event.shiftKey=!1,e.values&&e.values.forEach(function(e){(e.values||e._values)&&k(e,0,!0)}),!0;if(!O(e))return!0;e.values?(e._values=e.values,e.values=null):(e.values=e._values,e._values=null),g.update()}function L(e){return e._values&&e._values.length?h:e.values&&e.values.length?p:""}function A(e){return e._values&&e._values.length}function O(e){var t=e.values||e._values;return t&&t.length}var t=1,n=d3.select(this),i=d3.layout.tree().children(function(e){return e.values}).size([r,f]);g.update=function(){n.transition().duration(600).call(g)},e[0]||(e[0]={key:a});var s=i.nodes(e[0]),y=d3.select(this).selectAll("div").data([[s]]),b=y.enter().append("div").attr("class","nvd3 nv-wrap nv-indentedtree"),w=b.append("table"),E=y.select("table").attr("width","100%").attr("class",c);if(o){var S=w.append("thead"),x=S.append("tr");l.forEach(function(e){x.append("th").attr("width",e.width?e.width:"10%").style("text-align",e.type=="numeric"?"right":"left").append("span").text(e.label)})}var T=E.selectAll("tbody").data(function(e){return e});T.enter().append("tbody"),t=d3.max(s,function(e){return e.depth}),i.size([r,t*f]);var N=T.selectAll("tr").data(function(e){return e.filter(function(e){return u&&!e.children?u(e):!0})},function(e,t){return e.id||e.id||++m});N.exit().remove(),N.select("img.nv-treeicon").attr("src",L).classed("folded",A);var C=N.enter().append("tr");l.forEach(function(e,t){var n=C.append("td").style("padding-left",function(e){return(t?0:e.depth*f+12+(L(e)?0:16))+"px"},"important").style("text-align",e.type=="numeric"?"right":"left");t==0&&n.append("img").classed("nv-treeicon",!0).classed("nv-folded",A).attr("src",L).style("width","14px").style("height","14px").style("padding","0 1px").style("display",function(e){return L(e)?"inline-block":"none"}).on("click",k),n.each(function(n){!t&&v(n)?d3.select(this).append("a").attr("href",v).attr("class",d3.functor(e.classes)).append("span"):d3.select(this).append("span"),d3.select(this).select("span").attr("class",d3.functor(e.classes)).text(function(t){return e.format?e.format(t):t[e.key]||"-"})}),e.showCount&&(n.append("span").attr("class","nv-childrenCount"),N.selectAll("span.nv-childrenCount").text(function(e){return e.values&&e.values.length||e._values&&e._values.length?"("+(e.values&&e.values.filter(function(e){return u?u(e):!0}).length||e._values&&e._values.filter(function(e){return u?u(e):!0}).length||0)+")":""}))}),N.order().on("click",function(e){d.elementClick({row:this,data:e,pos:[e.x,e.y]})}).on("dblclick",function(e){d.elementDblclick({row:this,data:e,pos:[e.x,e.y]})}).on("mouseover",function(e){d.elementMouseover({row:this,data:e,pos:[e.x,e.y]})}).on("mouseout",function(e){d.elementMouseout({row:this,data:e,pos:[e.x,e.y]})})}),g}var t={top:0,right:0,bottom:0,left:0},n=960,r=500,i=e.utils.defaultColor(),s=Math.floor(Math.random()*1e4),o=!0,u=!1,a="No Data Available.",f=20,l=[{key:"key",label:"Name",type:"text"}],c=null,h="images/grey-plus.png",p="images/grey-minus.png",d=d3.dispatch("elementClick","elementDblclick","elementMouseover","elementMouseout"),v=function(e){return e.url},m=0;return g.options=e.utils.optionsFunc.bind(g),g.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,g):t},g.width=function(e){return arguments.length?(n=e,g):n},g.height=function(e){return arguments.length?(r=e,g):r},g.color=function(t){return arguments.length?(i=e.utils.getColor(t),scatter.color(i),g):i},g.id=function(e){return arguments.length?(s=e,g):s},g.header=function(e){return arguments.length?(o=e,g):o},g.noData=function(e){return arguments.length?(a=e,g):a},g.filterZero=function(e){return arguments.length?(u=e,g):u},g.columns=function(e){return arguments.length?(l=e,g):l},g.tableClass=function(e){return arguments.length?(c=e,g):c},g.iconOpen=function(e){return arguments.length?(h=e,g):h},g.iconClose=function(e){return arguments.length?(p=e,g):p},g.getUrl=function(e){return arguments.length?(v=e,g):v},g},e.models.legend=function(){"use strict";function c(h){return h.each(function(c){var h=n-t.left-t.right,p=d3.select(this),d=p.selectAll("g.nv-legend").data([c]),v=d.enter().append("g").attr("class","nvd3 nv-legend").append("g"),m=d.select("g");d.attr("transform","translate("+t.left+","+t.top+")");var g=m.selectAll(".nv-series").data(function(e){return e}),y=g.enter().append("g").attr("class","nv-series").on("mouseover",function(e,t){l.legendMouseover(e,t)}).on("mouseout",function(e,t){l.legendMouseout(e,t)}).on("click",function(e,t){l.legendClick(e,t),a&&(f?(c.forEach(function(e){e.disabled=!0}),e.disabled=!1):(e.disabled=!e.disabled,c.every(function(e){return e.disabled})&&c.forEach(function(e){e.disabled=!1})),l.stateChange({disabled:c.map(function(e){return!!e.disabled})}))}).on("dblclick",function(e,t){l.legendDblclick(e,t),a&&(c.forEach(function(e){e.disabled=!0}),e.disabled=!1,l.stateChange({disabled:c.map(function(e){return!!e.disabled})}))});y.append("circle").style("stroke-width",2).attr("class","nv-legend-symbol").attr("r",5),y.append("text").attr("text-anchor","start").attr("class","nv-legend-text").attr("dy",".32em").attr("dx","8"),g.classed("disabled",function(e){return e.disabled}),g.exit().remove(),g.select("circle").style("fill",function(e,t){return e.color||s(e,t)}).style("stroke",function(e,t){return e.color||s(e,t)}),g.select("text").text(i);if(o){var b=[];g.each(function(t,n){var r=d3.select(this).select("text"),i;try{i=r.node().getComputedTextLength()}catch(s){i=e.utils.calcApproxTextWidth(r)}b.push(i+28)});var w=0,E=0,S=[];while(Eh&&w>1){S=[],w--;for(var x=0;x(S[x%w]||0)&&(S[x%w]=b[x]);E=S.reduce(function(e,t,n,r){return e+t})}var T=[];for(var N=0,C=0;NA&&(A=L),"translate("+O+","+k+")"}),m.attr("transform","translate("+(n-t.right-A)+","+t.top+")"),r=t.top+t.bottom+k+15}}),c}var t={top:5,right:0,bottom:5,left:0},n=400,r=20,i=function(e){return e.key},s=e.utils.defaultColor(),o=!0,u=!0,a=!0,f=!1,l=d3.dispatch("legendClick","legendDblclick","legendMouseover","legendMouseout","stateChange");return c.dispatch=l,c.options=e.utils.optionsFunc.bind(c),c.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,c):t},c.width=function(e){return arguments.length?(n=e,c):n},c.height=function(e){return arguments.length?(r=e,c):r},c.key=function(e){return arguments.length?(i=e,c):i},c.color=function(t){return arguments.length?(s=e.utils.getColor(t),c):s},c.align=function(e){return arguments.length?(o=e,c):o},c.rightAlign=function(e){return arguments.length?(u=e,c):u},c.updateState=function(e){return arguments.length?(a=e,c):a},c.radioButtonMode=function(e){return arguments.length?(f=e,c):f},c},e.models.line=function(){"use strict";function m(g){return g.each(function(m){var g=r-n.left-n.right,b=i-n.top-n.bottom,w=d3.select(this);c=t.xScale(),h=t.yScale(),d=d||c,v=v||h;var E=w.selectAll("g.nv-wrap.nv-line").data([m]),S=E.enter().append("g").attr("class","nvd3 nv-wrap nv-line"),T=S.append("defs"),N=S.append("g"),C=E.select("g");N.append("g").attr("class","nv-groups"),N.append("g").attr("class","nv-scatterWrap"),E.attr("transform","translate("+n.left+","+n.top+")"),t.width(g).height(b);var k=E.select(".nv-scatterWrap");k.transition().call(t),T.append("clipPath").attr("id","nv-edge-clip-"+t.id()).append("rect"),E.select("#nv-edge-clip-"+t.id()+" rect").attr("width",g).attr("height",b),C.attr("clip-path",l?"url(#nv-edge-clip-"+t.id()+")":""),k.attr("clip-path",l?"url(#nv-edge-clip-"+t.id()+")":"");var L=E.select(".nv-groups").selectAll(".nv-group").data(function(e){return e},function(e){return e.key});L.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),L.exit().remove(),L.attr("class",function(e,t){return"nv-group nv-series-"+t}).classed("hover",function(e){return e.hover}).style("fill",function(e,t){return s(e,t)}).style("stroke",function(e,t){return s(e,t)}),L.transition().style("stroke-opacity",1).style("fill-opacity",.5);var A=L.selectAll("path.nv-area").data(function(e){return f(e)?[e]:[]});A.enter().append("path").attr("class","nv-area").attr("d",function(t){return d3.svg.area().interpolate(p).defined(a).x(function(t,n){return e.utils.NaNtoZero(d(o(t,n)))}).y0(function(t,n){return e.utils.NaNtoZero(v(u(t,n)))}).y1(function(e,t){return v(h.domain()[0]<=0?h.domain()[1]>=0?0:h.domain()[1]:h.domain()[0])}).apply(this,[t.values])}),L.exit().selectAll("path.nv-area").remove(),A.transition().attr("d",function(t){return d3.svg.area().interpolate -(p).defined(a).x(function(t,n){return e.utils.NaNtoZero(c(o(t,n)))}).y0(function(t,n){return e.utils.NaNtoZero(h(u(t,n)))}).y1(function(e,t){return h(h.domain()[0]<=0?h.domain()[1]>=0?0:h.domain()[1]:h.domain()[0])}).apply(this,[t.values])});var O=L.selectAll("path.nv-line").data(function(e){return[e.values]});O.enter().append("path").attr("class","nv-line").attr("d",d3.svg.line().interpolate(p).defined(a).x(function(t,n){return e.utils.NaNtoZero(d(o(t,n)))}).y(function(t,n){return e.utils.NaNtoZero(v(u(t,n)))})),O.transition().attr("d",d3.svg.line().interpolate(p).defined(a).x(function(t,n){return e.utils.NaNtoZero(c(o(t,n)))}).y(function(t,n){return e.utils.NaNtoZero(h(u(t,n)))})),d=c.copy(),v=h.copy()}),m}var t=e.models.scatter(),n={top:0,right:0,bottom:0,left:0},r=960,i=500,s=e.utils.defaultColor(),o=function(e){return e.x},u=function(e){return e.y},a=function(e,t){return!isNaN(u(e,t))&&u(e,t)!==null},f=function(e){return e.area},l=!1,c,h,p="linear";t.size(16).sizeDomain([16,256]);var d,v;return m.dispatch=t.dispatch,m.scatter=t,d3.rebind(m,t,"id","interactive","size","xScale","yScale","zScale","xDomain","yDomain","xRange","yRange","sizeDomain","forceX","forceY","forceSize","clipVoronoi","useVoronoi","clipRadius","padData","highlightPoint","clearHighlights"),m.options=e.utils.optionsFunc.bind(m),m.margin=function(e){return arguments.length?(n.top=typeof e.top!="undefined"?e.top:n.top,n.right=typeof e.right!="undefined"?e.right:n.right,n.bottom=typeof e.bottom!="undefined"?e.bottom:n.bottom,n.left=typeof e.left!="undefined"?e.left:n.left,m):n},m.width=function(e){return arguments.length?(r=e,m):r},m.height=function(e){return arguments.length?(i=e,m):i},m.x=function(e){return arguments.length?(o=e,t.x(e),m):o},m.y=function(e){return arguments.length?(u=e,t.y(e),m):u},m.clipEdge=function(e){return arguments.length?(l=e,m):l},m.color=function(n){return arguments.length?(s=e.utils.getColor(n),t.color(s),m):s},m.interpolate=function(e){return arguments.length?(p=e,m):p},m.defined=function(e){return arguments.length?(a=e,m):a},m.isArea=function(e){return arguments.length?(f=d3.functor(e),m):f},m},e.models.lineChart=function(){"use strict";function N(m){return m.each(function(m){var C=d3.select(this),k=this,L=(a||parseInt(C.style("width"))||960)-o.left-o.right,A=(f||parseInt(C.style("height"))||400)-o.top-o.bottom;N.update=function(){C.transition().duration(x).call(N)},N.container=this,b.disabled=m.map(function(e){return!!e.disabled});if(!w){var O;w={};for(O in b)b[O]instanceof Array?w[O]=b[O].slice(0):w[O]=b[O]}if(!m||!m.length||!m.filter(function(e){return e.values.length}).length){var M=C.selectAll(".nv-noData").data([E]);return M.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),M.attr("x",o.left+L/2).attr("y",o.top+A/2).text(function(e){return e}),N}C.selectAll(".nv-noData").remove(),g=t.xScale(),y=t.yScale();var _=C.selectAll("g.nv-wrap.nv-lineChart").data([m]),D=_.enter().append("g").attr("class","nvd3 nv-wrap nv-lineChart").append("g"),P=_.select("g");D.append("rect").style("opacity",0),D.append("g").attr("class","nv-x nv-axis"),D.append("g").attr("class","nv-y nv-axis"),D.append("g").attr("class","nv-linesWrap"),D.append("g").attr("class","nv-legendWrap"),D.append("g").attr("class","nv-interactive"),P.select("rect").attr("width",L).attr("height",A),l&&(i.width(L),P.select(".nv-legendWrap").datum(m).call(i),o.top!=i.height()&&(o.top=i.height(),A=(f||parseInt(C.style("height"))||400)-o.top-o.bottom),_.select(".nv-legendWrap").attr("transform","translate(0,"+ -o.top+")")),_.attr("transform","translate("+o.left+","+o.top+")"),p&&P.select(".nv-y.nv-axis").attr("transform","translate("+L+",0)"),d&&(s.width(L).height(A).margin({left:o.left,top:o.top}).svgContainer(C).xScale(g),_.select(".nv-interactive").call(s)),t.width(L).height(A).color(m.map(function(e,t){return e.color||u(e,t)}).filter(function(e,t){return!m[t].disabled}));var H=P.select(".nv-linesWrap").datum(m.filter(function(e){return!e.disabled}));H.transition().call(t),c&&(n.scale(g).ticks(L/100).tickSize(-A,0),P.select(".nv-x.nv-axis").attr("transform","translate(0,"+y.range()[0]+")"),P.select(".nv-x.nv-axis").transition().call(n)),h&&(r.scale(y).ticks(A/36).tickSize(-L,0),P.select(".nv-y.nv-axis").transition().call(r)),i.dispatch.on("stateChange",function(e){b=e,S.stateChange(b),N.update()}),s.dispatch.on("elementMousemove",function(i){t.clearHighlights();var a,f,l,c=[];m.filter(function(e,t){return e.seriesIndex=t,!e.disabled}).forEach(function(n,r){f=e.interactiveBisect(n.values,i.pointXValue,N.x()),t.highlightPoint(r,f,!0);var s=n.values[f];if(typeof s=="undefined")return;typeof a=="undefined"&&(a=s),typeof l=="undefined"&&(l=N.xScale()(N.x()(s,f))),c.push({key:n.key,value:N.y()(s,f),color:u(n,n.seriesIndex)})});if(c.length>2){var h=N.yScale().invert(i.mouseY),p=Math.abs(N.yScale().domain()[0]-N.yScale().domain()[1]),d=.03*p,g=e.nearestValueIndex(c.map(function(e){return e.value}),h,d);g!==null&&(c[g].highlight=!0)}var y=n.tickFormat()(N.x()(a,f));s.tooltip.position({left:l+o.left,top:i.mouseY+o.top}).chartContainer(k.parentNode).enabled(v).valueFormatter(function(e,t){return r.tickFormat()(e)}).data({value:y,series:c})(),s.renderGuideLine(l)}),s.dispatch.on("elementMouseout",function(e){S.tooltipHide(),t.clearHighlights()}),S.on("tooltipShow",function(e){v&&T(e,k.parentNode)}),S.on("changeState",function(e){typeof e.disabled!="undefined"&&(m.forEach(function(t,n){t.disabled=e.disabled[n]}),b.disabled=e.disabled),N.update()})}),N}var t=e.models.line(),n=e.models.axis(),r=e.models.axis(),i=e.models.legend(),s=e.interactiveGuideline(),o={top:30,right:20,bottom:50,left:60},u=e.utils.defaultColor(),a=null,f=null,l=!0,c=!0,h=!0,p=!1,d=!1,v=!0,m=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},g,y,b={},w=null,E="No Data Available.",S=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),x=250;n.orient("bottom").tickPadding(7),r.orient(p?"right":"left");var T=function(i,s){var o=i.pos[0]+(s.offsetLeft||0),u=i.pos[1]+(s.offsetTop||0),a=n.tickFormat()(t.x()(i.point,i.pointIndex)),f=r.tickFormat()(t.y()(i.point,i.pointIndex)),l=m(i.series.key,a,f,i,N);e.tooltip.show([o,u],l,null,null,s)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+o.left,e.pos[1]+o.top],S.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){S.tooltipHide(e)}),S.on("tooltipHide",function(){v&&e.tooltip.cleanup()}),N.dispatch=S,N.lines=t,N.legend=i,N.xAxis=n,N.yAxis=r,N.interactiveLayer=s,d3.rebind(N,t,"defined","isArea","x","y","size","xScale","yScale","xDomain","yDomain","xRange","yRange","forceX","forceY","interactive","clipEdge","clipVoronoi","useVoronoi","id","interpolate"),N.options=e.utils.optionsFunc.bind(N),N.margin=function(e){return arguments.length?(o.top=typeof e.top!="undefined"?e.top:o.top,o.right=typeof e.right!="undefined"?e.right:o.right,o.bottom=typeof e.bottom!="undefined"?e.bottom:o.bottom,o.left=typeof e.left!="undefined"?e.left:o.left,N):o},N.width=function(e){return arguments.length?(a=e,N):a},N.height=function(e){return arguments.length?(f=e,N):f},N.color=function(t){return arguments.length?(u=e.utils.getColor(t),i.color(u),N):u},N.showLegend=function(e){return arguments.length?(l=e,N):l},N.showXAxis=function(e){return arguments.length?(c=e,N):c},N.showYAxis=function(e){return arguments.length?(h=e,N):h},N.rightAlignYAxis=function(e){return arguments.length?(p=e,r.orient(e?"right":"left"),N):p},N.useInteractiveGuideline=function(e){return arguments.length?(d=e,e===!0&&(N.interactive(!1),N.useVoronoi(!1)),N):d},N.tooltips=function(e){return arguments.length?(v=e,N):v},N.tooltipContent=function(e){return arguments.length?(m=e,N):m},N.state=function(e){return arguments.length?(b=e,N):b},N.defaultState=function(e){return arguments.length?(w=e,N):w},N.noData=function(e){return arguments.length?(E=e,N):E},N.transitionDuration=function(e){return arguments.length?(x=e,N):x},N},e.models.linePlusBarChart=function(){"use strict";function T(e){return e.each(function(e){var l=d3.select(this),c=this,v=(a||parseInt(l.style("width"))||960)-u.left-u.right,N=(f||parseInt(l.style("height"))||400)-u.top-u.bottom;T.update=function(){l.transition().call(T)},b.disabled=e.map(function(e){return!!e.disabled});if(!w){var C;w={};for(C in b)b[C]instanceof Array?w[C]=b[C].slice(0):w[C]=b[C]}if(!e||!e.length||!e.filter(function(e){return e.values.length}).length){var k=l.selectAll(".nv-noData").data([E]);return k.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),k.attr("x",u.left+v/2).attr("y",u.top+N/2).text(function(e){return e}),T}l.selectAll(".nv-noData").remove();var L=e.filter(function(e){return!e.disabled&&e.bar}),A=e.filter(function(e){return!e.bar});m=A.filter(function(e){return!e.disabled}).length&&A.filter(function(e){return!e.disabled})[0].values.length?t.xScale():n.xScale(),g=n.yScale(),y=t.yScale();var O=d3.select(this).selectAll("g.nv-wrap.nv-linePlusBar").data([e]),M=O.enter().append("g").attr("class","nvd3 nv-wrap nv-linePlusBar").append("g"),_=O.select("g");M.append("g").attr("class","nv-x nv-axis"),M.append("g").attr("class","nv-y1 nv-axis"),M.append("g").attr("class","nv-y2 nv-axis"),M.append("g").attr("class","nv-barsWrap"),M.append("g").attr("class","nv-linesWrap"),M.append("g").attr("class","nv-legendWrap"),p&&(o.width(v/2),_.select(".nv-legendWrap").datum(e.map(function(e){return e.originalKey=e.originalKey===undefined?e.key:e.originalKey,e.key=e.originalKey+(e.bar?" (left axis)":" (right axis)"),e})).call(o),u.top!=o.height()&&(u.top=o.height(),N=(f||parseInt(l.style("height"))||400)-u.top-u.bottom),_.select(".nv-legendWrap").attr("transform","translate("+v/2+","+ -u.top+")")),O.attr("transform","translate("+u.left+","+u.top+")"),t.width(v).height(N).color(e.map(function(e,t){return e.color||h(e,t)}).filter(function(t,n){return!e[n].disabled&&!e[n].bar})),n.width(v).height(N).color(e.map(function(e,t){return e.color||h(e,t)}).filter(function(t,n){return!e[n].disabled&&e[n].bar}));var D=_.select(".nv-barsWrap").datum(L.length?L:[{values:[]}]),P=_.select(".nv-linesWrap").datum(A[0]&&!A[0].disabled?A:[{values:[]}]);d3.transition(D).call(n),d3.transition(P).call(t),r.scale(m).ticks(v/100).tickSize(-N,0),_.select(".nv-x.nv-axis").attr("transform","translate(0,"+g.range()[0]+")"),d3.transition(_.select(".nv-x.nv-axis")).call(r),i.scale(g).ticks(N/36).tickSize(-v,0),d3.transition(_.select(".nv-y1.nv-axis")).style("opacity",L.length?1:0).call(i),s.scale(y).ticks(N/36).tickSize(L.length?0:-v,0),_.select(".nv-y2.nv-axis").style("opacity",A.length?1:0).attr("transform","translate("+v+",0)"),d3.transition(_.select(".nv-y2.nv-axis")).call(s),o.dispatch.on("stateChange",function(e){b=e,S.stateChange(b),T.update()}),S.on("tooltipShow",function(e){d&&x(e,c.parentNode)}),S.on("changeState",function(t){typeof t.disabled!="undefined"&&(e.forEach(function(e,n){e.disabled=t.disabled[n]}),b.disabled=t.disabled),T.update()})}),T}var t=e.models.line(),n=e.models.historicalBar(),r=e.models.axis(),i=e.models.axis(),s=e.models.axis(),o=e.models.legend(),u={top:30,right:60,bottom:50,left:60},a=null,f=null,l=function(e){return e.x},c=function(e){return e.y},h=e.utils.defaultColor(),p=!0,d=!0,v=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},m,g,y,b={},w=null,E="No Data Available.",S=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState");n.padData(!0),t.clipEdge(!1).padData(!0),r.orient("bottom").tickPadding(7).highlightZero(!1),i.orient("left"),s.orient("right");var x=function(n,o){var u=n.pos[0]+(o.offsetLeft||0),a=n.pos[1]+(o.offsetTop||0),f=r.tickFormat()(t.x()(n.point,n.pointIndex)),l=(n.series.bar?i:s).tickFormat()(t.y()(n.point,n.pointIndex)),c=v(n.series.key,f,l,n,T);e.tooltip.show([u,a],c,n.value<0?"n":"s",null,o)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+u.left,e.pos[1]+u.top],S.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){S.tooltipHide(e)}),n.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+u.left,e.pos[1]+u.top],S.tooltipShow(e)}),n.dispatch.on("elementMouseout.tooltip",function(e){S.tooltipHide(e)}),S.on("tooltipHide",function(){d&&e.tooltip.cleanup()}),T.dispatch=S,T.legend=o,T.lines=t,T.bars=n,T.xAxis=r,T.y1Axis=i,T.y2Axis=s,d3.rebind(T,t,"defined","size","clipVoronoi","interpolate"),T.options=e.utils.optionsFunc.bind(T),T.x=function(e){return arguments.length?(l=e,t.x(e),n.x(e),T):l},T.y=function(e){return arguments.length?(c=e,t.y(e),n.y(e),T):c},T.margin=function(e){return arguments.length?(u.top=typeof e.top!="undefined"?e.top:u.top,u.right=typeof e.right!="undefined"?e.right:u.right,u.bottom=typeof e.bottom!="undefined"?e.bottom:u.bottom,u.left=typeof e.left!="undefined"?e.left:u.left,T):u},T.width=function(e){return arguments.length?(a=e,T):a},T.height=function(e){return arguments.length?(f=e,T):f},T.color=function(t){return arguments.length?(h=e.utils.getColor(t),o.color(h),T):h},T.showLegend=function(e){return arguments.length?(p=e,T):p},T.tooltips=function(e){return arguments.length?(d=e,T):d},T.tooltipContent=function(e){return arguments.length?(v=e,T):v},T.state=function(e){return arguments.length?(b=e,T):b},T.defaultState=function(e){return arguments.length?(w=e,T):w},T.noData=function(e){return arguments.length?(E=e,T):E},T},e.models.lineWithFocusChart=function(){"use strict";function k(e){return e.each(function(e){function U(e){var t=+(e=="e"),n=t?1:-1,r=M/3;return"M"+.5*n+","+r+"A6,6 0 0 "+t+" "+6.5*n+","+(r+6)+"V"+(2*r-6)+"A6,6 0 0 "+t+" "+.5*n+","+2*r+"Z"+"M"+2.5*n+","+(r+8)+"V"+(2*r-8)+"M"+4.5*n+","+(r+8)+"V"+(2*r-8)}function z(){a.empty()||a.extent(w),I.data([a.empty()?g.domain():w]).each(function(e,t){var n=g(e[0])-v.range()[0],r=v.range()[1]-g(e[1]);d3.select(this).select(".left").attr("width",n<0?0:n),d3.select(this).select(".right").attr("x",g(e[1])).attr("width",r<0?0:r)})}function W(){w=a.empty()?null:a.extent();var n=a.empty()?g.domain():a.extent();if(Math.abs(n[0]-n[1])<=1)return;T.brush({extent:n,brush:a}),z();var s=H.select(".nv-focus .nv-linesWrap").datum(e.filter(function(e){return!e.disabled}).map(function(e,r){return{key:e.key,values:e.values.filter(function(e,r){return t.x()(e,r)>=n[0]&&t.x()(e,r)<=n[1]})}}));s.transition().duration(N).call(t),H.select(".nv-focus .nv-x.nv-axis").transition().duration(N).call(r),H.select(".nv-focus .nv-y.nv-axis").transition().duration(N).call(i)}var S=d3.select(this),L=this,A=(h||parseInt(S.style("width"))||960)-f.left-f.right,O=(p||parseInt(S.style("height"))||400)-f.top-f.bottom-d,M=d-l.top-l.bottom;k.update=function(){S.transition().duration(N).call(k)},k.container=this;if(!e||!e.length||!e.filter(function(e){return e.values.length}).length){var _=S.selectAll(".nv-noData").data([x]);return _.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),_.attr("x",f.left+A/2).attr("y",f.top+O/2).text(function(e){return e}),k}S.selectAll(".nv-noData").remove(),v=t.xScale(),m=t.yScale(),g=n.xScale(),y=n.yScale();var D=S.selectAll("g.nv-wrap.nv-lineWithFocusChart").data([e]),P=D.enter().append("g").attr("class","nvd3 nv-wrap nv-lineWithFocusChart").append("g"),H=D.select("g");P.append("g").attr("class","nv-legendWrap");var B=P.append("g").attr("class","nv-focus");B.append("g").attr("class","nv-x nv-axis"),B.append("g").attr("class","nv-y nv-axis"),B.append("g").attr("class","nv-linesWrap");var j=P.append("g").attr("class","nv-context");j.append("g").attr("class","nv-x nv-axis"),j.append("g").attr("class","nv-y nv-axis"),j.append("g").attr("class","nv-linesWrap"),j.append("g").attr("class","nv-brushBackground"),j.append("g").attr("class","nv-x nv-brush"),b&&(u.width(A),H.select(".nv-legendWrap").datum(e).call(u),f.top!=u.height()&&(f.top=u.height(),O=(p||parseInt(S.style("height"))||400)-f.top-f.bottom-d),H.select(".nv-legendWrap").attr("transform","translate(0,"+ -f.top+")")),D.attr("transform","translate("+f.left+","+f.top+")"),t.width(A).height(O).color(e.map(function(e,t){return e.color||c(e,t)}).filter(function(t,n){return!e[n].disabled})),n.defined(t.defined()).width(A).height(M).color(e.map(function(e,t){return e.color||c(e,t)}).filter(function(t,n){return!e[n].disabled})),H.select(".nv-context").attr("transform","translate(0,"+(O+f.bottom+l.top)+")");var F=H.select(".nv-context .nv-linesWrap").datum(e.filter(function(e){return!e.disabled}));d3.transition(F).call(n),r.scale(v).ticks(A/100).tickSize(-O,0),i.scale(m).ticks(O/36).tickSize(-A,0),H.select(".nv-focus .nv-x.nv-axis").attr("transform","translate(0,"+O+")"),a.x(g).on("brush",function(){var e=k.transitionDuration();k.transitionDuration(0),W(),k.transitionDuration(e)}),w&&a.extent(w);var I=H.select(".nv-brushBackground").selectAll("g").data([w||a.extent()]),q=I.enter().append("g");q.append("rect").attr("class","left").attr("x",0).attr("y",0).attr("height",M),q.append("rect").attr("class","right").attr("x",0).attr("y",0).attr("height",M);var R=H.select(".nv-x.nv-brush").call(a);R.selectAll("rect").attr("height",M),R.selectAll(".resize").append("path").attr("d",U),W(),s.scale(g).ticks(A/100).tickSize(-M,0),H.select(".nv-context .nv-x.nv-axis").attr("transform","translate(0,"+y.range()[0]+")"),d3.transition(H.select(".nv-context .nv-x.nv-axis")).call(s),o.scale(y).ticks(M/36).tickSize(-A,0),d3.transition(H.select(".nv-context .nv-y.nv-axis")).call(o),H.select(".nv-context .nv-x.nv-axis").attr("transform","translate(0,"+y.range()[0]+")"),u.dispatch.on("stateChange",function(e){k.update()}),T.on("tooltipShow",function(e){E&&C(e,L.parentNode)})}),k}var t=e.models.line(),n=e.models.line(),r=e.models.axis(),i=e.models.axis(),s=e.models.axis(),o=e.models.axis(),u=e.models.legend(),a=d3.svg.brush(),f={top:30,right:30,bottom:30,left:60},l={top:0,right:30,bottom:20,left:60},c=e.utils.defaultColor(),h=null,p=null,d=100,v,m,g,y,b=!0,w=null,E=!0,S=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},x="No Data Available.",T=d3.dispatch("tooltipShow","tooltipHide","brush"),N=250;t.clipEdge(!0),n.interactive(!1),r.orient("bottom").tickPadding(5),i.orient("left"),s.orient("bottom").tickPadding(5),o.orient("left");var C=function(n,s){var o=n.pos[0]+(s.offsetLeft||0),u=n.pos[1]+(s.offsetTop||0),a=r.tickFormat()(t.x()(n.point,n.pointIndex)),f=i.tickFormat()(t.y()(n.point,n.pointIndex)),l=S(n.series.key,a,f,n,k);e.tooltip.show([o,u],l,null,null,s)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+f.left,e.pos[1]+f.top],T.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){T.tooltipHide(e)}),T.on("tooltipHide",function(){E&&e.tooltip.cleanup()}),k.dispatch=T,k.legend=u,k.lines=t,k.lines2=n,k.xAxis=r,k.yAxis=i,k.x2Axis=s,k.y2Axis=o,d3.rebind(k,t,"defined","isArea","size","xDomain","yDomain","xRange","yRange","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),k.options=e.utils.optionsFunc.bind(k),k.x=function(e){return arguments.length?(t.x(e),n.x(e),k):t.x},k.y=function(e){return arguments.length?(t.y(e),n.y(e),k):t.y},k.margin=function(e){return arguments.length?(f.top=typeof e.top!="undefined"?e.top:f.top,f.right=typeof e.right!="undefined"?e.right:f.right,f.bottom=typeof e.bottom!="undefined"?e.bottom:f.bottom,f.left=typeof e.left!="undefined"?e.left:f.left,k):f},k.margin2=function(e){return arguments.length?(l=e,k):l},k.width=function(e){return arguments.length?(h=e,k):h},k.height=function(e){return arguments.length?(p=e,k):p},k.height2=function(e){return arguments.length?(d=e,k):d},k.color=function(t){return arguments.length?(c=e.utils.getColor(t),u.color(c),k):c},k.showLegend=function(e){return arguments.length?(b=e,k):b},k.tooltips=function(e){return arguments.length?(E=e,k):E},k.tooltipContent=function(e){return arguments.length?(S=e,k):S},k.interpolate=function(e){return arguments.length?(t.interpolate(e),n.interpolate(e),k):t.interpolate()},k.noData=function(e){return arguments.length?(x=e,k):x},k.xTickFormat=function(e){return arguments.length?(r.tickFormat(e),s.tickFormat(e),k):r.tickFormat()},k.yTickFormat=function(e){return arguments.length?(i.tickFormat(e),o.tickFormat(e),k):i.tickFormat()},k.brushExtent=function(e){return arguments.length?(w=e,k):w},k.transitionDuration=function(e){return arguments.length?(N=e,k):N},k},e.models.linePlusBarWithFocusChart=function(){"use strict";function B(e){return e.each(function(e){function nt(e){var t=+(e=="e"),n=t?1:-1,r=q/3;return"M"+.5*n+","+r+"A6,6 0 0 "+t+" "+6.5*n+","+(r+6)+"V"+(2*r-6)+"A6,6 0 0 "+t+" "+.5*n+","+2*r+"Z"+"M"+2.5*n+","+(r+8)+"V"+(2*r-8)+"M"+4.5*n+","+(r+8)+"V"+(2*r-8)}function rt(){h.empty()||h.extent(x),Z.data([h.empty()?k.domain():x]).each(function(e,t){var n=k(e[0])-k.range()[0],r=k.range()[1]-k(e[1]);d3.select(this).select(".left").attr("width",n<0?0:n),d3.select(this).select(".right").attr("x",k(e[1])).attr("width",r<0?0:r)})}function it(){x=h.empty()?null:h.extent(),S=h.empty()?k.domain():h.extent(),D.brush({extent:S,brush:h}),rt(),r.width(F).height(I).color(e.map(function(e,t){return e.color||w(e,t)}).filter(function(t,n){return!e[n].disabled&&e[n].bar})),t.width(F).height(I).color(e.map(function(e,t){return e.color||w(e,t)}).filter(function(t,n){return!e[n].disabled&&!e[n].bar}));var n=J.select(".nv-focus .nv-barsWrap").datum(U.length?U.map(function(e,t){return{key:e.key,values:e.values.filter(function(e,t){return r.x()(e,t)>=S[0]&&r.x()(e,t)<=S[1]})}}):[{values:[]}]),i=J.select(".nv-focus .nv-linesWrap").datum(z[0].disabled?[{values:[]}]:z.map(function(e,n){return{key:e.key,values:e.values.filter(function(e,n){return t.x()(e,n)>=S[0]&&t.x()(e,n)<=S[1]})}}));U.length?C=r.xScale():C=t.xScale(),s.scale(C).ticks(F/100).tickSize(-I,0),s.domain([Math.ceil(S[0]),Math.floor(S[1])]),J.select(".nv-x.nv-axis").transition().duration(P).call(s),n.transition().duration(P).call(r),i.transition().duration(P).call(t),J.select(".nv-focus .nv-x.nv-axis").attr("transform","translate(0,"+L.range()[0]+")"),u.scale(L).ticks(I/36).tickSize(-F,0),J.select(".nv-focus .nv-y1.nv-axis").style("opacity",U.length?1:0),a.scale(A).ticks(I/36).tickSize(U.length?0:-F,0),J.select(".nv-focus .nv-y2.nv-axis").style("opacity",z.length?1:0).attr("transform","translate("+C.range()[1]+",0)"),J.select(".nv-focus .nv-y1.nv-axis").transition().duration(P).call(u),J.select(".nv-focus .nv-y2.nv-axis").transition().duration(P).call(a)}var N=d3.select(this),j=this,F=(v||parseInt(N.style("width"))||960)-p.left-p.right,I=(m||parseInt(N.style("height"))||400)-p.top-p.bottom-g,q=g-d.top-d.bottom;B.update=function(){N.transition().duration(P).call(B)},B.container=this;if(!e||!e.length||!e.filter(function(e){return e.values.length}).length){var R=N.selectAll(".nv-noData").data([_]);return R.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),R.attr("x",p.left+F/2).attr("y",p.top+I/2).text(function(e){return e}),B}N.selectAll(".nv-noData").remove();var U=e.filter(function(e){return!e.disabled&&e.bar}),z=e.filter(function(e){return!e.bar});C=r.xScale(),k=o.scale(),L=r.yScale(),A=t.yScale(),O=i.yScale(),M=n.yScale();var W=e.filter(function(e){return!e.disabled&&e.bar}).map(function(e){return e.values.map(function(e,t){return{x:y(e,t),y:b(e,t)}})}),X=e.filter(function(e){return!e.disabled&&!e.bar}).map(function(e){return e.values.map(function(e,t){return{x:y(e,t),y:b(e,t)}})});C.range([0,F]),k.domain(d3.extent(d3.merge(W.concat(X)),function(e){return e.x})).range([0,F]);var V=N.selectAll("g.nv-wrap.nv-linePlusBar").data([e]),$=V.enter().append("g").attr("class","nvd3 nv-wrap nv-linePlusBar").append("g"),J=V.select("g");$.append("g").attr("class","nv-legendWrap");var K=$.append("g").attr("class","nv-focus");K.append("g").attr("class","nv-x nv-axis"),K.append("g").attr("class","nv-y1 nv-axis"),K.append("g").attr("class","nv-y2 nv-axis"),K.append("g").attr("class","nv-barsWrap"),K.append("g").attr("class","nv-linesWrap");var Q=$.append("g").attr("class","nv-context");Q.append("g").attr("class","nv-x nv-axis"),Q.append("g").attr("class","nv-y1 nv-axis"),Q.append("g").attr("class","nv-y2 nv-axis"),Q.append("g").attr("class","nv-barsWrap"),Q.append("g").attr("class","nv-linesWrap"),Q.append("g").attr("class","nv-brushBackground"),Q.append("g").attr("class","nv-x nv-brush"),E&&(c.width(F/2),J.select(".nv-legendWrap").datum(e.map(function(e){return e.originalKey=e.originalKey===undefined?e.key:e.originalKey,e.key=e.originalKey+(e.bar?" (left axis)":" (right axis)"),e})).call(c),p.top!=c.height()&&(p.top=c.height(),I=(m||parseInt(N.style("height"))||400)-p.top-p.bottom-g),J.select(".nv-legendWrap").attr("transform","translate("+F/2+","+ -p.top+")")),V.attr("transform","translate("+p.left+","+p.top+")"),i.width(F).height(q).color(e.map(function(e,t){return e.color||w(e,t)}).filter(function(t,n){return!e[n].disabled&&e[n].bar})),n.width(F).height(q).color(e.map(function(e,t){return e.color||w(e,t)}).filter(function(t,n){return!e[n].disabled&&!e[n].bar}));var G=J.select(".nv-context .nv-barsWrap").datum(U.length?U:[{values:[]}]),Y=J.select(".nv-context .nv-linesWrap").datum(z[0].disabled?[{values:[]}]:z);J.select(".nv-context").attr("transform","translate(0,"+(I+p.bottom+d.top)+")"),G.transition().call(i),Y.transition().call(n),h.x(k).on("brush",it),x&&h.extent(x);var Z=J.select(".nv-brushBackground").selectAll("g").data([x||h.extent()]),et=Z.enter().append("g");et.append("rect").attr("class","left").attr("x",0).attr("y",0).attr("height",q),et.append("rect").attr("class","right").attr("x",0).attr("y",0).attr("height",q);var tt=J.select(".nv-x.nv-brush").call(h);tt.selectAll("rect").attr("height",q),tt.selectAll(".resize").append("path").attr("d",nt),o.ticks(F/100).tickSize(-q,0),J.select(".nv-context .nv-x.nv-axis").attr("transform","translate(0,"+O.range()[0]+")"),J.select(".nv-context .nv-x.nv-axis").transition().call(o),f.scale(O).ticks(q/36).tickSize(-F,0),J.select(".nv-context .nv-y1.nv-axis").style("opacity",U.length?1:0).attr("transform","translate(0,"+k.range()[0]+")"),J.select(".nv-context .nv-y1.nv-axis").transition().call(f),l.scale(M).ticks(q/36).tickSize(U.length?0:-F,0),J.select(".nv-context .nv-y2.nv-axis").style("opacity",z.length?1:0).attr("transform","translate("+k.range()[1]+",0)"),J.select(".nv-context .nv-y2.nv-axis").transition().call(l),c.dispatch.on("stateChange",function(e){B.update()}),D.on("tooltipShow",function(e){T&&H(e,j.parentNode)}),it()}),B}var t=e.models.line(),n=e.models.line(),r=e.models.historicalBar(),i=e.models.historicalBar(),s=e.models.axis(),o=e.models.axis(),u=e.models.axis(),a=e.models.axis(),f=e.models.axis(),l=e.models.axis(),c=e.models.legend(),h=d3.svg.brush(),p={top:30,right:30,bottom:30,left:60},d={top:0,right:30,bottom:20,left:60},v=null,m=null,g=100,y=function(e){return e.x},b=function(e){return e.y},w=e.utils.defaultColor(),E=!0,S,x=null,T=!0,N=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},C,k,L,A,O,M,_="No Data Available.",D=d3.dispatch("tooltipShow","tooltipHide","brush"),P=0;t.clipEdge(!0),n.interactive(!1),s.orient("bottom").tickPadding(5),u.orient("left"),a.orient("right"),o.orient("bottom").tickPadding(5),f.orient("left"),l.orient("right");var H=function(n,r){S&&(n.pointIndex+=Math.ceil(S[0]));var i=n.pos[0]+(r.offsetLeft||0),o=n.pos[1]+(r.offsetTop||0),f=s.tickFormat()(t.x()(n.point,n.pointIndex)),l=(n.series.bar?u:a).tickFormat()(t.y()(n.point,n.pointIndex)),c=N(n.series.key,f,l,n,B);e.tooltip.show([i,o],c,n.value<0?"n":"s",null,r)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+p.left,e.pos[1]+p.top],D.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){D.tooltipHide(e)}),r.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+p.left,e.pos[1]+p.top],D.tooltipShow(e)}),r.dispatch.on("elementMouseout.tooltip",function(e){D.tooltipHide(e)}),D.on("tooltipHide",function(){T&&e.tooltip.cleanup()}),B.dispatch=D,B.legend=c,B.lines=t,B.lines2=n,B.bars=r,B.bars2=i,B.xAxis=s,B.x2Axis=o,B.y1Axis=u,B.y2Axis=a,B.y3Axis=f,B.y4Axis=l,d3.rebind(B,t,"defined","size","clipVoronoi","interpolate"),B.options=e.utils.optionsFunc.bind(B),B.x=function(e){return arguments.length?(y=e,t.x(e),r.x(e),B):y},B.y=function(e){return arguments.length?(b=e,t.y(e),r.y(e),B):b},B.margin=function(e){return arguments.length?(p.top=typeof e.top!="undefined"?e.top:p.top,p.right=typeof e.right!="undefined"?e.right:p.right,p.bottom=typeof e.bottom!="undefined"?e.bottom:p.bottom,p.left=typeof e.left!="undefined"?e.left:p.left,B):p},B.width=function(e){return arguments.length?(v=e,B):v},B.height=function(e){return arguments.length?(m=e,B):m},B.color=function(t){return arguments.length?(w=e.utils.getColor(t),c.color(w),B):w},B.showLegend=function(e){return arguments.length?(E=e,B):E},B.tooltips=function(e){return arguments.length?(T=e,B):T},B.tooltipContent=function(e){return arguments.length?(N=e,B):N},B.noData=function(e){return arguments.length?(_=e,B):_},B.brushExtent=function(e){return arguments.length?(x=e,B):x},B},e.models.multiBar=function(){"use strict";function C(e){return e.each(function(e){var C=n-t.left-t.right,k=r-t.top-t.bottom,L=d3.select(this);d&&e.length&&(d=[{values:e[0].values.map(function(e){return{x:e.x,y:0,series:e.series,size:.01}})}]),c&&(e=d3.layout.stack().offset(h).values(function(e){return e.values}).y(a)(!e.length&&d?d:e)),e.forEach(function(e,t){e.values.forEach(function(e){e.series=t})}),c&&e[0].values.map(function(t,n){var r=0,i=0;e.map(function(e){var t=e.values[n];t.size=Math.abs(t.y),t.y<0?(t.y1=i,i-=t.size):(t.y1=t.size+r,r+=t.size)})});var A=y&&b?[]:e.map(function(e){return e.values.map(function(e,t){return{x:u(e,t),y:a(e,t),y0:e.y0,y1:e.y1}})});i.domain(y||d3.merge(A).map(function(e){return e.x})).rangeBands(w||[0,C],S),s.domain(b||d3.extent(d3.merge(A).map(function(e){return c?e.y>0?e.y1:e.y1+e.y:e.y}).concat(f))).range(E||[k,0]),i.domain()[0]===i.domain()[1]&&(i.domain()[0]?i.domain([i.domain()[0]-i.domain()[0]*.01,i.domain()[1]+i.domain()[1]*.01]):i.domain([-1,1])),s.domain()[0]===s.domain()[1]&&(s.domain()[0]?s.domain([s.domain()[0]+s.domain()[0]*.01,s.domain()[1]-s.domain()[1]*.01]):s.domain([-1,1])),T=T||i,N=N||s;var O=L.selectAll("g.nv-wrap.nv-multibar").data([e]),M=O.enter().append("g").attr("class","nvd3 nv-wrap nv-multibar"),_=M.append("defs"),D=M.append("g"),P=O.select("g");D.append("g").attr("class","nv-groups"),O.attr("transform","translate("+t.left+","+t.top+")"),_.append("clipPath").attr("id","nv-edge-clip-"+o).append("rect"),O.select("#nv-edge-clip-"+o+" rect").attr("width",C).attr("height",k),P.attr("clip-path",l?"url(#nv-edge-clip-"+o+")":"");var H=O.select(".nv-groups").selectAll(".nv-group").data(function(e){return e},function(e,t){return t});H.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),H.exit().transition().selectAll("rect.nv-bar").delay(function(t,n){return n*g/e[0].values.length}).attr("y",function(e){return c?N(e.y0):N(0)}).attr("height",0).remove(),H.attr("class",function(e,t){return"nv-group nv-series-"+t}).classed("hover",function(e){return e.hover}).style("fill",function(e,t){return p(e,t)}).style("stroke",function(e,t){return p(e,t)}),H.transition().style("stroke-opacity",1).style("fill-opacity",.75);var B=H.selectAll("rect.nv-bar").data(function(t){return d&&!e.length?d.values:t.values});B.exit().remove();var j=B.enter().append("rect").attr("class",function(e,t){return a(e,t)<0?"nv-bar negative":"nv-bar positive"}).attr("x",function(t,n,r){return c?0:r*i.rangeBand()/e.length}).attr("y",function(e){return N(c?e.y0:0)}).attr("height",0).attr("width",i.rangeBand()/(c?1:e.length)).attr("transform",function(e,t){return"translate("+i(u(e,t))+",0)"});B.style("fill",function(e,t,n){return p(e,n,t)}).style("stroke",function(e,t,n){return p(e,n,t)}).on("mouseover",function(t,n){d3.select(this).classed("hover",!0),x.elementMouseover({value:a(t,n),point:t,series:e[t.series],pos:[i(u(t,n))+i.rangeBand()*(c?e.length/2:t.series+.5)/e.length,s(a(t,n)+(c?t.y0:0))],pointIndex:n,seriesIndex:t.series,e:d3.event})}).on("mouseout",function(t,n){d3.select(this).classed("hover",!1),x.elementMouseout({value:a(t,n),point:t,series:e[t.series],pointIndex:n,seriesIndex:t.series,e:d3.event})}).on("click",function(t,n){x.elementClick({value:a(t,n),point:t,series:e[t.series],pos:[i(u(t,n))+i.rangeBand()*(c?e.length/2:t.series+.5)/e.length,s(a(t,n)+(c?t.y0:0))],pointIndex:n,seriesIndex:t.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(t,n){x.elementDblClick({value:a(t,n),point:t,series:e[t.series],pos:[i(u(t,n))+i.rangeBand()*(c?e.length/2:t.series+.5)/e.length,s(a(t,n)+(c?t.y0:0))],pointIndex:n,seriesIndex:t.series,e:d3.event}),d3.event.stopPropagation() -}),B.attr("class",function(e,t){return a(e,t)<0?"nv-bar negative":"nv-bar positive"}).transition().attr("transform",function(e,t){return"translate("+i(u(e,t))+",0)"}),v&&(m||(m=e.map(function(){return!0})),B.style("fill",function(e,t,n){return d3.rgb(v(e,t)).darker(m.map(function(e,t){return t}).filter(function(e,t){return!m[t]})[n]).toString()}).style("stroke",function(e,t,n){return d3.rgb(v(e,t)).darker(m.map(function(e,t){return t}).filter(function(e,t){return!m[t]})[n]).toString()})),c?B.transition().delay(function(t,n){return n*g/e[0].values.length}).attr("y",function(e,t){return s(c?e.y1:0)}).attr("height",function(e,t){return Math.max(Math.abs(s(e.y+(c?e.y0:0))-s(c?e.y0:0)),1)}).attr("x",function(t,n){return c?0:t.series*i.rangeBand()/e.length}).attr("width",i.rangeBand()/(c?1:e.length)):B.transition().delay(function(t,n){return n*g/e[0].values.length}).attr("x",function(t,n){return t.series*i.rangeBand()/e.length}).attr("width",i.rangeBand()/e.length).attr("y",function(e,t){return a(e,t)<0?s(0):s(0)-s(a(e,t))<1?s(0)-1:s(a(e,t))||0}).attr("height",function(e,t){return Math.max(Math.abs(s(a(e,t))-s(0)),1)||0}),T=i.copy(),N=s.copy()}),C}var t={top:0,right:0,bottom:0,left:0},n=960,r=500,i=d3.scale.ordinal(),s=d3.scale.linear(),o=Math.floor(Math.random()*1e4),u=function(e){return e.x},a=function(e){return e.y},f=[0],l=!0,c=!1,h="zero",p=e.utils.defaultColor(),d=!1,v=null,m,g=1200,y,b,w,E,S=.1,x=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout"),T,N;return C.dispatch=x,C.options=e.utils.optionsFunc.bind(C),C.x=function(e){return arguments.length?(u=e,C):u},C.y=function(e){return arguments.length?(a=e,C):a},C.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,C):t},C.width=function(e){return arguments.length?(n=e,C):n},C.height=function(e){return arguments.length?(r=e,C):r},C.xScale=function(e){return arguments.length?(i=e,C):i},C.yScale=function(e){return arguments.length?(s=e,C):s},C.xDomain=function(e){return arguments.length?(y=e,C):y},C.yDomain=function(e){return arguments.length?(b=e,C):b},C.xRange=function(e){return arguments.length?(w=e,C):w},C.yRange=function(e){return arguments.length?(E=e,C):E},C.forceY=function(e){return arguments.length?(f=e,C):f},C.stacked=function(e){return arguments.length?(c=e,C):c},C.stackOffset=function(e){return arguments.length?(h=e,C):h},C.clipEdge=function(e){return arguments.length?(l=e,C):l},C.color=function(t){return arguments.length?(p=e.utils.getColor(t),C):p},C.barColor=function(t){return arguments.length?(v=e.utils.getColor(t),C):v},C.disabled=function(e){return arguments.length?(m=e,C):m},C.id=function(e){return arguments.length?(o=e,C):o},C.hideable=function(e){return arguments.length?(d=e,C):d},C.delay=function(e){return arguments.length?(g=e,C):g},C.groupSpacing=function(e){return arguments.length?(S=e,C):S},C},e.models.multiBarChart=function(){"use strict";function A(e){return e.each(function(e){var b=d3.select(this),O=this,M=(u||parseInt(b.style("width"))||960)-o.left-o.right,_=(a||parseInt(b.style("height"))||400)-o.top-o.bottom;A.update=function(){b.transition().duration(k).call(A)},A.container=this,S.disabled=e.map(function(e){return!!e.disabled});if(!x){var D;x={};for(D in S)S[D]instanceof Array?x[D]=S[D].slice(0):x[D]=S[D]}if(!e||!e.length||!e.filter(function(e){return e.values.length}).length){var P=b.selectAll(".nv-noData").data([T]);return P.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),P.attr("x",o.left+M/2).attr("y",o.top+_/2).text(function(e){return e}),A}b.selectAll(".nv-noData").remove(),w=t.xScale(),E=t.yScale();var H=b.selectAll("g.nv-wrap.nv-multiBarWithLegend").data([e]),B=H.enter().append("g").attr("class","nvd3 nv-wrap nv-multiBarWithLegend").append("g"),j=H.select("g");B.append("g").attr("class","nv-x nv-axis"),B.append("g").attr("class","nv-y nv-axis"),B.append("g").attr("class","nv-barsWrap"),B.append("g").attr("class","nv-legendWrap"),B.append("g").attr("class","nv-controlsWrap"),c&&(i.width(M-C()),t.barColor()&&e.forEach(function(e,t){e.color=d3.rgb("#ccc").darker(t*1.5).toString()}),j.select(".nv-legendWrap").datum(e).call(i),o.top!=i.height()&&(o.top=i.height(),_=(a||parseInt(b.style("height"))||400)-o.top-o.bottom),j.select(".nv-legendWrap").attr("transform","translate("+C()+","+ -o.top+")"));if(l){var F=[{key:"Grouped",disabled:t.stacked()},{key:"Stacked",disabled:!t.stacked()}];s.width(C()).color(["#444","#444","#444"]),j.select(".nv-controlsWrap").datum(F).attr("transform","translate(0,"+ -o.top+")").call(s)}H.attr("transform","translate("+o.left+","+o.top+")"),d&&j.select(".nv-y.nv-axis").attr("transform","translate("+M+",0)"),t.disabled(e.map(function(e){return e.disabled})).width(M).height(_).color(e.map(function(e,t){return e.color||f(e,t)}).filter(function(t,n){return!e[n].disabled}));var I=j.select(".nv-barsWrap").datum(e.filter(function(e){return!e.disabled}));I.transition().call(t);if(h){n.scale(w).ticks(M/100).tickSize(-_,0),j.select(".nv-x.nv-axis").attr("transform","translate(0,"+E.range()[0]+")"),j.select(".nv-x.nv-axis").transition().call(n);var q=j.select(".nv-x.nv-axis > g").selectAll("g");q.selectAll("line, text").style("opacity",1);if(m){var R=function(e,t){return"translate("+e+","+t+")"},U=5,z=17;q.selectAll("text").attr("transform",function(e,t,n){return R(0,n%2==0?U:z)});var W=d3.selectAll(".nv-x.nv-axis .nv-wrap g g text")[0].length;j.selectAll(".nv-x.nv-axis .nv-axisMaxMin text").attr("transform",function(e,t){return R(0,t===0||W%2!==0?z:U)})}v&&q.filter(function(t,n){return n%Math.ceil(e[0].values.length/(M/100))!==0}).selectAll("text, line").style("opacity",0),g&&q.selectAll(".tick text").attr("transform","rotate("+g+" 0,0)").style("text-anchor",g>0?"start":"end"),j.select(".nv-x.nv-axis").selectAll("g.nv-axisMaxMin text").style("opacity",1)}p&&(r.scale(E).ticks(_/36).tickSize(-M,0),j.select(".nv-y.nv-axis").transition().call(r)),i.dispatch.on("stateChange",function(e){S=e,N.stateChange(S),A.update()}),s.dispatch.on("legendClick",function(e,n){if(!e.disabled)return;F=F.map(function(e){return e.disabled=!0,e}),e.disabled=!1;switch(e.key){case"Grouped":t.stacked(!1);break;case"Stacked":t.stacked(!0)}S.stacked=t.stacked(),N.stateChange(S),A.update()}),N.on("tooltipShow",function(e){y&&L(e,O.parentNode)}),N.on("changeState",function(n){typeof n.disabled!="undefined"&&(e.forEach(function(e,t){e.disabled=n.disabled[t]}),S.disabled=n.disabled),typeof n.stacked!="undefined"&&(t.stacked(n.stacked),S.stacked=n.stacked),A.update()})}),A}var t=e.models.multiBar(),n=e.models.axis(),r=e.models.axis(),i=e.models.legend(),s=e.models.legend(),o={top:30,right:20,bottom:50,left:60},u=null,a=null,f=e.utils.defaultColor(),l=!0,c=!0,h=!0,p=!0,d=!1,v=!0,m=!1,g=0,y=!0,b=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" on "+t+"

"},w,E,S={stacked:!1},x=null,T="No Data Available.",N=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),C=function(){return l?180:0},k=250;t.stacked(!1),n.orient("bottom").tickPadding(7).highlightZero(!0).showMaxMin(!1).tickFormat(function(e){return e}),r.orient(d?"right":"left").tickFormat(d3.format(",.1f")),s.updateState(!1);var L=function(i,s){var o=i.pos[0]+(s.offsetLeft||0),u=i.pos[1]+(s.offsetTop||0),a=n.tickFormat()(t.x()(i.point,i.pointIndex)),f=r.tickFormat()(t.y()(i.point,i.pointIndex)),l=b(i.series.key,a,f,i,A);e.tooltip.show([o,u],l,i.value<0?"n":"s",null,s)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+o.left,e.pos[1]+o.top],N.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){N.tooltipHide(e)}),N.on("tooltipHide",function(){y&&e.tooltip.cleanup()}),A.dispatch=N,A.multibar=t,A.legend=i,A.xAxis=n,A.yAxis=r,d3.rebind(A,t,"x","y","xDomain","yDomain","xRange","yRange","forceX","forceY","clipEdge","id","stacked","stackOffset","delay","barColor","groupSpacing"),A.options=e.utils.optionsFunc.bind(A),A.margin=function(e){return arguments.length?(o.top=typeof e.top!="undefined"?e.top:o.top,o.right=typeof e.right!="undefined"?e.right:o.right,o.bottom=typeof e.bottom!="undefined"?e.bottom:o.bottom,o.left=typeof e.left!="undefined"?e.left:o.left,A):o},A.width=function(e){return arguments.length?(u=e,A):u},A.height=function(e){return arguments.length?(a=e,A):a},A.color=function(t){return arguments.length?(f=e.utils.getColor(t),i.color(f),A):f},A.showControls=function(e){return arguments.length?(l=e,A):l},A.showLegend=function(e){return arguments.length?(c=e,A):c},A.showXAxis=function(e){return arguments.length?(h=e,A):h},A.showYAxis=function(e){return arguments.length?(p=e,A):p},A.rightAlignYAxis=function(e){return arguments.length?(d=e,r.orient(e?"right":"left"),A):d},A.reduceXTicks=function(e){return arguments.length?(v=e,A):v},A.rotateLabels=function(e){return arguments.length?(g=e,A):g},A.staggerLabels=function(e){return arguments.length?(m=e,A):m},A.tooltip=function(e){return arguments.length?(b=e,A):b},A.tooltips=function(e){return arguments.length?(y=e,A):y},A.tooltipContent=function(e){return arguments.length?(b=e,A):b},A.state=function(e){return arguments.length?(S=e,A):S},A.defaultState=function(e){return arguments.length?(x=e,A):x},A.noData=function(e){return arguments.length?(T=e,A):T},A.transitionDuration=function(e){return arguments.length?(k=e,A):k},A},e.models.multiBarHorizontal=function(){"use strict";function N(e){return e.each(function(e){var i=n-t.left-t.right,g=r-t.top-t.bottom,N=d3.select(this);p&&(e=d3.layout.stack().offset("zero").values(function(e){return e.values}).y(a)(e)),e.forEach(function(e,t){e.values.forEach(function(e){e.series=t})}),p&&e[0].values.map(function(t,n){var r=0,i=0;e.map(function(e){var t=e.values[n];t.size=Math.abs(t.y),t.y<0?(t.y1=i-t.size,i-=t.size):(t.y1=r,r+=t.size)})});var C=y&&b?[]:e.map(function(e){return e.values.map(function(e,t){return{x:u(e,t),y:a(e,t),y0:e.y0,y1:e.y1}})});s.domain(y||d3.merge(C).map(function(e){return e.x})).rangeBands(w||[0,g],.1),o.domain(b||d3.extent(d3.merge(C).map(function(e){return p?e.y>0?e.y1+e.y:e.y1:e.y}).concat(f))),d&&!p?o.range(E||[o.domain()[0]<0?v:0,i-(o.domain()[1]>0?v:0)]):o.range(E||[0,i]),x=x||s,T=T||d3.scale.linear().domain(o.domain()).range([o(0),o(0)]);var k=d3.select(this).selectAll("g.nv-wrap.nv-multibarHorizontal").data([e]),L=k.enter().append("g").attr("class","nvd3 nv-wrap nv-multibarHorizontal"),A=L.append("defs"),O=L.append("g"),M=k.select("g");O.append("g").attr("class","nv-groups"),k.attr("transform","translate("+t.left+","+t.top+")");var _=k.select(".nv-groups").selectAll(".nv-group").data(function(e){return e},function(e,t){return t});_.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),_.exit().transition().style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),_.attr("class",function(e,t){return"nv-group nv-series-"+t}).classed("hover",function(e){return e.hover}).style("fill",function(e,t){return l(e,t)}).style("stroke",function(e,t){return l(e,t)}),_.transition().style("stroke-opacity",1).style("fill-opacity",.75);var D=_.selectAll("g.nv-bar").data(function(e){return e.values});D.exit().remove();var P=D.enter().append("g").attr("transform",function(t,n,r){return"translate("+T(p?t.y0:0)+","+(p?0:r*s.rangeBand()/e.length+s(u(t,n)))+")"});P.append("rect").attr("width",0).attr("height",s.rangeBand()/(p?1:e.length)),D.on("mouseover",function(t,n){d3.select(this).classed("hover",!0),S.elementMouseover({value:a(t,n),point:t,series:e[t.series],pos:[o(a(t,n)+(p?t.y0:0)),s(u(t,n))+s.rangeBand()*(p?e.length/2:t.series+.5)/e.length],pointIndex:n,seriesIndex:t.series,e:d3.event})}).on("mouseout",function(t,n){d3.select(this).classed("hover",!1),S.elementMouseout({value:a(t,n),point:t,series:e[t.series],pointIndex:n,seriesIndex:t.series,e:d3.event})}).on("click",function(t,n){S.elementClick({value:a(t,n),point:t,series:e[t.series],pos:[s(u(t,n))+s.rangeBand()*(p?e.length/2:t.series+.5)/e.length,o(a(t,n)+(p?t.y0:0))],pointIndex:n,seriesIndex:t.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(t,n){S.elementDblClick({value:a(t,n),point:t,series:e[t.series],pos:[s(u(t,n))+s.rangeBand()*(p?e.length/2:t.series+.5)/e.length,o(a(t,n)+(p?t.y0:0))],pointIndex:n,seriesIndex:t.series,e:d3.event}),d3.event.stopPropagation()}),P.append("text"),d&&!p?(D.select("text").attr("text-anchor",function(e,t){return a(e,t)<0?"end":"start"}).attr("y",s.rangeBand()/(e.length*2)).attr("dy",".32em").text(function(e,t){return m(a(e,t))}),D.transition().select("text").attr("x",function(e,t){return a(e,t)<0?-4:o(a(e,t))-o(0)+4})):D.selectAll("text").text(""),D.attr("class",function(e,t){return a(e,t)<0?"nv-bar negative":"nv-bar positive"}),c&&(h||(h=e.map(function(){return!0})),D.style("fill",function(e,t,n){return d3.rgb(c(e,t)).darker(h.map(function(e,t){return t}).filter(function(e,t){return!h[t]})[n]).toString()}).style("stroke",function(e,t,n){return d3.rgb(c(e,t)).darker(h.map(function(e,t){return t}).filter(function(e,t){return!h[t]})[n]).toString()})),p?D.transition().attr("transform",function(e,t){return"translate("+o(e.y1)+","+s(u(e,t))+")"}).select("rect").attr("width",function(e,t){return Math.abs(o(a(e,t)+e.y0)-o(e.y0))}).attr("height",s.rangeBand()):D.transition().attr("transform",function(t,n){return"translate("+(a(t,n)<0?o(a(t,n)):o(0))+","+(t.series*s.rangeBand()/e.length+s(u(t,n)))+")"}).select("rect").attr("height",s.rangeBand()/e.length).attr("width",function(e,t){return Math.max(Math.abs(o(a(e,t))-o(0)),1)}),x=s.copy(),T=o.copy()}),N}var t={top:0,right:0,bottom:0,left:0},n=960,r=500,i=Math.floor(Math.random()*1e4),s=d3.scale.ordinal(),o=d3.scale.linear(),u=function(e){return e.x},a=function(e){return e.y},f=[0],l=e.utils.defaultColor(),c=null,h,p=!1,d=!1,v=60,m=d3.format(",.2f"),g=1200,y,b,w,E,S=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout"),x,T;return N.dispatch=S,N.options=e.utils.optionsFunc.bind(N),N.x=function(e){return arguments.length?(u=e,N):u},N.y=function(e){return arguments.length?(a=e,N):a},N.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,N):t},N.width=function(e){return arguments.length?(n=e,N):n},N.height=function(e){return arguments.length?(r=e,N):r},N.xScale=function(e){return arguments.length?(s=e,N):s},N.yScale=function(e){return arguments.length?(o=e,N):o},N.xDomain=function(e){return arguments.length?(y=e,N):y},N.yDomain=function(e){return arguments.length?(b=e,N):b},N.xRange=function(e){return arguments.length?(w=e,N):w},N.yRange=function(e){return arguments.length?(E=e,N):E},N.forceY=function(e){return arguments.length?(f=e,N):f},N.stacked=function(e){return arguments.length?(p=e,N):p},N.color=function(t){return arguments.length?(l=e.utils.getColor(t),N):l},N.barColor=function(t){return arguments.length?(c=e.utils.getColor(t),N):c},N.disabled=function(e){return arguments.length?(h=e,N):h},N.id=function(e){return arguments.length?(i=e,N):i},N.delay=function(e){return arguments.length?(g=e,N):g},N.showValues=function(e){return arguments.length?(d=e,N):d},N.valueFormat=function(e){return arguments.length?(m=e,N):m},N.valuePadding=function(e){return arguments.length?(v=e,N):v},N},e.models.multiBarHorizontalChart=function(){"use strict";function T(e){return e.each(function(h){var d=d3.select(this),N=this,C=(u||parseInt(d.style("width"))||960)-o.left-o.right,k=(a||parseInt(d.style("height"))||400)-o.top-o.bottom;T.update=function(){d.transition().duration(S).call(T)},T.container=this,g.disabled=h.map(function(e){return!!e.disabled});if(!y){var L;y={};for(L in g)g[L]instanceof Array?y[L]=g[L].slice(0):y[L]=g[L]}if(!h||!h.length||!h.filter(function(e){return e.values.length}).length){var A=d.selectAll(".nv-noData").data([b]);return A.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),A.attr("x",o.left+C/2).attr("y",o.top+k/2).text(function(e){return e}),T}d.selectAll(".nv-noData").remove(),v=t.xScale(),m=t.yScale();var O=d.selectAll("g.nv-wrap.nv-multiBarHorizontalChart").data([h]),M=O.enter().append("g").attr("class","nvd3 nv-wrap nv-multiBarHorizontalChart").append("g"),_=O.select("g");M.append("g").attr("class","nv-x nv-axis"),M.append("g").attr("class","nv-y nv-axis"),M.append("g").attr("class","nv-barsWrap"),M.append("g").attr("class","nv-legendWrap"),M.append("g").attr("class","nv-controlsWrap"),c&&(i.width(C-E()),t.barColor()&&h.forEach(function(e,t){e.color=d3.rgb("#ccc").darker(t*1.5).toString()}),_.select(".nv-legendWrap").datum(h).call(i),o.top!=i.height()&&(o.top=i.height(),k=(a||parseInt(d.style("height"))||400)-o.top-o.bottom),_.select(".nv-legendWrap").attr("transform","translate("+E()+","+ -o.top+")"));if(l){var D=[{key:"Grouped",disabled:t.stacked()},{key:"Stacked",disabled:!t.stacked()}];s.width(E()).color(["#444","#444","#444"]),_.select(".nv-controlsWrap").datum(D).attr("transform","translate(0,"+ -o.top+")").call(s)}O.attr("transform","translate("+o.left+","+o.top+")"),t.disabled(h.map(function(e){return e.disabled})).width(C).height(k).color(h.map(function(e,t){return e.color||f(e,t)}).filter(function(e,t){return!h[t].disabled}));var P=_.select(".nv-barsWrap").datum(h.filter(function(e){return!e.disabled}));P.transition().call(t),n.scale(v).ticks(k/24).tickSize(-C,0),_.select(".nv-x.nv-axis").transition().call(n);var H=_.select(".nv-x.nv-axis").selectAll("g");H.selectAll("line, text").style("opacity",1),r.scale(m).ticks(C/100).tickSize(-k,0),_.select(".nv-y.nv-axis").attr("transform","translate(0,"+k+")"),_.select(".nv-y.nv-axis").transition().call(r),i.dispatch.on("stateChange",function(e){g=e,w.stateChange(g),T.update()}),s.dispatch.on("legendClick",function(e,n){if(!e.disabled)return;D=D.map(function(e){return e.disabled=!0,e}),e.disabled=!1;switch(e.key){case"Grouped":t.stacked(!1);break;case"Stacked":t.stacked(!0)}g.stacked=t.stacked(),w.stateChange(g),T.update()}),w.on("tooltipShow",function(e){p&&x(e,N.parentNode)}),w.on("changeState",function(n){typeof n.disabled!="undefined"&&(h.forEach(function(e,t){e.disabled=n.disabled[t]}),g.disabled=n.disabled),typeof n.stacked!="undefined"&&(t.stacked(n.stacked),g.stacked=n.stacked),e.call(T)})}),T}var t=e.models.multiBarHorizontal(),n=e.models.axis(),r=e.models.axis(),i=e.models.legend().height(30),s=e.models.legend().height(30),o={top:30,right:20,bottom:50,left:60},u=null,a=null,f=e.utils.defaultColor(),l=!0,c=!0,h=!1,p=!0,d=function(e,t,n,r,i){return"

"+e+" - "+t+"

"+"

"+n+"

"},v,m,g={stacked:h},y=null,b="No Data Available.",w=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),E=function(){return l?180:0},S=250;t.stacked(h),n.orient("left").tickPadding(5).highlightZero(!1).showMaxMin(!1).tickFormat(function(e){return e}),r.orient("bottom").tickFormat(d3.format(",.1f")),s.updateState(!1);var x=function(i,s){var o=i.pos[0]+(s.offsetLeft||0),u=i.pos[1]+(s.offsetTop||0),a=n.tickFormat()(t.x()(i.point,i.pointIndex)),f=r.tickFormat()(t.y()(i.point,i.pointIndex)),l=d(i.series.key,a,f,i,T);e.tooltip.show([o,u],l,i.value<0?"e":"w",null,s)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+o.left,e.pos[1]+o.top],w.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){w.tooltipHide(e)}),w.on("tooltipHide",function(){p&&e.tooltip.cleanup()}),T.dispatch=w,T.multibar=t,T.legend=i,T.xAxis=n,T.yAxis=r,d3.rebind(T,t,"x","y","xDomain","yDomain","xRange","yRange","forceX","forceY","clipEdge","id","delay","showValues","valueFormat","stacked","barColor"),T.options=e.utils.optionsFunc.bind(T),T.margin=function(e){return arguments.length?(o.top=typeof e.top!="undefined"?e.top:o.top,o.right=typeof e.right!="undefined"?e.right:o.right,o.bottom=typeof e.bottom!="undefined"?e.bottom:o.bottom,o.left=typeof e.left!="undefined"?e.left:o.left,T):o},T.width=function(e){return arguments.length?(u=e,T):u},T.height=function(e){return arguments.length?(a=e,T):a},T.color=function(t){return arguments.length?(f=e.utils.getColor(t),i.color(f),T):f},T.showControls=function(e){return arguments.length?(l=e,T):l},T.showLegend=function(e){return arguments.length?(c=e,T):c},T.tooltip=function(e){return arguments.length?(d=e,T):d},T.tooltips=function(e){return arguments.length?(p=e,T):p},T.tooltipContent=function(e){return arguments.length?(d=e,T):d},T.state=function(e){return arguments.length?(g=e,T):g},T.defaultState=function(e){return arguments.length?(y=e,T):y},T.noData=function(e){return arguments.length?(b=e,T):b},T.transitionDuration=function(e){return arguments.length?(S=e,T):S},T},e.models.multiChart=function(){"use strict";function C(e){return e.each(function(e){var u=d3.select(this),f=this;C.update=function(){u.transition().call(C)},C.container=this;var k=(r||parseInt(u.style("width"))||960)-t.left-t.right,L=(i||parseInt(u.style("height"))||400)-t.top-t.bottom,A=e.filter(function(e){return!e.disabled&&e.type=="line"&&e.yAxis==1}),O=e.filter(function(e){return!e.disabled&&e.type=="line"&&e.yAxis==2}),M=e.filter(function(e){return!e.disabled&&e.type=="bar"&&e.yAxis==1}),_=e.filter(function(e){return!e.disabled&&e.type=="bar"&&e.yAxis==2}),D=e.filter(function(e){return!e.disabled&&e.type=="area"&&e.yAxis==1}),P=e.filter(function(e){return!e.disabled&&e.type=="area"&&e.yAxis==2}),H=e.filter(function(e){return!e.disabled&&e.yAxis==1}).map(function(e){return e.values.map(function(e,t){return{x:e.x,y:e.y}})}),B=e.filter(function(e){return!e.disabled&&e.yAxis==2}).map(function(e){return e.values.map(function(e,t){return{x:e.x,y:e.y}})});a.domain(d3.extent(d3.merge(H.concat(B)),function(e){return e.x})).range([0,k]);var j=u.selectAll("g.wrap.multiChart").data([e]),F=j.enter().append("g").attr("class","wrap nvd3 multiChart").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","lines1Wrap"),F.append("g").attr("class","lines2Wrap"),F.append("g").attr("class","bars1Wrap"),F.append("g").attr("class","bars2Wrap"),F.append("g").attr("class","stack1Wrap"),F.append("g").attr("class","stack2Wrap"),F.append("g").attr("class","legendWrap");var I=j.select("g");s&&(x.width(k/2),I.select(".legendWrap").datum(e.map(function(e){return e.originalKey=e.originalKey===undefined?e.key:e.originalKey,e.key=e.originalKey+(e.yAxis==1?"":" (right axis)"),e})).call(x),t.top!=x.height()&&(t.top=x.height(),L=(i||parseInt(u.style("height"))||400)-t.top-t.bottom),I.select(".legendWrap").attr("transform","translate("+k/2+","+ -t.top+")")),d.width(k).height(L).interpolate("monotone").color(e.map(function(e,t){return e.color||n[t%n.length]}).filter(function(t,n){return!e[n].disabled&&e[n].yAxis==1&&e[n].type=="line"})),v.width(k).height(L).interpolate("monotone").color(e.map(function(e,t){return e.color||n[t%n.length]}).filter(function(t,n){return!e[n].disabled&&e[n].yAxis==2&&e[n].type=="line"})),m.width(k).height(L).color(e.map(function(e,t){return e.color||n[t%n.length]}).filter(function(t,n){return!e[n].disabled&&e[n].yAxis==1&&e[n].type=="bar"})),g.width(k).height(L).color(e.map(function(e,t){return e.color||n[t%n.length]}).filter(function(t,n){return!e[n].disabled&&e[n].yAxis==2&&e[n].type=="bar"})),y.width(k).height(L).color(e.map(function(e,t){return e.color||n[t%n.length]}).filter(function(t,n){return!e[n].disabled&&e[n].yAxis==1&&e[n].type=="area"})),b.width(k).height(L).color(e.map(function(e,t){return e.color||n[t%n.length]}).filter(function(t,n){return!e[n].disabled&&e[n].yAxis==2&&e[n].type=="area"})),I.attr("transform","translate("+t.left+","+t.top+")");var q=I.select(".lines1Wrap").datum(A),R=I.select(".bars1Wrap").datum(M),U=I.select(".stack1Wrap").datum(D),z=I.select(".lines2Wrap").datum(O),W=I.select(".bars2Wrap").datum(_),X=I.select(".stack2Wrap").datum(P),V=D.length?D.map(function(e){return e.values}).reduce(function(e,t){return e.map(function(e,n){return{x:e.x,y:e.y+t[n].y}})}).concat([{x:0,y:0}]):[],$=P.length?P.map(function(e){return e.values}).reduce(function(e,t){return e.map(function(e,n){return{x:e.x,y:e.y+t[n].y}})}).concat([{x:0,y:0}]):[];h.domain(l||d3.extent(d3.merge(H).concat(V),function(e){return e.y})).range([0,L]),p.domain(c||d3.extent(d3.merge(B).concat($),function(e){return e.y})).range([0,L]),d.yDomain(h.domain()),m.yDomain(h.domain()),y.yDomain(h.domain()),v.yDomain(p.domain()),g.yDomain(p.domain()),b.yDomain(p.domain()),D.length&&d3.transition(U).call(y),P.length&&d3.transition(X).call(b),M.length&&d3.transition(R).call(m),_.length&&d3.transition(W).call(g),A.length&&d3.transition(q).call(d),O.length&&d3.transition(z).call(v),w.ticks(k/100).tickSize(-L,0),I.select(".x.axis").attr("transform","translate(0,"+L+")"),d3.transition(I.select(".x.axis")).call(w),E.ticks(L/36).tickSize(-k,0),d3.transition(I.select(".y1.axis")).call(E),S.ticks(L/36).tickSize(-k,0),d3.transition(I.select(".y2.axis")).call(S),I.select(".y2.axis").style("opacity",B.length?1:0).attr("transform","translate("+a.range()[1]+",0)"),x.dispatch.on("stateChange",function(e){C.update()}),T.on("tooltipShow",function(e){o&&N(e,f.parentNode)})}),C}var t={top:30,right:20,bottom:50,left:60},n=d3.scale.category20().range(),r=null,i=null,s=!0,o=!0,u=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},a,f,l,c,a=d3.scale.linear(),h=d3.scale.linear(),p=d3.scale.linear(),d=e.models.line().yScale(h),v=e.models.line().yScale(p),m=e.models.multiBar().stacked(!1).yScale(h),g=e.models.multiBar().stacked(!1).yScale(p),y=e.models.stackedArea().yScale(h),b=e.models.stackedArea().yScale(p),w=e.models.axis().scale(a).orient("bottom").tickPadding(5),E=e.models.axis().scale(h).orient("left"),S=e.models.axis().scale(p).orient("right"),x=e.models.legend().height(30),T=d3.dispatch("tooltipShow","tooltipHide"),N=function(t,n){var r=t.pos[0]+(n.offsetLeft||0),i=t.pos[1]+(n.offsetTop||0),s=w.tickFormat()(d.x()(t.point,t.pointIndex)),o=(t.series.yAxis==2?S:E).tickFormat()(d.y()(t.point,t.pointIndex)),a=u(t.series.key,s,o,t,C);e.tooltip.show([r,i],a,undefined,undefined,n.offsetParent)};return d.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],T.tooltipShow(e)}),d.dispatch.on("elementMouseout.tooltip",function(e){T.tooltipHide(e)}),v.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],T.tooltipShow(e)}),v.dispatch.on("elementMouseout.tooltip",function(e){T.tooltipHide(e)}),m.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],T.tooltipShow(e)}),m.dispatch.on("elementMouseout.tooltip",function(e){T.tooltipHide(e)}),g.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],T.tooltipShow(e)}),g.dispatch.on("elementMouseout.tooltip",function(e){T.tooltipHide(e)}),y.dispatch.on("tooltipShow",function(e){if(!Math.round(y.y()(e.point)*100))return setTimeout(function(){d3.selectAll(".point.hover").classed("hover",!1)},0),!1;e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],T.tooltipShow(e)}),y.dispatch.on("tooltipHide",function(e){T.tooltipHide(e)}),b.dispatch.on("tooltipShow",function(e){if(!Math.round(b.y()(e.point)*100))return setTimeout(function(){d3.selectAll(".point.hover").classed("hover",!1)},0),!1;e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],T.tooltipShow(e)}),b.dispatch.on("tooltipHide",function(e){T.tooltipHide(e)}),d.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],T.tooltipShow(e)}),d.dispatch.on("elementMouseout.tooltip",function(e){T.tooltipHide(e)}),v.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],T.tooltipShow(e)}),v.dispatch.on("elementMouseout.tooltip",function(e){T.tooltipHide(e)}),T.on("tooltipHide",function(){o&&e.tooltip.cleanup()}),C.dispatch=T,C.lines1=d,C.lines2=v,C.bars1=m,C.bars2=g,C.stack1=y,C.stack2=b,C.xAxis=w,C.yAxis1=E,C.yAxis2=S,C.options=e.utils.optionsFunc.bind(C),C.x=function(e){return arguments.length?(getX=e,d.x(e),m.x(e),C):getX},C.y=function(e){return arguments.length?(getY=e,d.y(e),m.y(e),C):getY},C.yDomain1=function(e){return arguments.length?(l=e,C):l},C.yDomain2=function(e){return arguments.length?(c=e,C):c},C.margin=function(e){return arguments.length?(t=e,C):t},C.width=function(e){return arguments.length?(r=e,C):r},C.height=function(e){return arguments.length?(i=e,C):i},C.color=function(e){return arguments.length?(n=e,x.color(e),C):n},C.showLegend=function(e){return arguments.length?(s=e,C):s},C.tooltips=function(e){return arguments.length?(o=e,C):o},C.tooltipContent=function(e){return arguments.length?(u=e,C):u},C},e.models.ohlcBar=function(){"use strict";function x(e){return e.each(function(e){var g=n-t.left-t.right,x=r-t.top-t.bottom,T=d3.select(this);s.domain(y||d3.extent(e[0].values.map(u).concat(p))),v?s.range(w||[g*.5/e[0].values.length,g*(e[0].values.length-.5)/e[0].values.length]):s.range(w||[0,g]),o.domain(b||[d3.min(e[0].values.map(h).concat(d)),d3.max(e[0].values.map(c).concat(d))]).range(E||[x,0]),s.domain()[0]===s.domain()[1]&&(s.domain()[0]?s.domain([s.domain()[0]-s.domain()[0]*.01,s.domain()[1]+s.domain()[1]*.01]):s.domain([-1,1])),o.domain()[0]===o.domain()[1]&&(o.domain()[0]?o.domain([o.domain()[0]+o.domain()[0]*.01,o.domain()[1]-o.domain()[1]*.01]):o.domain([-1,1]));var N=d3.select(this).selectAll("g.nv-wrap.nv-ohlcBar").data([e[0].values]),C=N.enter().append("g").attr("class","nvd3 nv-wrap nv-ohlcBar"),k=C.append("defs"),L=C.append("g"),A=N.select("g");L.append("g").attr("class","nv-ticks"),N.attr("transform","translate("+t.left+","+t.top+")"),T.on("click",function(e,t){S.chartClick({data:e,index:t,pos:d3.event,id:i})}),k.append("clipPath").attr("id","nv-chart-clip-path-"+i).append("rect"),N.select("#nv-chart-clip-path-"+i+" rect").attr("width",g).attr("height",x),A.attr("clip-path",m?"url(#nv-chart-clip-path-"+i+")":"");var O=N.select(".nv-ticks").selectAll(".nv-tick").data(function(e){return e});O.exit().remove();var M=O.enter().append("path").attr("class",function(e,t,n){return(f(e,t)>l(e,t)?"nv-tick negative":"nv-tick positive")+" nv-tick-"+n+"-"+t}).attr("d",function(t,n){var r=g/e[0].values.length*.9;return"m0,0l0,"+(o(f(t,n))-o(c(t,n)))+"l"+ -r/2+",0l"+r/2+",0l0,"+(o(h(t,n))-o(f(t,n)))+"l0,"+(o(l(t,n))-o(h(t,n)))+"l"+r/2+",0l"+ -r/2+",0z"}).attr("transform",function(e,t){return"translate("+s(u(e,t))+","+o(c(e,t))+")"}).on("mouseover",function(t,n){d3.select(this).classed("hover",!0),S.elementMouseover({point:t,series:e[0],pos:[s(u(t,n)),o(a(t,n))],pointIndex:n,seriesIndex:0,e:d3.event})}).on("mouseout",function(t,n){d3.select(this).classed("hover",!1),S.elementMouseout({point:t,series:e[0],pointIndex:n,seriesIndex:0,e:d3.event})}).on("click",function(e,t){S.elementClick({value:a(e,t),data:e,index:t,pos:[s(u(e,t)),o(a(e,t))],e:d3.event,id:i}),d3.event.stopPropagation()}).on("dblclick",function(e,t){S.elementDblClick({value:a(e,t),data:e,index:t,pos:[s(u(e,t)),o(a(e,t))],e:d3.event,id:i}),d3.event.stopPropagation()});O.attr("class",function(e,t,n){return(f(e,t)>l(e,t)?"nv-tick negative":"nv-tick positive")+" nv-tick-"+n+"-"+t}),d3.transition(O).attr("transform",function(e,t){return"translate("+s(u(e,t))+","+o(c(e,t))+")"}).attr("d",function(t,n){var r=g/e[0].values.length*.9;return"m0,0l0,"+(o(f(t,n))-o(c(t,n)))+"l"+ -r/2+",0l"+r/2+",0l0,"+(o(h(t,n))-o(f(t,n)))+"l0,"+(o(l(t,n))-o(h(t,n)))+"l"+r/2+",0l"+ -r/2+",0z"})}),x}var t={top:0,right:0,bottom:0,left:0},n=960,r=500,i=Math.floor(Math.random()*1e4),s=d3.scale.linear(),o=d3.scale.linear(),u=function(e){return e.x},a=function(e){return e.y},f=function(e){return e.open},l=function(e){return e.close},c=function(e){return e.high},h=function(e){return e.low},p=[],d=[],v=!1,m=!0,g=e.utils.defaultColor(),y,b,w,E,S=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return x.dispatch=S,x.options=e.utils.optionsFunc.bind(x),x.x=function(e){return arguments.length?(u=e,x):u},x.y=function(e){return arguments.length?(a=e,x):a},x.open=function(e){return arguments.length?(f=e,x):f},x.close=function(e){return arguments.length?(l=e,x):l},x.high=function(e){return arguments.length?(c=e,x):c},x.low=function(e){return arguments.length?(h=e,x):h},x.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,x):t},x.width=function(e){return arguments -.length?(n=e,x):n},x.height=function(e){return arguments.length?(r=e,x):r},x.xScale=function(e){return arguments.length?(s=e,x):s},x.yScale=function(e){return arguments.length?(o=e,x):o},x.xDomain=function(e){return arguments.length?(y=e,x):y},x.yDomain=function(e){return arguments.length?(b=e,x):b},x.xRange=function(e){return arguments.length?(w=e,x):w},x.yRange=function(e){return arguments.length?(E=e,x):E},x.forceX=function(e){return arguments.length?(p=e,x):p},x.forceY=function(e){return arguments.length?(d=e,x):d},x.padData=function(e){return arguments.length?(v=e,x):v},x.clipEdge=function(e){return arguments.length?(m=e,x):m},x.color=function(t){return arguments.length?(g=e.utils.getColor(t),x):g},x.id=function(e){return arguments.length?(i=e,x):i},x},e.models.pie=function(){"use strict";function E(e){return e.each(function(e){function P(e){var t=(e.startAngle+e.endAngle)*90/Math.PI-90;return t>90?t-180:t}function H(e){e.endAngle=isNaN(e.endAngle)?0:e.endAngle,e.startAngle=isNaN(e.startAngle)?0:e.startAngle,v||(e.innerRadius=0);var t=d3.interpolate(this._current,e);return this._current=t(0),function(e){return L(t(e))}}function B(e){e.innerRadius=0;var t=d3.interpolate({startAngle:0,endAngle:0},e);return function(e){return L(t(e))}}var o=n-t.left-t.right,f=r-t.top-t.bottom,E=Math.min(o,f)/2,S=E-E/5,x=d3.select(this),T=x.selectAll(".nv-wrap.nv-pie").data(e),N=T.enter().append("g").attr("class","nvd3 nv-wrap nv-pie nv-chart-"+u),C=N.append("g"),k=T.select("g");C.append("g").attr("class","nv-pie"),T.attr("transform","translate("+t.left+","+t.top+")"),k.select(".nv-pie").attr("transform","translate("+o/2+","+f/2+")"),x.on("click",function(e,t){w.chartClick({data:e,index:t,pos:d3.event,id:u})});var L=d3.svg.arc().outerRadius(S);g&&L.startAngle(g),y&&L.endAngle(y),v&&L.innerRadius(E*b);var A=d3.layout.pie().sort(null).value(function(e){return e.disabled?0:s(e)}),O=T.select(".nv-pie").selectAll(".nv-slice").data(A);O.exit().remove();var M=O.enter().append("g").attr("class","nv-slice").on("mouseover",function(e,t){d3.select(this).classed("hover",!0),w.elementMouseover({label:i(e.data),value:s(e.data),point:e.data,pointIndex:t,pos:[d3.event.pageX,d3.event.pageY],id:u})}).on("mouseout",function(e,t){d3.select(this).classed("hover",!1),w.elementMouseout({label:i(e.data),value:s(e.data),point:e.data,index:t,id:u})}).on("click",function(e,t){w.elementClick({label:i(e.data),value:s(e.data),point:e.data,index:t,pos:d3.event,id:u}),d3.event.stopPropagation()}).on("dblclick",function(e,t){w.elementDblClick({label:i(e.data),value:s(e.data),point:e.data,index:t,pos:d3.event,id:u}),d3.event.stopPropagation()});O.attr("fill",function(e,t){return a(e,t)}).attr("stroke",function(e,t){return a(e,t)});var _=M.append("path").each(function(e){this._current=e});O.select("path").transition().attr("d",L).attrTween("d",H);if(l){var D=d3.svg.arc().innerRadius(0);c&&(D=L),h&&(D=d3.svg.arc().outerRadius(L.outerRadius())),M.append("g").classed("nv-label",!0).each(function(e,t){var n=d3.select(this);n.attr("transform",function(e){if(m){e.outerRadius=S+10,e.innerRadius=S+15;var t=(e.startAngle+e.endAngle)/2*(180/Math.PI);return(e.startAngle+e.endAngle)/2d?r[p]:""});var r=n.select("text").node().getBBox();n.select(".nv-label rect").attr("width",r.width+10).attr("height",r.height+10).attr("transform",function(){return"translate("+[r.x-5,r.y-5]+")"})})}}),E}var t={top:0,right:0,bottom:0,left:0},n=500,r=500,i=function(e){return e.x},s=function(e){return e.y},o=function(e){return e.description},u=Math.floor(Math.random()*1e4),a=e.utils.defaultColor(),f=d3.format(",.2f"),l=!0,c=!0,h=!1,p="key",d=.02,v=!1,m=!1,g=!1,y=!1,b=.5,w=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return E.dispatch=w,E.options=e.utils.optionsFunc.bind(E),E.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,E):t},E.width=function(e){return arguments.length?(n=e,E):n},E.height=function(e){return arguments.length?(r=e,E):r},E.values=function(t){return e.log("pie.values() is no longer supported."),E},E.x=function(e){return arguments.length?(i=e,E):i},E.y=function(e){return arguments.length?(s=d3.functor(e),E):s},E.description=function(e){return arguments.length?(o=e,E):o},E.showLabels=function(e){return arguments.length?(l=e,E):l},E.labelSunbeamLayout=function(e){return arguments.length?(m=e,E):m},E.donutLabelsOutside=function(e){return arguments.length?(h=e,E):h},E.pieLabelsOutside=function(e){return arguments.length?(c=e,E):c},E.labelType=function(e){return arguments.length?(p=e,p=p||"key",E):p},E.donut=function(e){return arguments.length?(v=e,E):v},E.donutRatio=function(e){return arguments.length?(b=e,E):b},E.startAngle=function(e){return arguments.length?(g=e,E):g},E.endAngle=function(e){return arguments.length?(y=e,E):y},E.id=function(e){return arguments.length?(u=e,E):u},E.color=function(t){return arguments.length?(a=e.utils.getColor(t),E):a},E.valueFormat=function(e){return arguments.length?(f=e,E):f},E.labelThreshold=function(e){return arguments.length?(d=e,E):d},E},e.models.pieChart=function(){"use strict";function v(e){return e.each(function(e){var u=d3.select(this),a=this,f=(i||parseInt(u.style("width"))||960)-r.left-r.right,d=(s||parseInt(u.style("height"))||400)-r.top-r.bottom;v.update=function(){u.transition().call(v)},v.container=this,l.disabled=e.map(function(e){return!!e.disabled});if(!c){var m;c={};for(m in l)l[m]instanceof Array?c[m]=l[m].slice(0):c[m]=l[m]}if(!e||!e.length){var g=u.selectAll(".nv-noData").data([h]);return g.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),g.attr("x",r.left+f/2).attr("y",r.top+d/2).text(function(e){return e}),v}u.selectAll(".nv-noData").remove();var y=u.selectAll("g.nv-wrap.nv-pieChart").data([e]),b=y.enter().append("g").attr("class","nvd3 nv-wrap nv-pieChart").append("g"),w=y.select("g");b.append("g").attr("class","nv-pieWrap"),b.append("g").attr("class","nv-legendWrap"),o&&(n.width(f).key(t.x()),y.select(".nv-legendWrap").datum(e).call(n),r.top!=n.height()&&(r.top=n.height(),d=(s||parseInt(u.style("height"))||400)-r.top-r.bottom),y.select(".nv-legendWrap").attr("transform","translate(0,"+ -r.top+")")),y.attr("transform","translate("+r.left+","+r.top+")"),t.width(f).height(d);var E=w.select(".nv-pieWrap").datum([e]);d3.transition(E).call(t),n.dispatch.on("stateChange",function(e){l=e,p.stateChange(l),v.update()}),t.dispatch.on("elementMouseout.tooltip",function(e){p.tooltipHide(e)}),p.on("changeState",function(t){typeof t.disabled!="undefined"&&(e.forEach(function(e,n){e.disabled=t.disabled[n]}),l.disabled=t.disabled),v.update()})}),v}var t=e.models.pie(),n=e.models.legend(),r={top:30,right:20,bottom:20,left:20},i=null,s=null,o=!0,u=e.utils.defaultColor(),a=!0,f=function(e,t,n,r){return"

"+e+"

"+"

"+t+"

"},l={},c=null,h="No Data Available.",p=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),d=function(n,r){var i=t.description()(n.point)||t.x()(n.point),s=n.pos[0]+(r&&r.offsetLeft||0),o=n.pos[1]+(r&&r.offsetTop||0),u=t.valueFormat()(t.y()(n.point)),a=f(i,u,n,v);e.tooltip.show([s,o],a,n.value<0?"n":"s",null,r)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+r.left,e.pos[1]+r.top],p.tooltipShow(e)}),p.on("tooltipShow",function(e){a&&d(e)}),p.on("tooltipHide",function(){a&&e.tooltip.cleanup()}),v.legend=n,v.dispatch=p,v.pie=t,d3.rebind(v,t,"valueFormat","values","x","y","description","id","showLabels","donutLabelsOutside","pieLabelsOutside","labelType","donut","donutRatio","labelThreshold"),v.options=e.utils.optionsFunc.bind(v),v.margin=function(e){return arguments.length?(r.top=typeof e.top!="undefined"?e.top:r.top,r.right=typeof e.right!="undefined"?e.right:r.right,r.bottom=typeof e.bottom!="undefined"?e.bottom:r.bottom,r.left=typeof e.left!="undefined"?e.left:r.left,v):r},v.width=function(e){return arguments.length?(i=e,v):i},v.height=function(e){return arguments.length?(s=e,v):s},v.color=function(r){return arguments.length?(u=e.utils.getColor(r),n.color(u),t.color(u),v):u},v.showLegend=function(e){return arguments.length?(o=e,v):o},v.tooltips=function(e){return arguments.length?(a=e,v):a},v.tooltipContent=function(e){return arguments.length?(f=e,v):f},v.state=function(e){return arguments.length?(l=e,v):l},v.defaultState=function(e){return arguments.length?(c=e,v):c},v.noData=function(e){return arguments.length?(h=e,v):h},v},e.models.scatter=function(){"use strict";function I(q){return q.each(function(I){function Q(){if(!g)return!1;var e,i=d3.merge(I.map(function(e,t){return e.values.map(function(e,n){var r=f(e,n),i=l(e,n);return[o(r)+Math.random()*1e-7,u(i)+Math.random()*1e-7,t,n,e]}).filter(function(e,t){return b(e[4],t)})}));if(D===!0){if(x){var a=X.select("defs").selectAll(".nv-point-clips").data([s]).enter();a.append("clipPath").attr("class","nv-point-clips").attr("id","nv-points-clip-"+s);var c=X.select("#nv-points-clip-"+s).selectAll("circle").data(i);c.enter().append("circle").attr("r",T),c.exit().remove(),c.attr("cx",function(e){return e[0]}).attr("cy",function(e){return e[1]}),X.select(".nv-point-paths").attr("clip-path","url(#nv-points-clip-"+s+")")}i.length&&(i.push([o.range()[0]-20,u.range()[0]-20,null,null]),i.push([o.range()[1]+20,u.range()[1]+20,null,null]),i.push([o.range()[0]-20,u.range()[0]+20,null,null]),i.push([o.range()[1]+20,u.range()[1]-20,null,null]));var h=d3.geom.polygon([[-10,-10],[-10,r+10],[n+10,r+10],[n+10,-10]]),p=d3.geom.voronoi(i).map(function(e,t){return{data:h.clip(e),series:i[t][2],point:i[t][3]}}),d=X.select(".nv-point-paths").selectAll("path").data(p);d.enter().append("path").attr("class",function(e,t){return"nv-path-"+t}),d.exit().remove(),d.attr("d",function(e){return e.data.length===0?"M 0 0":"M"+e.data.join("L")+"Z"});var v=function(e,n){if(F)return 0;var r=I[e.series];if(typeof r=="undefined")return;var i=r.values[e.point];n({point:i,series:r,pos:[o(f(i,e.point))+t.left,u(l(i,e.point))+t.top],seriesIndex:e.series,pointIndex:e.point})};d.on("click",function(e){v(e,_.elementClick)}).on("mouseover",function(e){v(e,_.elementMouseover)}).on("mouseout",function(e,t){v(e,_.elementMouseout)})}else X.select(".nv-groups").selectAll(".nv-group").selectAll(".nv-point").on("click",function(e,n){if(F||!I[e.series])return 0;var r=I[e.series],i=r.values[n];_.elementClick({point:i,series:r,pos:[o(f(i,n))+t.left,u(l(i,n))+t.top],seriesIndex:e.series,pointIndex:n})}).on("mouseover",function(e,n){if(F||!I[e.series])return 0;var r=I[e.series],i=r.values[n];_.elementMouseover({point:i,series:r,pos:[o(f(i,n))+t.left,u(l(i,n))+t.top],seriesIndex:e.series,pointIndex:n})}).on("mouseout",function(e,t){if(F||!I[e.series])return 0;var n=I[e.series],r=n.values[t];_.elementMouseout({point:r,series:n,seriesIndex:e.series,pointIndex:t})});F=!1}var q=n-t.left-t.right,R=r-t.top-t.bottom,U=d3.select(this);I.forEach(function(e,t){e.values.forEach(function(e){e.series=t})});var W=N&&C&&A?[]:d3.merge(I.map(function(e){return e.values.map(function(e,t){return{x:f(e,t),y:l(e,t),size:c(e,t)}})}));o.domain(N||d3.extent(W.map(function(e){return e.x}).concat(d))),w&&I[0]?o.range(k||[(q*E+q)/(2*I[0].values.length),q-q*(1+E)/(2*I[0].values.length)]):o.range(k||[0,q]),u.domain(C||d3.extent(W.map(function(e){return e.y}).concat(v))).range(L||[R,0]),a.domain(A||d3.extent(W.map(function(e){return e.size}).concat(m))).range(O||[16,256]);if(o.domain()[0]===o.domain()[1]||u.domain()[0]===u.domain()[1])M=!0;o.domain()[0]===o.domain()[1]&&(o.domain()[0]?o.domain([o.domain()[0]-o.domain()[0]*.01,o.domain()[1]+o.domain()[1]*.01]):o.domain([-1,1])),u.domain()[0]===u.domain()[1]&&(u.domain()[0]?u.domain([u.domain()[0]-u.domain()[0]*.01,u.domain()[1]+u.domain()[1]*.01]):u.domain([-1,1])),isNaN(o.domain()[0])&&o.domain([-1,1]),isNaN(u.domain()[0])&&u.domain([-1,1]),P=P||o,H=H||u,B=B||a;var X=U.selectAll("g.nv-wrap.nv-scatter").data([I]),V=X.enter().append("g").attr("class","nvd3 nv-wrap nv-scatter nv-chart-"+s+(M?" nv-single-point":"")),$=V.append("defs"),J=V.append("g"),K=X.select("g");J.append("g").attr("class","nv-groups"),J.append("g").attr("class","nv-point-paths"),X.attr("transform","translate("+t.left+","+t.top+")"),$.append("clipPath").attr("id","nv-edge-clip-"+s).append("rect"),X.select("#nv-edge-clip-"+s+" rect").attr("width",q).attr("height",R),K.attr("clip-path",S?"url(#nv-edge-clip-"+s+")":""),F=!0;var G=X.select(".nv-groups").selectAll(".nv-group").data(function(e){return e},function(e){return e.key});G.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),G.exit().remove(),G.attr("class",function(e,t){return"nv-group nv-series-"+t}).classed("hover",function(e){return e.hover}),G.transition().style("fill",function(e,t){return i(e,t)}).style("stroke",function(e,t){return i(e,t)}).style("stroke-opacity",1).style("fill-opacity",.5);if(p){var Y=G.selectAll("circle.nv-point").data(function(e){return e.values},y);Y.enter().append("circle").style("fill",function(e,t){return e.color}).style("stroke",function(e,t){return e.color}).attr("cx",function(t,n){return e.utils.NaNtoZero(P(f(t,n)))}).attr("cy",function(t,n){return e.utils.NaNtoZero(H(l(t,n)))}).attr("r",function(e,t){return Math.sqrt(a(c(e,t))/Math.PI)}),Y.exit().remove(),G.exit().selectAll("path.nv-point").transition().attr("cx",function(t,n){return e.utils.NaNtoZero(o(f(t,n)))}).attr("cy",function(t,n){return e.utils.NaNtoZero(u(l(t,n)))}).remove(),Y.each(function(e,t){d3.select(this).classed("nv-point",!0).classed("nv-point-"+t,!0).classed("hover",!1)}),Y.transition().attr("cx",function(t,n){return e.utils.NaNtoZero(o(f(t,n)))}).attr("cy",function(t,n){return e.utils.NaNtoZero(u(l(t,n)))}).attr("r",function(e,t){return Math.sqrt(a(c(e,t))/Math.PI)})}else{var Y=G.selectAll("path.nv-point").data(function(e){return e.values});Y.enter().append("path").style("fill",function(e,t){return e.color}).style("stroke",function(e,t){return e.color}).attr("transform",function(e,t){return"translate("+P(f(e,t))+","+H(l(e,t))+")"}).attr("d",d3.svg.symbol().type(h).size(function(e,t){return a(c(e,t))})),Y.exit().remove(),G.exit().selectAll("path.nv-point").transition().attr("transform",function(e,t){return"translate("+o(f(e,t))+","+u(l(e,t))+")"}).remove(),Y.each(function(e,t){d3.select(this).classed("nv-point",!0).classed("nv-point-"+t,!0).classed("hover",!1)}),Y.transition().attr("transform",function(e,t){return"translate("+o(f(e,t))+","+u(l(e,t))+")"}).attr("d",d3.svg.symbol().type(h).size(function(e,t){return a(c(e,t))}))}clearTimeout(j),j=setTimeout(Q,300),P=o.copy(),H=u.copy(),B=a.copy()}),I}var t={top:0,right:0,bottom:0,left:0},n=960,r=500,i=e.utils.defaultColor(),s=Math.floor(Math.random()*1e5),o=d3.scale.linear(),u=d3.scale.linear(),a=d3.scale.linear(),f=function(e){return e.x},l=function(e){return e.y},c=function(e){return e.size||1},h=function(e){return e.shape||"circle"},p=!0,d=[],v=[],m=[],g=!0,y=null,b=function(e){return!e.notActive},w=!1,E=.1,S=!1,x=!0,T=function(){return 25},N=null,C=null,k=null,L=null,A=null,O=null,M=!1,_=d3.dispatch("elementClick","elementMouseover","elementMouseout"),D=!0,P,H,B,j,F=!1;return I.clearHighlights=function(){d3.selectAll(".nv-chart-"+s+" .nv-point.hover").classed("hover",!1)},I.highlightPoint=function(e,t,n){d3.select(".nv-chart-"+s+" .nv-series-"+e+" .nv-point-"+t).classed("hover",n)},_.on("elementMouseover.point",function(e){g&&I.highlightPoint(e.seriesIndex,e.pointIndex,!0)}),_.on("elementMouseout.point",function(e){g&&I.highlightPoint(e.seriesIndex,e.pointIndex,!1)}),I.dispatch=_,I.options=e.utils.optionsFunc.bind(I),I.x=function(e){return arguments.length?(f=d3.functor(e),I):f},I.y=function(e){return arguments.length?(l=d3.functor(e),I):l},I.size=function(e){return arguments.length?(c=d3.functor(e),I):c},I.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,I):t},I.width=function(e){return arguments.length?(n=e,I):n},I.height=function(e){return arguments.length?(r=e,I):r},I.xScale=function(e){return arguments.length?(o=e,I):o},I.yScale=function(e){return arguments.length?(u=e,I):u},I.zScale=function(e){return arguments.length?(a=e,I):a},I.xDomain=function(e){return arguments.length?(N=e,I):N},I.yDomain=function(e){return arguments.length?(C=e,I):C},I.sizeDomain=function(e){return arguments.length?(A=e,I):A},I.xRange=function(e){return arguments.length?(k=e,I):k},I.yRange=function(e){return arguments.length?(L=e,I):L},I.sizeRange=function(e){return arguments.length?(O=e,I):O},I.forceX=function(e){return arguments.length?(d=e,I):d},I.forceY=function(e){return arguments.length?(v=e,I):v},I.forceSize=function(e){return arguments.length?(m=e,I):m},I.interactive=function(e){return arguments.length?(g=e,I):g},I.pointKey=function(e){return arguments.length?(y=e,I):y},I.pointActive=function(e){return arguments.length?(b=e,I):b},I.padData=function(e){return arguments.length?(w=e,I):w},I.padDataOuter=function(e){return arguments.length?(E=e,I):E},I.clipEdge=function(e){return arguments.length?(S=e,I):S},I.clipVoronoi=function(e){return arguments.length?(x=e,I):x},I.useVoronoi=function(e){return arguments.length?(D=e,D===!1&&(x=!1),I):D},I.clipRadius=function(e){return arguments.length?(T=e,I):T},I.color=function(t){return arguments.length?(i=e.utils.getColor(t),I):i},I.shape=function(e){return arguments.length?(h=e,I):h},I.onlyCircles=function(e){return arguments.length?(p=e,I):p},I.id=function(e){return arguments.length?(s=e,I):s},I.singlePoint=function(e){return arguments.length?(M=e,I):M},I},e.models.scatterChart=function(){"use strict";function F(e){return e.each(function(e){function K(){if(T)return X.select(".nv-point-paths").style("pointer-events","all"),!1;X.select(".nv-point-paths").style("pointer-events","none");var i=d3.mouse(this);h.distortion(x).focus(i[0]),p.distortion(x).focus(i[1]),X.select(".nv-scatterWrap").call(t),b&&X.select(".nv-x.nv-axis").call(n),w&&X.select(".nv-y.nv-axis").call(r),X.select(".nv-distributionX").datum(e.filter(function(e){return!e.disabled})).call(o),X.select(".nv-distributionY").datum(e.filter(function(e){return!e.disabled})).call(u)}var C=d3.select(this),k=this,L=(f||parseInt(C.style("width"))||960)-a.left-a.right,I=(l||parseInt(C.style("height"))||400)-a.top-a.bottom;F.update=function(){C.transition().duration(D).call(F)},F.container=this,A.disabled=e.map(function(e){return!!e.disabled});if(!O){var q;O={};for(q in A)A[q]instanceof Array?O[q]=A[q].slice(0):O[q]=A[q]}if(!e||!e.length||!e.filter(function(e){return e.values.length}).length){var R=C.selectAll(".nv-noData").data([_]);return R.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),R.attr("x",a.left+L/2).attr("y",a.top+I/2).text(function(e){return e}),F}C.selectAll(".nv-noData").remove(),P=P||h,H=H||p;var U=C.selectAll("g.nv-wrap.nv-scatterChart").data([e]),z=U.enter().append("g").attr("class","nvd3 nv-wrap nv-scatterChart nv-chart-"+t.id()),W=z.append("g"),X=U.select("g");W.append("rect").attr("class","nvd3 nv-background"),W.append("g").attr("class","nv-x nv-axis"),W.append("g").attr("class","nv-y nv-axis"),W.append("g").attr("class","nv-scatterWrap"),W.append("g").attr("class","nv-distWrap"),W.append("g").attr("class","nv-legendWrap"),W.append("g").attr("class","nv-controlsWrap");if(y){var V=S?L/2:L;i.width(V),U.select(".nv-legendWrap").datum(e).call(i),a.top!=i.height()&&(a.top=i.height(),I=(l||parseInt(C.style("height"))||400)-a.top-a.bottom),U.select(".nv-legendWrap").attr("transform","translate("+(L-V)+","+ -a.top+")")}S&&(s.width(180).color(["#444"]),X.select(".nv-controlsWrap").datum(j).attr("transform","translate(0,"+ -a.top+")").call(s)),U.attr("transform","translate("+a.left+","+a.top+")"),E&&X.select(".nv-y.nv-axis").attr("transform","translate("+L+",0)"),t.width(L).height(I).color(e.map(function(e,t){return e.color||c(e,t)}).filter(function(t,n){return!e[n].disabled})),d!==0&&t.xDomain(null),v!==0&&t.yDomain(null),U.select(".nv-scatterWrap").datum(e.filter(function(e){return!e.disabled})).call(t);if(d!==0){var $=h.domain()[1]-h.domain()[0];t.xDomain([h.domain()[0]-d*$,h.domain()[1]+d*$])}if(v!==0){var J=p.domain()[1]-p.domain()[0];t.yDomain([p.domain()[0]-v*J,p.domain()[1]+v*J])}(v!==0||d!==0)&&U.select(".nv-scatterWrap").datum(e.filter(function(e){return!e.disabled})).call(t),b&&(n.scale(h).ticks(n.ticks()&&n.ticks().length?n.ticks():L/100).tickSize(-I,0),X.select(".nv-x.nv-axis").attr("transform","translate(0,"+p.range()[0]+")").call(n)),w&&(r.scale(p).ticks(r.ticks()&&r.ticks().length?r.ticks():I/36).tickSize(-L,0),X.select(".nv-y.nv-axis").call(r)),m&&(o.getData(t.x()).scale(h).width(L).color(e.map(function(e,t){return e.color||c(e,t)}).filter(function(t,n){return!e[n].disabled})),W.select(".nv-distWrap").append("g").attr("class","nv-distributionX"),X.select(".nv-distributionX").attr("transform","translate(0,"+p.range()[0]+")").datum(e.filter(function(e){return!e.disabled})).call(o)),g&&(u.getData(t.y()).scale(p).width(I).color(e.map(function(e,t){return e.color||c(e,t)}).filter(function(t,n){return!e[n].disabled})),W.select(".nv-distWrap").append("g").attr("class","nv-distributionY"),X.select(".nv-distributionY").attr("transform","translate("+(E?L:-u.size())+",0)").datum(e.filter(function(e){return!e.disabled})).call(u)),d3.fisheye&&(X.select(".nv-background").attr("width",L).attr("height",I),X.select(".nv-background").on("mousemove",K),X.select(".nv-background").on("click",function(){T=!T}),t.dispatch.on("elementClick.freezeFisheye",function(){T=!T})),s.dispatch.on("legendClick",function(e,i){e.disabled=!e.disabled,x=e.disabled?0:2.5,X.select(".nv-background").style("pointer-events",e.disabled?"none":"all"),X.select(".nv-point-paths").style("pointer-events",e.disabled?"all":"none"),e.disabled?(h.distortion(x).focus(0),p.distortion(x).focus(0),X.select(".nv-scatterWrap").call(t),X.select(".nv-x.nv-axis").call(n),X.select(".nv-y.nv-axis").call(r)):T=!1,F.update()}),i.dispatch.on("stateChange",function(e){A.disabled=e.disabled,M.stateChange(A),F.update()}),t.dispatch.on("elementMouseover.tooltip",function(e){d3.select(".nv-chart-"+t.id()+" .nv-series-"+e.seriesIndex+" .nv-distx-"+e.pointIndex).attr("y1",function(t,n){return e.pos[1]-I}),d3.select(".nv-chart-"+t.id()+" .nv-series-"+e.seriesIndex+" .nv-disty-"+e.pointIndex).attr("x2",e.pos[0]+o.size()),e.pos=[e.pos[0]+a.left,e.pos[1]+a.top],M.tooltipShow(e)}),M.on("tooltipShow",function(e){N&&B(e,k.parentNode)}),M.on("changeState",function(t){typeof t.disabled!="undefined"&&(e.forEach(function(e,n){e.disabled=t.disabled[n]}),A.disabled=t.disabled),F.update()}),P=h.copy(),H=p.copy()}),F}var t=e.models.scatter(),n=e.models.axis(),r=e.models.axis(),i=e.models.legend(),s=e.models.legend(),o=e.models.distribution(),u=e.models.distribution(),a={top:30,right:20,bottom:50,left:75},f=null,l=null,c=e.utils.defaultColor(),h=d3.fisheye?d3.fisheye.scale(d3.scale.linear).distortion(0):t.xScale(),p=d3.fisheye?d3.fisheye.scale(d3.scale.linear).distortion(0):t.yScale(),d=0,v=0,m=!1,g=!1,y=!0,b=!0,w=!0,E=!1,S=!!d3.fisheye,x=0,T=!1,N=!0,C=function(e,t,n){return""+t+""},k=function(e,t,n){return""+n+""},L=null,A={},O=null,M=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),_="No Data Available.",D=250;t.xScale(h).yScale(p),n.orient("bottom").tickPadding(10),r.orient(E?"right":"left").tickPadding(10),o.axis("x"),u.axis("y"),s.updateState(!1);var P,H,B=function(i,s){var o=i.pos[0]+(s.offsetLeft||0),u=i.pos[1]+(s.offsetTop||0),f=i.pos[0]+(s.offsetLeft||0),l=p.range()[0]+a.top+(s.offsetTop||0),c=h.range()[0]+a.left+(s.offsetLeft||0),d=i.pos[1]+(s.offsetTop||0),v=n.tickFormat()(t.x()(i.point,i.pointIndex)),m=r.tickFormat()(t.y()(i.point,i.pointIndex));C!=null&&e.tooltip.show([f,l],C(i.series.key,v,m,i,F),"n",1,s,"x-nvtooltip"),k!=null&&e.tooltip.show([c,d],k(i.series.key,v,m,i,F),"e",1,s,"y-nvtooltip"),L!=null&&e.tooltip.show([o,u],L(i.series.key,v,m,i,F),i.value<0?"n":"s",null,s)},j=[{key:"Magnify",disabled:!0}];return t.dispatch.on("elementMouseout.tooltip",function(e){M.tooltipHide(e),d3.select(".nv-chart-"+t.id()+" .nv-series-"+e.seriesIndex+" .nv-distx-"+e.pointIndex).attr("y1",0),d3.select(".nv-chart-"+t.id()+" .nv-series-"+e.seriesIndex+" .nv-disty-"+e.pointIndex).attr("x2",u.size())}),M.on("tooltipHide",function(){N&&e.tooltip.cleanup()}),F.dispatch=M,F.scatter=t,F.legend=i,F.controls=s,F.xAxis=n,F.yAxis=r,F.distX=o,F.distY=u,d3.rebind(F,t,"id","interactive","pointActive","x","y","shape","size","xScale","yScale","zScale","xDomain","yDomain","xRange","yRange","sizeDomain","sizeRange","forceX","forceY","forceSize","clipVoronoi","clipRadius","useVoronoi"),F.options=e.utils.optionsFunc.bind(F),F.margin=function(e){return arguments.length?(a.top=typeof e.top!="undefined"?e.top:a.top,a.right=typeof e.right!="undefined"?e.right:a.right,a.bottom=typeof e.bottom!="undefined"?e.bottom:a.bottom,a.left=typeof e.left!="undefined"?e.left:a.left,F):a},F.width=function(e){return arguments.length?(f=e,F):f},F.height=function(e){return arguments.length?(l=e,F):l},F.color=function(t){return arguments.length?(c=e.utils.getColor(t),i.color(c),o.color(c),u.color(c),F):c},F.showDistX=function(e){return arguments.length?(m=e,F):m},F.showDistY=function(e){return arguments.length?(g=e,F):g},F.showControls=function(e){return arguments.length?(S=e,F):S},F.showLegend=function(e){return arguments.length?(y=e,F):y},F.showXAxis=function(e){return arguments.length?(b=e,F):b},F.showYAxis=function(e){return arguments.length?(w=e,F):w},F.rightAlignYAxis=function(e){return arguments.length?(E=e,r.orient(e?"right":"left"),F):E},F.fisheye=function(e){return arguments.length?(x=e,F):x},F.xPadding=function(e){return arguments.length?(d=e,F):d},F.yPadding=function(e){return arguments.length?(v=e,F):v},F.tooltips=function(e){return arguments.length?(N=e,F):N},F.tooltipContent=function(e){return arguments.length?(L=e,F):L},F.tooltipXContent=function(e){return arguments.length?(C=e,F):C},F.tooltipYContent=function(e){return arguments.length?(k=e,F):k},F.state=function(e){return arguments.length?(A=e,F):A},F.defaultState=function(e){return arguments.length?(O=e,F):O},F.noData=function(e){return arguments.length?(_=e,F):_},F.transitionDuration=function(e){return arguments.length?(D=e,F):D},F},e.models.scatterPlusLineChart=function(){"use strict";function B(e){return e.each(function(e){function $(){if(S)return z.select(".nv-point-paths").style("pointer-events","all"),!1;z.select(".nv-point-paths").style("pointer-events","none");var i=d3.mouse(this);h.distortion(E).focus(i[0]),p.distortion(E).focus(i[1]),z.select(".nv-scatterWrap").datum(e.filter(function(e){return!e.disabled})).call(t),g&&z.select(".nv-x.nv-axis").call(n),y&&z.select(".nv-y.nv-axis").call(r),z.select(".nv-distributionX").datum(e.filter(function(e){return!e.disabled})).call(o),z.select(".nv-distributionY").datum(e.filter(function(e){return!e.disabled})).call(u)}var T=d3.select(this),N=this,C=(f||parseInt(T.style("width"))||960)-a.left-a.right,j=(l||parseInt(T.style("height"))||400)-a.top-a.bottom;B.update=function(){T.transition().duration(M).call(B)},B.container=this,k.disabled=e.map(function(e){return!!e.disabled});if(!L){var F;L={};for(F in k)k[F]instanceof Array?L[F]=k[F].slice(0):L[F]=k[F]}if(!e||!e.length||!e.filter(function(e){return e.values.length}).length){var I=T.selectAll(".nv-noData").data([O]);return I.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),I.attr("x",a.left+C/2).attr("y",a.top+j/2).text(function(e){return e}),B}T.selectAll(".nv-noData").remove(),h=t.xScale(),p=t.yScale(),_=_||h,D=D||p;var q=T.selectAll("g.nv-wrap.nv-scatterChart").data([e]),R=q.enter().append("g").attr("class","nvd3 nv-wrap nv-scatterChart nv-chart-"+t.id()),U=R.append("g"),z=q.select("g");U.append("rect").attr("class","nvd3 nv-background").style("pointer-events","none"),U.append("g").attr("class","nv-x nv-axis"),U.append("g").attr("class","nv-y nv-axis"),U.append("g").attr("class","nv-scatterWrap"),U.append("g").attr("class","nv-regressionLinesWrap"),U.append("g").attr("class","nv-distWrap"),U.append("g").attr("class","nv-legendWrap"),U.append("g").attr("class","nv-controlsWrap"),q.attr("transform","translate("+a.left+","+a.top+")"),b&&z.select(".nv-y.nv-axis").attr("transform","translate("+C+",0)"),m&&(i.width(C/2),q.select(".nv-legendWrap").datum(e).call(i),a.top!=i.height()&&(a.top=i.height(),j=(l||parseInt(T.style("height"))||400)-a.top-a.bottom),q.select(".nv-legendWrap").attr("transform","translate("+C/2+","+ -a.top+")")),w&&(s.width(180).color(["#444"]),z.select(".nv-controlsWrap").datum(H).attr("transform","translate(0,"+ -a.top+")").call(s)),t.width(C).height(j).color(e.map(function(e,t){return e.color||c(e,t)}).filter(function(t,n){return!e[n].disabled})),q.select(".nv-scatterWrap").datum(e.filter(function(e){return!e.disabled})).call(t),q.select(".nv-regressionLinesWrap").attr("clip-path","url(#nv-edge-clip-"+t.id()+")");var W=q.select(".nv-regressionLinesWrap").selectAll(".nv-regLines").data(function(e){return e});W.enter().append("g").attr("class","nv-regLines");var X=W.selectAll(".nv-regLine").data(function(e){return[e]}),V=X.enter().append("line").attr("class","nv-regLine").style("stroke-opacity",0);X.transition().attr("x1",h.range()[0]).attr("x2",h.range()[1]).attr("y1",function(e,t){return p(h.domain()[0]*e.slope+e.intercept)}).attr("y2",function(e,t){return p(h.domain()[1]*e.slope+e.intercept)}).style("stroke",function(e,t,n){return c(e,n)}).style("stroke-opacity",function(e,t){return e.disabled||typeof e.slope=="undefined"||typeof e.intercept=="undefined"?0:1}),g&&(n.scale(h).ticks(n.ticks()?n.ticks():C/100).tickSize(-j,0),z.select(".nv-x.nv-axis").attr("transform","translate(0,"+p.range()[0]+")").call(n)),y&&(r.scale(p).ticks(r.ticks()?r.ticks():j/36).tickSize(-C,0),z.select(".nv-y.nv-axis").call(r)),d&&(o.getData(t.x()).scale(h).width(C).color(e.map(function(e,t){return e.color||c(e,t)}).filter(function(t,n){return!e[n].disabled})),U.select(".nv-distWrap").append("g").attr("class","nv-distributionX"),z.select(".nv-distributionX").attr("transform","translate(0,"+p.range()[0]+")").datum(e.filter(function(e){return!e.disabled})).call(o)),v&&(u.getData(t.y()).scale(p).width(j).color(e.map(function(e,t){return e.color||c(e,t)}).filter(function(t,n){return!e[n].disabled})),U.select(".nv-distWrap").append("g").attr("class","nv-distributionY"),z.select(".nv-distributionY").attr("transform","translate("+(b?C:-u.size())+",0)").datum(e.filter(function(e){return!e.disabled})).call(u)),d3.fisheye&&(z.select(".nv-background").attr("width",C).attr("height",j),z.select(".nv-background").on("mousemove",$),z.select(".nv-background").on("click",function(){S=!S}),t.dispatch.on("elementClick.freezeFisheye",function(){S=!S})),s.dispatch.on("legendClick",function(e,i){e.disabled=!e.disabled,E=e.disabled?0:2.5,z.select(".nv-background").style("pointer-events",e.disabled?"none":"all"),z.select(".nv-point-paths").style("pointer-events",e.disabled?"all":"none"),e.disabled?(h.distortion(E).focus(0),p.distortion(E).focus(0),z.select(".nv-scatterWrap").call(t),z.select(".nv-x.nv-axis").call(n),z.select(".nv-y.nv-axis").call(r)):S=!1,B.update()}),i.dispatch.on("stateChange",function(e){k=e,A.stateChange(k),B.update()}),t.dispatch.on("elementMouseover.tooltip",function(e){d3.select(".nv-chart-"+t.id()+" .nv-series-"+e.seriesIndex+" .nv-distx-"+e.pointIndex). -attr("y1",e.pos[1]-j),d3.select(".nv-chart-"+t.id()+" .nv-series-"+e.seriesIndex+" .nv-disty-"+e.pointIndex).attr("x2",e.pos[0]+o.size()),e.pos=[e.pos[0]+a.left,e.pos[1]+a.top],A.tooltipShow(e)}),A.on("tooltipShow",function(e){x&&P(e,N.parentNode)}),A.on("changeState",function(t){typeof t.disabled!="undefined"&&(e.forEach(function(e,n){e.disabled=t.disabled[n]}),k.disabled=t.disabled),B.update()}),_=h.copy(),D=p.copy()}),B}var t=e.models.scatter(),n=e.models.axis(),r=e.models.axis(),i=e.models.legend(),s=e.models.legend(),o=e.models.distribution(),u=e.models.distribution(),a={top:30,right:20,bottom:50,left:75},f=null,l=null,c=e.utils.defaultColor(),h=d3.fisheye?d3.fisheye.scale(d3.scale.linear).distortion(0):t.xScale(),p=d3.fisheye?d3.fisheye.scale(d3.scale.linear).distortion(0):t.yScale(),d=!1,v=!1,m=!0,g=!0,y=!0,b=!1,w=!!d3.fisheye,E=0,S=!1,x=!0,T=function(e,t,n){return""+t+""},N=function(e,t,n){return""+n+""},C=function(e,t,n,r){return"

"+e+"

"+"

"+r+"

"},k={},L=null,A=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),O="No Data Available.",M=250;t.xScale(h).yScale(p),n.orient("bottom").tickPadding(10),r.orient(b?"right":"left").tickPadding(10),o.axis("x"),u.axis("y"),s.updateState(!1);var _,D,P=function(i,s){var o=i.pos[0]+(s.offsetLeft||0),u=i.pos[1]+(s.offsetTop||0),f=i.pos[0]+(s.offsetLeft||0),l=p.range()[0]+a.top+(s.offsetTop||0),c=h.range()[0]+a.left+(s.offsetLeft||0),d=i.pos[1]+(s.offsetTop||0),v=n.tickFormat()(t.x()(i.point,i.pointIndex)),m=r.tickFormat()(t.y()(i.point,i.pointIndex));T!=null&&e.tooltip.show([f,l],T(i.series.key,v,m,i,B),"n",1,s,"x-nvtooltip"),N!=null&&e.tooltip.show([c,d],N(i.series.key,v,m,i,B),"e",1,s,"y-nvtooltip"),C!=null&&e.tooltip.show([o,u],C(i.series.key,v,m,i.point.tooltip,i,B),i.value<0?"n":"s",null,s)},H=[{key:"Magnify",disabled:!0}];return t.dispatch.on("elementMouseout.tooltip",function(e){A.tooltipHide(e),d3.select(".nv-chart-"+t.id()+" .nv-series-"+e.seriesIndex+" .nv-distx-"+e.pointIndex).attr("y1",0),d3.select(".nv-chart-"+t.id()+" .nv-series-"+e.seriesIndex+" .nv-disty-"+e.pointIndex).attr("x2",u.size())}),A.on("tooltipHide",function(){x&&e.tooltip.cleanup()}),B.dispatch=A,B.scatter=t,B.legend=i,B.controls=s,B.xAxis=n,B.yAxis=r,B.distX=o,B.distY=u,d3.rebind(B,t,"id","interactive","pointActive","x","y","shape","size","xScale","yScale","zScale","xDomain","yDomain","xRange","yRange","sizeDomain","sizeRange","forceX","forceY","forceSize","clipVoronoi","clipRadius","useVoronoi"),B.options=e.utils.optionsFunc.bind(B),B.margin=function(e){return arguments.length?(a.top=typeof e.top!="undefined"?e.top:a.top,a.right=typeof e.right!="undefined"?e.right:a.right,a.bottom=typeof e.bottom!="undefined"?e.bottom:a.bottom,a.left=typeof e.left!="undefined"?e.left:a.left,B):a},B.width=function(e){return arguments.length?(f=e,B):f},B.height=function(e){return arguments.length?(l=e,B):l},B.color=function(t){return arguments.length?(c=e.utils.getColor(t),i.color(c),o.color(c),u.color(c),B):c},B.showDistX=function(e){return arguments.length?(d=e,B):d},B.showDistY=function(e){return arguments.length?(v=e,B):v},B.showControls=function(e){return arguments.length?(w=e,B):w},B.showLegend=function(e){return arguments.length?(m=e,B):m},B.showXAxis=function(e){return arguments.length?(g=e,B):g},B.showYAxis=function(e){return arguments.length?(y=e,B):y},B.rightAlignYAxis=function(e){return arguments.length?(b=e,r.orient(e?"right":"left"),B):b},B.fisheye=function(e){return arguments.length?(E=e,B):E},B.tooltips=function(e){return arguments.length?(x=e,B):x},B.tooltipContent=function(e){return arguments.length?(C=e,B):C},B.tooltipXContent=function(e){return arguments.length?(T=e,B):T},B.tooltipYContent=function(e){return arguments.length?(N=e,B):N},B.state=function(e){return arguments.length?(k=e,B):k},B.defaultState=function(e){return arguments.length?(L=e,B):L},B.noData=function(e){return arguments.length?(O=e,B):O},B.transitionDuration=function(e){return arguments.length?(M=e,B):M},B},e.models.sparkline=function(){"use strict";function d(e){return e.each(function(e){var i=n-t.left-t.right,d=r-t.top-t.bottom,v=d3.select(this);s.domain(l||d3.extent(e,u)).range(h||[0,i]),o.domain(c||d3.extent(e,a)).range(p||[d,0]);var m=v.selectAll("g.nv-wrap.nv-sparkline").data([e]),g=m.enter().append("g").attr("class","nvd3 nv-wrap nv-sparkline"),b=g.append("g"),w=m.select("g");m.attr("transform","translate("+t.left+","+t.top+")");var E=m.selectAll("path").data(function(e){return[e]});E.enter().append("path"),E.exit().remove(),E.style("stroke",function(e,t){return e.color||f(e,t)}).attr("d",d3.svg.line().x(function(e,t){return s(u(e,t))}).y(function(e,t){return o(a(e,t))}));var S=m.selectAll("circle.nv-point").data(function(e){function n(t){if(t!=-1){var n=e[t];return n.pointIndex=t,n}return null}var t=e.map(function(e,t){return a(e,t)}),r=n(t.lastIndexOf(o.domain()[1])),i=n(t.indexOf(o.domain()[0])),s=n(t.length-1);return[i,r,s].filter(function(e){return e!=null})});S.enter().append("circle"),S.exit().remove(),S.attr("cx",function(e,t){return s(u(e,e.pointIndex))}).attr("cy",function(e,t){return o(a(e,e.pointIndex))}).attr("r",2).attr("class",function(e,t){return u(e,e.pointIndex)==s.domain()[1]?"nv-point nv-currentValue":a(e,e.pointIndex)==o.domain()[0]?"nv-point nv-minValue":"nv-point nv-maxValue"})}),d}var t={top:2,right:0,bottom:2,left:0},n=400,r=32,i=!0,s=d3.scale.linear(),o=d3.scale.linear(),u=function(e){return e.x},a=function(e){return e.y},f=e.utils.getColor(["#000"]),l,c,h,p;return d.options=e.utils.optionsFunc.bind(d),d.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,d):t},d.width=function(e){return arguments.length?(n=e,d):n},d.height=function(e){return arguments.length?(r=e,d):r},d.x=function(e){return arguments.length?(u=d3.functor(e),d):u},d.y=function(e){return arguments.length?(a=d3.functor(e),d):a},d.xScale=function(e){return arguments.length?(s=e,d):s},d.yScale=function(e){return arguments.length?(o=e,d):o},d.xDomain=function(e){return arguments.length?(l=e,d):l},d.yDomain=function(e){return arguments.length?(c=e,d):c},d.xRange=function(e){return arguments.length?(h=e,d):h},d.yRange=function(e){return arguments.length?(p=e,d):p},d.animate=function(e){return arguments.length?(i=e,d):i},d.color=function(t){return arguments.length?(f=e.utils.getColor(t),d):f},d},e.models.sparklinePlus=function(){"use strict";function v(e){return e.each(function(c){function O(){if(a)return;var e=C.selectAll(".nv-hoverValue").data(u),r=e.enter().append("g").attr("class","nv-hoverValue").style("stroke-opacity",0).style("fill-opacity",0);e.exit().transition().duration(250).style("stroke-opacity",0).style("fill-opacity",0).remove(),e.attr("transform",function(e){return"translate("+s(t.x()(c[e],e))+",0)"}).transition().duration(250).style("stroke-opacity",1).style("fill-opacity",1);if(!u.length)return;r.append("line").attr("x1",0).attr("y1",-n.top).attr("x2",0).attr("y2",b),r.append("text").attr("class","nv-xValue").attr("x",-6).attr("y",-n.top).attr("text-anchor","end").attr("dy",".9em"),C.select(".nv-hoverValue .nv-xValue").text(f(t.x()(c[u[0]],u[0]))),r.append("text").attr("class","nv-yValue").attr("x",6).attr("y",-n.top).attr("text-anchor","start").attr("dy",".9em"),C.select(".nv-hoverValue .nv-yValue").text(l(t.y()(c[u[0]],u[0])))}function M(){function r(e,n){var r=Math.abs(t.x()(e[0],0)-n),i=0;for(var s=0;s2){var h=M.yScale().invert(i.mouseY),p=Infinity,d=null;c.forEach(function(e,t){if(h>=e.stackedValue.y0&&h<=e.stackedValue.y0+e.stackedValue.y){d=t;return}}),d!=null&&(c[d].highlight=!0)}var v=n.tickFormat()(M.x()(s,a)),m=t.style()=="expand"?function(e,t){return d3.format(".1%")(e)}:function(e,t){return r.tickFormat()(e)};o.tooltip.position({left:f+u.left,top:i.mouseY+u.top}).chartContainer(D.parentNode).enabled(g).valueFormatter(m).data({value:v,series:c})(),o.renderGuideLine(f)}),o.dispatch.on("elementMouseout",function(e){N.tooltipHide(),t.clearHighlights()}),N.on("tooltipShow",function(e){g&&O(e,D.parentNode)}),N.on("changeState",function(e){typeof e.disabled!="undefined"&&(y.forEach(function(t,n){t.disabled=e.disabled[n]}),S.disabled=e.disabled),typeof e.style!="undefined"&&t.style(e.style),M.update()})}),M}var t=e.models.stackedArea(),n=e.models.axis(),r=e.models.axis(),i=e.models.legend(),s=e.models.legend(),o=e.interactiveGuideline(),u={top:30,right:25,bottom:50,left:60},a=null,f=null,l=e.utils.defaultColor(),c=!0,h=!0,p=!0,d=!0,v=!1,m=!1,g=!0,y=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" on "+t+"

"},b,w,E=d3.format(",.2f"),S={style:t.style()},x=null,T="No Data Available.",N=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),C=250,k=["Stacked","Stream","Expanded"],L={},A=250;n.orient("bottom").tickPadding(7),r.orient(v?"right":"left"),s.updateState(!1);var O=function(i,s){var o=i.pos[0]+(s.offsetLeft||0),u=i.pos[1]+(s.offsetTop||0),a=n.tickFormat()(t.x()(i.point,i.pointIndex)),f=r.tickFormat()(t.y()(i.point,i.pointIndex)),l=y(i.series.key,a,f,i,M);e.tooltip.show([o,u],l,i.value<0?"n":"s",null,s)};return t.dispatch.on("tooltipShow",function(e){e.pos=[e.pos[0]+u.left,e.pos[1]+u.top],N.tooltipShow(e)}),t.dispatch.on("tooltipHide",function(e){N.tooltipHide(e)}),N.on("tooltipHide",function(){g&&e.tooltip.cleanup()}),M.dispatch=N,M.stacked=t,M.legend=i,M.controls=s,M.xAxis=n,M.yAxis=r,M.interactiveLayer=o,d3.rebind(M,t,"x","y","size","xScale","yScale","xDomain","yDomain","xRange","yRange","sizeDomain","interactive","useVoronoi","offset","order","style","clipEdge","forceX","forceY","forceSize","interpolate"),M.options=e.utils.optionsFunc.bind(M),M.margin=function(e){return arguments.length?(u.top=typeof e.top!="undefined"?e.top:u.top,u.right=typeof e.right!="undefined"?e.right:u.right,u.bottom=typeof e.bottom!="undefined"?e.bottom:u.bottom,u.left=typeof e.left!="undefined"?e.left:u.left,M):u},M.width=function(e){return arguments.length?(a=e,M):a},M.height=function(e){return arguments.length?(f=e,M):f},M.color=function(n){return arguments.length?(l=e.utils.getColor(n),i.color(l),t.color(l),M):l},M.showControls=function(e){return arguments.length?(c=e,M):c},M.showLegend=function(e){return arguments.length?(h=e,M):h},M.showXAxis=function(e){return arguments.length?(p=e,M):p},M.showYAxis=function(e){return arguments.length?(d=e,M):d},M.rightAlignYAxis=function(e){return arguments.length?(v=e,r.orient(e?"right":"left"),M):v},M.useInteractiveGuideline=function(e){return arguments.length?(m=e,e===!0&&(M.interactive(!1),M.useVoronoi(!1)),M):m},M.tooltip=function(e){return arguments.length?(y=e,M):y},M.tooltips=function(e){return arguments.length?(g=e,M):g},M.tooltipContent=function(e){return arguments.length?(y=e,M):y},M.state=function(e){return arguments.length?(S=e,M):S},M.defaultState=function(e){return arguments.length?(x=e,M):x},M.noData=function(e){return arguments.length?(T=e,M):T},M.transitionDuration=function(e){return arguments.length?(A=e,M):A},M.controlsData=function(e){return arguments.length?(k=e,M):k},M.controlLabels=function(e){return arguments.length?typeof e!="object"?L:(L=e,M):L},r.setTickFormat=r.tickFormat,r.tickFormat=function(e){return arguments.length?(E=e,r):E},M}})(); \ No newline at end of file +/*! nvd3 - v0.0.1 - 2013-11-07 */!function(){function a(a,b){return new Date(b,a+1,0).getDate()}function b(a,b,c){return function(d,e,f){var g=a(d),h=[];if(d>g&&b(g),f>1)for(;e>g;){var i=new Date(+g);0===c(i)%f&&h.push(i),b(g)}else for(;e>g;)h.push(new Date(+g)),b(g);return h}}var c=window.nv||{};c.version="1.1.14b",c.dev=!0,window.nv=c,c.tooltip=c.tooltip||{},c.utils=c.utils||{},c.models=c.models||{},c.charts={},c.graphs=[],c.logs={},c.dispatch=d3.dispatch("render_start","render_end"),c.dev&&(c.dispatch.on("render_start",function(){c.logs.startTime=+new Date}),c.dispatch.on("render_end",function(){c.logs.endTime=+new Date,c.logs.totalTime=c.logs.endTime-c.logs.startTime,c.log("total",c.logs.totalTime)})),c.log=function(){if(c.dev&&console.log&&console.log.apply)console.log.apply(console,arguments);else if(c.dev&&"function"==typeof console.log&&Function.prototype.bind){var a=Function.prototype.bind.call(console.log,console);a.apply(console,arguments)}return arguments[arguments.length-1]},c.render=function(a){a=a||1,c.render.active=!0,c.dispatch.render_start(),setTimeout(function(){for(var b,d,e=0;a>e&&(d=c.render.queue[e]);e++)b=d.generate(),typeof d.callback==typeof Function&&d.callback(b),c.graphs.push(b);c.render.queue.splice(0,e),c.render.queue.length?setTimeout(arguments.callee,0):(c.dispatch.render_end(),c.render.active=!1)},0)},c.render.active=!1,c.render.queue=[],c.addGraph=function(a){typeof arguments[0]==typeof Function&&(a={generate:arguments[0],callback:arguments[1]}),c.render.queue.push(a),c.render.active||c.render()},c.identity=function(a){return a},c.strip=function(a){return a.replace(/(\s|&)/g,"")},d3.time.monthEnd=function(a){return new Date(a.getFullYear(),a.getMonth(),0)},d3.time.monthEnds=b(d3.time.monthEnd,function(b){b.setUTCDate(b.getUTCDate()+1),b.setDate(a(b.getMonth()+1,b.getFullYear()))},function(a){return a.getMonth()}),c.interactiveGuideline=function(){"use strict";function a(l){l.each(function(l){function m(){var c=d3.mouse(this),d=c[0],e=c[1],i=!0,j=!1;if(k&&(d=d3.event.offsetX,e=d3.event.offsetY,"svg"!==d3.event.target.tagName&&(i=!1),d3.event.target.className.baseVal.match("nv-legend")&&(j=!0)),i&&(d-=f.left,e-=f.top),0>d||0>e||d>o||e>p||d3.event.relatedTarget&&void 0===d3.event.relatedTarget.ownerSVGElement||j){if(k&&d3.event.relatedTarget&&void 0===d3.event.relatedTarget.ownerSVGElement&&d3.event.relatedTarget.className.match(b.nvPointerEventsClass))return;return h.elementMouseout({mouseX:d,mouseY:e}),a.renderGuideLine(null),void 0}var l=g.invert(d);h.elementMousemove({mouseX:d,mouseY:e,pointXValue:l}),"dblclick"===d3.event.type&&h.elementDblclick({mouseX:d,mouseY:e,pointXValue:l})}var n=d3.select(this),o=d||960,p=e||400,q=n.selectAll("g.nv-wrap.nv-interactiveLineLayer").data([l]),r=q.enter().append("g").attr("class"," nv-wrap nv-interactiveLineLayer");r.append("g").attr("class","nv-interactiveGuideLine"),j&&(j.on("mousemove",m,!0).on("mouseout",m,!0).on("dblclick",m),a.renderGuideLine=function(a){if(i){var b=q.select(".nv-interactiveGuideLine").selectAll("line").data(null!=a?[c.utils.NaNtoZero(a)]:[],String);b.enter().append("line").attr("class","nv-guideline").attr("x1",function(a){return a}).attr("x2",function(a){return a}).attr("y1",p).attr("y2",0),b.exit().remove()}})})}var b=c.models.tooltip(),d=null,e=null,f={left:0,top:0},g=d3.scale.linear(),h=(d3.scale.linear(),d3.dispatch("elementMousemove","elementMouseout","elementDblclick")),i=!0,j=null,k=-1!==navigator.userAgent.indexOf("MSIE");return a.dispatch=h,a.tooltip=b,a.margin=function(b){return arguments.length?(f.top="undefined"!=typeof b.top?b.top:f.top,f.left="undefined"!=typeof b.left?b.left:f.left,a):f},a.width=function(b){return arguments.length?(d=b,a):d},a.height=function(b){return arguments.length?(e=b,a):e},a.xScale=function(b){return arguments.length?(g=b,a):g},a.showGuideLine=function(b){return arguments.length?(i=b,a):i},a.svgContainer=function(b){return arguments.length?(j=b,a):j},a},c.interactiveBisect=function(a,b,c){"use strict";if(!a instanceof Array)return null;"function"!=typeof c&&(c=function(a){return a.x});var d=d3.bisector(c).left,e=d3.max([0,d(a,b)-1]),f=c(a[e],e);if("undefined"==typeof f&&(f=e),f===b)return e;var g=d3.min([e+1,a.length-1]),h=c(a[g],g);return"undefined"==typeof h&&(h=g),Math.abs(h-b)>=Math.abs(f-b)?e:g},c.nearestValueIndex=function(a,b,c){"use strict";var d=1/0,e=null;return a.forEach(function(a,f){var g=Math.abs(b-a);d>=g&&c>g&&(d=g,e=f)}),e},function(){"use strict";window.nv.tooltip={},window.nv.models.tooltip=function(){function a(){if(l){var a=d3.select(l);"svg"!==a.node().tagName&&(a=a.select("svg"));var b=a.node()?a.attr("viewBox"):null;if(b){b=b.split(" ");var c=parseInt(a.style("width"))/b[2];n.left=n.left*c,n.top=n.top*c}}}function b(a){var b;b=l?d3.select(l):d3.select("body");var c=b.select(".nvtooltip");return null===c.node()&&(c=b.append("div").attr("class","nvtooltip "+(k?k:"xy-tooltip")).attr("id",p)),c.node().innerHTML=a,c.style("top",0).style("left",0).style("opacity",0),c.selectAll("div, table, td, tr").classed(q,!0),c.classed(q,!0),c.node()}function d(){if(o&&u(f)){a();var e=n.left,k=null!=j?j:n.top,p=b(t(f));if(m=p,l){var q=l.getElementsByTagName("svg")[0];q?q.getBoundingClientRect():l.getBoundingClientRect();var r={left:0,top:0};if(q){var s=q.getBoundingClientRect(),v=l.getBoundingClientRect(),w=s.top;if(0>w){var x=l.getBoundingClientRect();w=Math.abs(w)>x.height?0:w}r.top=Math.abs(w-v.top),r.left=Math.abs(s.left-v.left)}e+=l.offsetLeft+r.left-2*l.scrollLeft,k+=l.offsetTop+r.top-2*l.scrollTop}return i&&i>0&&(k=Math.floor(k/i)*i),c.tooltip.calcTooltipPosition([e,k],g,h,p),d}}var e=null,f=null,g="w",h=50,i=25,j=null,k=null,l=null,m=null,n={left:null,top:null},o=!0,p="nvtooltip-"+Math.floor(1e5*Math.random()),q="nv-pointer-events-none",r=function(a){return a},s=function(a){return a},t=function(a){if(null!=e)return e;if(null==a)return"";var b=d3.select(document.createElement("table")),c=b.selectAll("thead").data([a]).enter().append("thead");c.append("tr").append("td").attr("colspan",3).append("strong").classed("x-value",!0).html(s(a.value));var d=b.selectAll("tbody").data([a]).enter().append("tbody"),f=d.selectAll("tr").data(function(a){return a.series}).enter().append("tr").classed("highlight",function(a){return a.highlight});f.append("td").classed("legend-color-guide",!0).append("div").style("background-color",function(a){return a.color}),f.append("td").classed("key",!0).html(function(a){return a.key}),f.append("td").classed("value",!0).html(function(a,b){return r(a.value,b)}),f.selectAll("td").each(function(a){if(a.highlight){var b=d3.scale.linear().domain([0,1]).range(["#fff",a.color]),c=.6;d3.select(this).style("border-bottom-color",b(c)).style("border-top-color",b(c))}});var g=b.node().outerHTML;return void 0!==a.footer&&(g+=""),g},u=function(a){return a&&a.series&&a.series.length>0?!0:!1};return d.nvPointerEventsClass=q,d.content=function(a){return arguments.length?(e=a,d):e},d.tooltipElem=function(){return m},d.contentGenerator=function(a){return arguments.length?("function"==typeof a&&(t=a),d):t},d.data=function(a){return arguments.length?(f=a,d):f},d.gravity=function(a){return arguments.length?(g=a,d):g},d.distance=function(a){return arguments.length?(h=a,d):h},d.snapDistance=function(a){return arguments.length?(i=a,d):i},d.classes=function(a){return arguments.length?(k=a,d):k},d.chartContainer=function(a){return arguments.length?(l=a,d):l},d.position=function(a){return arguments.length?(n.left="undefined"!=typeof a.left?a.left:n.left,n.top="undefined"!=typeof a.top?a.top:n.top,d):n},d.fixedTop=function(a){return arguments.length?(j=a,d):j},d.enabled=function(a){return arguments.length?(o=a,d):o},d.valueFormatter=function(a){return arguments.length?("function"==typeof a&&(r=a),d):r},d.headerFormatter=function(a){return arguments.length?("function"==typeof a&&(s=a),d):s},d.id=function(){return p},d},c.tooltip.show=function(a,b,d,e,f,g){var h=document.createElement("div");h.className="nvtooltip "+(g?g:"xy-tooltip");var i=f;(!f||f.tagName.match(/g|svg/i))&&(i=document.getElementsByTagName("body")[0]),h.style.left=0,h.style.top=0,h.style.opacity=0,h.innerHTML=b,i.appendChild(h),f&&(a[0]=a[0]-f.scrollLeft,a[1]=a[1]-f.scrollTop),c.tooltip.calcTooltipPosition(a,d,e,h)},c.tooltip.findFirstNonSVGParent=function(a){for(;null!==a.tagName.match(/^g|svg$/i);)a=a.parentNode;return a},c.tooltip.findTotalOffsetTop=function(a,b){var c=b;do isNaN(a.offsetTop)||(c+=a.offsetTop);while(a=a.offsetParent);return c},c.tooltip.findTotalOffsetLeft=function(a,b){var c=b;do isNaN(a.offsetLeft)||(c+=a.offsetLeft);while(a=a.offsetParent);return c},c.tooltip.calcTooltipPosition=function(a,b,d,e){var f,g,h=parseInt(e.offsetHeight),i=parseInt(e.offsetWidth),j=c.utils.windowSize().width,k=c.utils.windowSize().height,l=window.pageYOffset,m=window.pageXOffset;k=window.innerWidth>=document.body.scrollWidth?k:k-16,j=window.innerHeight>=document.body.scrollHeight?j:j-16,b=b||"s",d=d||20;var n=function(a){return c.tooltip.findTotalOffsetTop(a,g)},o=function(a){return c.tooltip.findTotalOffsetLeft(a,f)};switch(b){case"e":f=a[0]-i-d,g=a[1]-h/2;var p=o(e),q=n(e);m>p&&(f=a[0]+d>m?a[0]+d:m-p+f),l>q&&(g=l-q+g),q+h>l+k&&(g=l+k-q+g-h);break;case"w":f=a[0]+d,g=a[1]-h/2;var p=o(e),q=n(e);p+i>j&&(f=a[0]-i-d),l>q&&(g=l+5),q+h>l+k&&(g=l+k-q+g-h);break;case"n":f=a[0]-i/2-5,g=a[1]+d;var p=o(e),q=n(e);m>p&&(f=m+5),p+i>j&&(f=f-i/2+5),q+h>l+k&&(g=l+k-q+g-h);break;case"s":f=a[0]-i/2,g=a[1]-h-d;var p=o(e),q=n(e);m>p&&(f=m+5),p+i>j&&(f=f-i/2+5),l>q&&(g=l);break;case"none":f=a[0],g=a[1]-d;var p=o(e),q=n(e)}return e.style.left=f+"px",e.style.top=g+"px",e.style.opacity=1,e.style.position="absolute",e},c.tooltip.cleanup=function(){for(var a=document.getElementsByClassName("nvtooltip"),b=[];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(){for(;b.length;){var a=b.pop();a.parentNode.removeChild(a)}},500)}}(),c.utils.windowSize=function(){var a={width:640,height:480};return document.body&&document.body.offsetWidth&&(a.width=document.body.offsetWidth,a.height=document.body.offsetHeight),"CSS1Compat"==document.compatMode&&document.documentElement&&document.documentElement.offsetWidth&&(a.width=document.documentElement.offsetWidth,a.height=document.documentElement.offsetHeight),window.innerWidth&&window.innerHeight&&(a.width=window.innerWidth,a.height=window.innerHeight),a},c.utils.windowResize=function(a){if(void 0!==a){var b=window.onresize;window.onresize=function(c){"function"==typeof b&&b(c),a(c)}}},c.utils.getColor=function(a){return arguments.length?"[object Array]"===Object.prototype.toString.call(a)?function(b,c){return b.color||a[c%a.length]}:a:c.utils.defaultColor()},c.utils.defaultColor=function(){var a=d3.scale.category20().range();return function(b,c){return b.color||a[c%a.length]}},c.utils.customTheme=function(a,b,c){b=b||function(a){return a.key},c=c||d3.scale.category20().range();var d=c.length;return function(e){var f=b(e);return d||(d=c.length),"undefined"!=typeof a[f]?"function"==typeof a[f]?a[f]():a[f]:c[--d]}},c.utils.pjax=function(a,b){function d(d){d3.html(d,function(d){var e=d3.select(b).node();e.parentNode.replaceChild(d3.select(d).select(b).node(),e),c.utils.pjax(a,b)})}d3.selectAll(a).on("click",function(){history.pushState(this.href,this.textContent,this.href),d(this.href),d3.event.preventDefault()}),d3.select(window).on("popstate",function(){d3.event.state&&d(d3.event.state)})},c.utils.calcApproxTextWidth=function(a){if(a instanceof d3.selection){var b=parseInt(a.style("font-size").replace("px","")),c=a.text().length;return.5*c*b}return 0},c.utils.NaNtoZero=function(a){return"number"!=typeof a||isNaN(a)||null===a||1/0===a?0:a},c.utils.optionsFunc=function(a){return a&&d3.map(a).forEach(function(a,b){"function"==typeof this[a]&&this[a](b)}.bind(this)),this},c.models.axis=function(){"use strict";function a(c){return c.each(function(a){var c=d3.select(this),f=c.selectAll("g.nv-wrap.nv-axis").data([a]),r=f.enter().append("g").attr("class","nvd3 nv-wrap nv-axis");r.append("g");var s=f.select("g");null!==o?b.ticks(o):("top"==b.orient()||"bottom"==b.orient())&&b.ticks(Math.abs(g.range()[1]-g.range()[0])/100),s.transition().call(b),q=q||b.scale();var t=b.tickFormat();null==t&&(t=q.tickFormat());var u=s.selectAll("text.nv-axislabel").data([h||null]);switch(u.exit().remove(),b.orient()){case"top":u.enter().append("text").attr("class","nv-axislabel");var v=2==g.range().length?g.range()[1]:g.range()[g.range().length-1]+(g.range()[1]-g.range()[0]);if(u.attr("text-anchor","middle").attr("y",0).attr("x",v/2),i){var w=f.selectAll("g.nv-axisMaxMin").data(g.domain());w.enter().append("g").attr("class","nv-axisMaxMin").append("text"),w.exit().remove(),w.attr("transform",function(a){return"translate("+g(a)+",0)"}).select("text").attr("dy","-0.5em").attr("y",-b.tickPadding()).attr("text-anchor","middle").text(function(a){var b=t(a);return(""+b).match("NaN")?"":b}),w.transition().attr("transform",function(a,b){return"translate("+g.range()[b]+",0)"})}break;case"bottom":var x=36,y=30,z=s.selectAll("g").select("text");if(k%360){z.each(function(){var a=this.getBBox().width;a>y&&(y=a)});var A=Math.abs(Math.sin(k*Math.PI/180)),x=(A?A*y:y)+30;z.attr("transform",function(){return"rotate("+k+" 0,0)"}).style("text-anchor",k%360>0?"start":"end")}u.enter().append("text").attr("class","nv-axislabel");var v=2==g.range().length?g.range()[1]:g.range()[g.range().length-1]+(g.range()[1]-g.range()[0]);if(u.attr("text-anchor","middle").attr("y",x).attr("x",v/2),i){var w=f.selectAll("g.nv-axisMaxMin").data([g.domain()[0],g.domain()[g.domain().length-1]]);w.enter().append("g").attr("class","nv-axisMaxMin").append("text"),w.exit().remove(),w.attr("transform",function(a){return"translate("+(g(a)+(n?g.rangeBand()/2:0))+",0)"}).select("text").attr("dy",".71em").attr("y",b.tickPadding()).attr("transform",function(){return"rotate("+k+" 0,0)"}).style("text-anchor",k?k%360>0?"start":"end":"middle").text(function(a){var b=t(a);return(""+b).match("NaN")?"":b}),w.transition().attr("transform",function(a){return"translate("+(g(a)+(n?g.rangeBand()/2:0))+",0)"})}m&&z.attr("transform",function(a,b){return"translate(0,"+(0==b%2?"0":"12")+")"});break;case"right":if(u.enter().append("text").attr("class","nv-axislabel"),u.style("text-anchor",l?"middle":"begin").attr("transform",l?"rotate(90)":"").attr("y",l?-Math.max(d.right,e)+12:-10).attr("x",l?g.range()[0]/2:b.tickPadding()),i){var w=f.selectAll("g.nv-axisMaxMin").data(g.domain());w.enter().append("g").attr("class","nv-axisMaxMin").append("text").style("opacity",0),w.exit().remove(),w.attr("transform",function(a){return"translate(0,"+g(a)+")"}).select("text").attr("dy",".32em").attr("y",0).attr("x",b.tickPadding()).style("text-anchor","start").text(function(a){var b=t(a);return(""+b).match("NaN")?"":b}),w.transition().attr("transform",function(a,b){return"translate(0,"+g.range()[b]+")"}).select("text").style("opacity",1)}break;case"left":if(u.enter().append("text").attr("class","nv-axislabel"),u.style("text-anchor",l?"middle":"end").attr("transform",l?"rotate(-90)":"").attr("y",l?-Math.max(d.left,e)+p:-10).attr("x",l?-g.range()[0]/2:-b.tickPadding()),i){var w=f.selectAll("g.nv-axisMaxMin").data(g.domain());w.enter().append("g").attr("class","nv-axisMaxMin").append("text").style("opacity",0),w.exit().remove(),w.attr("transform",function(a){return"translate(0,"+q(a)+")"}).select("text").attr("dy",".32em").attr("y",0).attr("x",-b.tickPadding()).attr("text-anchor","end").text(function(a){var b=t(a);return(""+b).match("NaN")?"":b}),w.transition().attr("transform",function(a,b){return"translate(0,"+g.range()[b]+")"}).select("text").style("opacity",1)}}if(u.text(function(a){return a}),!i||"left"!==b.orient()&&"right"!==b.orient()||(s.selectAll("g").each(function(a){d3.select(this).select("text").attr("opacity",1),(g(a)g.range()[0]-10)&&((a>1e-10||-1e-10>a)&&d3.select(this).attr("opacity",0),d3.select(this).select("text").attr("opacity",0))}),g.domain()[0]==g.domain()[1]&&0==g.domain()[0]&&f.selectAll("g.nv-axisMaxMin").style("opacity",function(a,b){return b?0:1})),i&&("top"===b.orient()||"bottom"===b.orient())){var B=[];f.selectAll("g.nv-axisMaxMin").each(function(a,b){try{b?B.push(g(a)-this.getBBox().width-4):B.push(g(a)+this.getBBox().width+4)}catch(c){b?B.push(g(a)-4):B.push(g(a)+4)}}),s.selectAll("g").each(function(a){(g(a)B[1])&&(a>1e-10||-1e-10>a?d3.select(this).remove():d3.select(this).select("text").remove())})}j&&s.selectAll(".tick").filter(function(a){return!parseFloat(Math.round(1e5*a.__data__)/1e6)&&void 0!==a.__data__}).classed("zero",!0),q=g.copy()}),a}var b=d3.svg.axis(),d={top:0,right:0,bottom:0,left:0},e=75,f=60,g=d3.scale.linear(),h=null,i=!0,j=!0,k=0,l=!0,m=!1,n=!1,o=null,p=12;b.scale(g).orient("bottom").tickFormat(function(a){return a});var q;return a.axis=b,d3.rebind(a,b,"orient","tickValues","tickSubdivide","tickSize","tickPadding","tickFormat"),d3.rebind(a,g,"domain","range","rangeBand","rangeBands"),a.options=c.utils.optionsFunc.bind(a),a.margin=function(b){return arguments.length?(d.top="undefined"!=typeof b.top?b.top:d.top,d.right="undefined"!=typeof b.right?b.right:d.right,d.bottom="undefined"!=typeof b.bottom?b.bottom:d.bottom,d.left="undefined"!=typeof b.left?b.left:d.left,a):d},a.width=function(b){return arguments.length?(e=b,a):e},a.ticks=function(b){return arguments.length?(o=b,a):o},a.height=function(b){return arguments.length?(f=b,a):f},a.axisLabel=function(b){return arguments.length?(h=b,a):h},a.showMaxMin=function(b){return arguments.length?(i=b,a):i},a.highlightZero=function(b){return arguments.length?(j=b,a):j},a.scale=function(c){return arguments.length?(g=c,b.scale(g),n="function"==typeof g.rangeBands,d3.rebind(a,g,"domain","range","rangeBand","rangeBands"),a):g},a.rotateYLabel=function(b){return arguments.length?(l=b,a):l},a.rotateLabels=function(b){return arguments.length?(k=b,a):k},a.staggerLabels=function(b){return arguments.length?(m=b,a):m},a.axisLabelDistance=function(b){return arguments.length?(p=b,a):p},a},c.models.historicalBar=function(){"use strict";function a(v){return v.each(function(a){var v=h-g.left-g.right,w=i-g.top-g.bottom,x=d3.select(this);k.domain(b||d3.extent(a[0].values.map(m).concat(o))),q?k.range(e||[.5*v/a[0].values.length,v*(a[0].values.length-.5)/a[0].values.length]):k.range(e||[0,v]),l.domain(d||d3.extent(a[0].values.map(n).concat(p))).range(f||[w,0]),k.domain()[0]===k.domain()[1]&&(k.domain()[0]?k.domain([k.domain()[0]-.01*k.domain()[0],k.domain()[1]+.01*k.domain()[1]]):k.domain([-1,1])),l.domain()[0]===l.domain()[1]&&(l.domain()[0]?l.domain([l.domain()[0]+.01*l.domain()[0],l.domain()[1]-.01*l.domain()[1]]):l.domain([-1,1]));var y=x.selectAll("g.nv-wrap.nv-historicalBar-"+j).data([a[0].values]),z=y.enter().append("g").attr("class","nvd3 nv-wrap nv-historicalBar-"+j),A=z.append("defs"),B=z.append("g"),C=y.select("g");B.append("g").attr("class","nv-bars"),y.attr("transform","translate("+g.left+","+g.top+")"),x.on("click",function(a,b){t.chartClick({data:a,index:b,pos:d3.event,id:j})}),A.append("clipPath").attr("id","nv-chart-clip-path-"+j).append("rect"),y.select("#nv-chart-clip-path-"+j+" rect").attr("width",v).attr("height",w),C.attr("clip-path",r?"url(#nv-chart-clip-path-"+j+")":"");var D=y.select(".nv-bars").selectAll(".nv-bar").data(function(a){return a},function(a,b){return m(a,b)});D.exit().remove(),D.enter().append("rect").attr("x",0).attr("y",function(a,b){return c.utils.NaNtoZero(l(Math.max(0,n(a,b))))}).attr("height",function(a,b){return c.utils.NaNtoZero(Math.abs(l(n(a,b))-l(0)))}).attr("transform",function(b,c){return"translate("+(k(m(b,c))-.45*(v/a[0].values.length))+",0)"}).on("mouseover",function(b,c){u&&(d3.select(this).classed("hover",!0),t.elementMouseover({point:b,series:a[0],pos:[k(m(b,c)),l(n(b,c))],pointIndex:c,seriesIndex:0,e:d3.event}))}).on("mouseout",function(b,c){u&&(d3.select(this).classed("hover",!1),t.elementMouseout({point:b,series:a[0],pointIndex:c,seriesIndex:0,e:d3.event}))}).on("click",function(a,b){u&&(t.elementClick({value:n(a,b),data:a,index:b,pos:[k(m(a,b)),l(n(a,b))],e:d3.event,id:j}),d3.event.stopPropagation())}).on("dblclick",function(a,b){u&&(t.elementDblClick({value:n(a,b),data:a,index:b,pos:[k(m(a,b)),l(n(a,b))],e:d3.event,id:j}),d3.event.stopPropagation())}),D.attr("fill",function(a,b){return s(a,b)}).attr("class",function(a,b,c){return(n(a,b)<0?"nv-bar negative":"nv-bar positive")+" nv-bar-"+c+"-"+b}).transition().attr("transform",function(b,c){return"translate("+(k(m(b,c))-.45*(v/a[0].values.length))+",0)"}).attr("width",.9*(v/a[0].values.length)),D.transition().attr("y",function(a,b){var d=n(a,b)<0?l(0):l(0)-l(n(a,b))<1?l(0)-1:l(n(a,b));return c.utils.NaNtoZero(d)}).attr("height",function(a,b){return c.utils.NaNtoZero(Math.max(Math.abs(l(n(a,b))-l(0)),1))})}),a}var b,d,e,f,g={top:0,right:0,bottom:0,left:0},h=960,i=500,j=Math.floor(1e4*Math.random()),k=d3.scale.linear(),l=d3.scale.linear(),m=function(a){return a.x},n=function(a){return a.y},o=[],p=[0],q=!1,r=!0,s=c.utils.defaultColor(),t=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout"),u=!0;return a.highlightPoint=function(a,b){d3.select(".nv-historicalBar-"+j).select(".nv-bars .nv-bar-0-"+a).classed("hover",b)},a.clearHighlights=function(){d3.select(".nv-historicalBar-"+j).select(".nv-bars .nv-bar.hover").classed("hover",!1)},a.dispatch=t,a.options=c.utils.optionsFunc.bind(a),a.x=function(b){return arguments.length?(m=b,a):m},a.y=function(b){return arguments.length?(n=b,a):n},a.margin=function(b){return arguments.length?(g.top="undefined"!=typeof b.top?b.top:g.top,g.right="undefined"!=typeof b.right?b.right:g.right,g.bottom="undefined"!=typeof b.bottom?b.bottom:g.bottom,g.left="undefined"!=typeof b.left?b.left:g.left,a):g},a.width=function(b){return arguments.length?(h=b,a):h},a.height=function(b){return arguments.length?(i=b,a):i},a.xScale=function(b){return arguments.length?(k=b,a):k},a.yScale=function(b){return arguments.length?(l=b,a):l},a.xDomain=function(c){return arguments.length?(b=c,a):b},a.yDomain=function(b){return arguments.length?(d=b,a):d},a.xRange=function(b){return arguments.length?(e=b,a):e},a.yRange=function(b){return arguments.length?(f=b,a):f},a.forceX=function(b){return arguments.length?(o=b,a):o},a.forceY=function(b){return arguments.length?(p=b,a):p},a.padData=function(b){return arguments.length?(q=b,a):q},a.clipEdge=function(b){return arguments.length?(r=b,a):r},a.color=function(b){return arguments.length?(s=c.utils.getColor(b),a):s},a.id=function(b){return arguments.length?(j=b,a):j},a.interactive=function(){return arguments.length?(u=!1,a):u},a},c.models.bullet=function(){"use strict";function a(c){return c.each(function(a,c){var d=m-b.left-b.right,o=n-b.top-b.bottom,r=d3.select(this),s=f.call(this,a,c).slice().sort(d3.descending),t=g.call(this,a,c).slice().sort(d3.descending),u=h.call(this,a,c).slice().sort(d3.descending),v=i.call(this,a,c).slice(),w=j.call(this,a,c).slice(),x=k.call(this,a,c).slice(),y=d3.scale.linear().domain(d3.extent(d3.merge([l,s]))).range(e?[d,0]:[0,d]);this.__chart__||d3.scale.linear().domain([0,1/0]).range(y.range()),this.__chart__=y;var z=d3.min(s),A=d3.max(s),B=s[1],C=r.selectAll("g.nv-wrap.nv-bullet").data([a]),D=C.enter().append("g").attr("class","nvd3 nv-wrap nv-bullet"),E=D.append("g"),F=C.select("g");E.append("rect").attr("class","nv-range nv-rangeMax"),E.append("rect").attr("class","nv-range nv-rangeAvg"),E.append("rect").attr("class","nv-range nv-rangeMin"),E.append("rect").attr("class","nv-measure"),E.append("path").attr("class","nv-markerTriangle"),C.attr("transform","translate("+b.left+","+b.top+")");var G=function(a){return Math.abs(y(a)-y(0))},H=function(a){return 0>a?y(a):y(0)};F.select("rect.nv-rangeMax").attr("height",o).attr("width",G(A>0?A:z)).attr("x",H(A>0?A:z)).datum(A>0?A:z),F.select("rect.nv-rangeAvg").attr("height",o).attr("width",G(B)).attr("x",H(B)).datum(B),F.select("rect.nv-rangeMin").attr("height",o).attr("width",G(A)).attr("x",H(A)).attr("width",G(A>0?z:A)).attr("x",H(A>0?z:A)).datum(A>0?z:A),F.select("rect.nv-measure").style("fill",p).attr("height",o/3).attr("y",o/3).attr("width",0>u?y(0)-y(u[0]):y(u[0])-y(0)).attr("x",H(u)).on("mouseover",function(){q.elementMouseover({value:u[0],label:x[0]||"Current",pos:[y(u[0]),o/2]})}).on("mouseout",function(){q.elementMouseout({value:u[0],label:x[0]||"Current"})});var I=o/6;t[0]?F.selectAll("path.nv-markerTriangle").attr("transform",function(){return"translate("+y(t[0])+","+o/2+")"}).attr("d","M0,"+I+"L"+I+","+-I+" "+-I+","+-I+"Z").on("mouseover",function(){q.elementMouseover({value:t[0],label:w[0]||"Previous",pos:[y(t[0]),o/2]})}).on("mouseout",function(){q.elementMouseout({value:t[0],label:w[0]||"Previous"})}):F.selectAll("path.nv-markerTriangle").remove(),C.selectAll(".nv-range").on("mouseover",function(a,b){var c=v[b]||(b?1==b?"Mean":"Minimum":"Maximum");q.elementMouseover({value:a,label:c,pos:[y(a),o/2]})}).on("mouseout",function(a,b){var c=v[b]||(b?1==b?"Mean":"Minimum":"Maximum");q.elementMouseout({value:a,label:c})})}),a}var b={top:0,right:0,bottom:0,left:0},d="left",e=!1,f=function(a){return a.ranges},g=function(a){return a.markers},h=function(a){return a.measures},i=function(a){return a.rangeLabels?a.rangeLabels:[]},j=function(a){return a.markerLabels?a.markerLabels:[]},k=function(a){return a.measureLabels?a.measureLabels:[]},l=[0],m=380,n=30,o=null,p=c.utils.getColor(["#1f77b4"]),q=d3.dispatch("elementMouseover","elementMouseout");return a.dispatch=q,a.options=c.utils.optionsFunc.bind(a),a.orient=function(b){return arguments.length?(d=b,e="right"==d||"bottom"==d,a):d},a.ranges=function(b){return arguments.length?(f=b,a):f},a.markers=function(b){return arguments.length?(g=b,a):g},a.measures=function(b){return arguments.length?(h=b,a):h},a.forceX=function(b){return arguments.length?(l=b,a):l},a.width=function(b){return arguments.length?(m=b,a):m},a.height=function(b){return arguments.length?(n=b,a):n},a.margin=function(c){return arguments.length?(b.top="undefined"!=typeof c.top?c.top:b.top,b.right="undefined"!=typeof c.right?c.right:b.right,b.bottom="undefined"!=typeof c.bottom?c.bottom:b.bottom,b.left="undefined"!=typeof c.left?c.left:b.left,a):b},a.tickFormat=function(b){return arguments.length?(o=b,a):o},a.color=function(b){return arguments.length?(p=c.utils.getColor(b),a):p},a},c.models.bulletChart=function(){"use strict";function a(c){return c.each(function(d,n){var r=d3.select(this),s=(j||parseInt(r.style("width"))||960)-f.left-f.right,t=k-f.top-f.bottom,u=this;if(a.update=function(){a(c)},a.container=this,!d||!g.call(this,d,n)){var v=r.selectAll(".nv-noData").data([o]);return v.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),v.attr("x",f.left+s/2).attr("y",18+f.top+t/2).text(function(a){return a}),a}r.selectAll(".nv-noData").remove();var w=g.call(this,d,n).slice().sort(d3.descending),x=h.call(this,d,n).slice().sort(d3.descending),y=i.call(this,d,n).slice().sort(d3.descending),z=r.selectAll("g.nv-wrap.nv-bulletChart").data([d]),A=z.enter().append("g").attr("class","nvd3 nv-wrap nv-bulletChart"),B=A.append("g"),C=z.select("g");B.append("g").attr("class","nv-bulletWrap"),B.append("g").attr("class","nv-titles"),z.attr("transform","translate("+f.left+","+f.top+")");var D=d3.scale.linear().domain([0,Math.max(w[0],x[0],y[0])]).range(e?[s,0]:[0,s]),E=this.__chart__||d3.scale.linear().domain([0,1/0]).range(D.range());this.__chart__=D;var F=B.select(".nv-titles").append("g").attr("text-anchor","end").attr("transform","translate(-6,"+(k-f.top-f.bottom)/2+")");F.append("text").attr("class","nv-title").text(function(a){return a.title}),F.append("text").attr("class","nv-subtitle").attr("dy","1em").text(function(a){return a.subtitle}),b.width(s).height(t);var G=C.select(".nv-bulletWrap");d3.transition(G).call(b);var H=l||D.tickFormat(s/100),I=C.selectAll("g.nv-tick").data(D.ticks(s/50),function(a){return this.textContent||H(a)}),J=I.enter().append("g").attr("class","nv-tick").attr("transform",function(a){return"translate("+E(a)+",0)"}).style("opacity",1e-6);J.append("line").attr("y1",t).attr("y2",7*t/6),J.append("text").attr("text-anchor","middle").attr("dy","1em").attr("y",7*t/6).text(H);var K=d3.transition(I).attr("transform",function(a){return"translate("+D(a)+",0)"}).style("opacity",1);K.select("line").attr("y1",t).attr("y2",7*t/6),K.select("text").attr("y",7*t/6),d3.transition(I.exit()).attr("transform",function(a){return"translate("+D(a)+",0)"}).style("opacity",1e-6).remove(),p.on("tooltipShow",function(a){a.key=d.title,m&&q(a,u.parentNode)})}),d3.timer.flush(),a}var b=c.models.bullet(),d="left",e=!1,f={top:5,right:40,bottom:20,left:120},g=function(a){return a.ranges},h=function(a){return a.markers},i=function(a){return a.measures},j=null,k=55,l=null,m=!0,n=function(a,b,c){return"

"+b+"

"+"

"+c+"

"},o="No Data Available.",p=d3.dispatch("tooltipShow","tooltipHide"),q=function(b,d){var e=b.pos[0]+(d.offsetLeft||0)+f.left,g=b.pos[1]+(d.offsetTop||0)+f.top,h=n(b.key,b.label,b.value,b,a);c.tooltip.show([e,g],h,b.value<0?"e":"w",null,d)};return b.dispatch.on("elementMouseover.tooltip",function(a){p.tooltipShow(a)}),b.dispatch.on("elementMouseout.tooltip",function(a){p.tooltipHide(a)}),p.on("tooltipHide",function(){m&&c.tooltip.cleanup()}),a.dispatch=p,a.bullet=b,d3.rebind(a,b,"color"),a.options=c.utils.optionsFunc.bind(a),a.orient=function(b){return arguments.length?(d=b,e="right"==d||"bottom"==d,a):d},a.ranges=function(b){return arguments.length?(g=b,a):g},a.markers=function(b){return arguments.length?(h=b,a):h},a.measures=function(b){return arguments.length?(i=b,a):i},a.width=function(b){return arguments.length?(j=b,a):j},a.height=function(b){return arguments.length?(k=b,a):k},a.margin=function(b){return arguments.length?(f.top="undefined"!=typeof b.top?b.top:f.top,f.right="undefined"!=typeof b.right?b.right:f.right,f.bottom="undefined"!=typeof b.bottom?b.bottom:f.bottom,f.left="undefined"!=typeof b.left?b.left:f.left,a):f},a.tickFormat=function(b){return arguments.length?(l=b,a):l},a.tooltips=function(b){return arguments.length?(m=b,a):m},a.tooltipContent=function(b){return arguments.length?(n=b,a):n},a.noData=function(b){return arguments.length?(o=b,a):o},a},c.models.cumulativeLineChart=function(){"use strict";function a(x){return x.each(function(x){function I(){d3.select(a.container).style("cursor","ew-resize")}function J(){G.x=d3.event.x,G.i=Math.round(F.invert(G.x)),L()}function K(){d3.select(a.container).style("cursor","auto"),z.index=G.i,D.stateChange(z)}function L(){db.data([G]);var b=a.transitionDuration();a.transitionDuration(0),a.update(),a.transitionDuration(b)}var M=d3.select(this).classed("nv-chart-"+y,!0),N=this,O=(n||parseInt(M.style("width"))||960)-l.left-l.right,P=(o||parseInt(M.style("height"))||400)-l.top-l.bottom;if(a.update=function(){M.transition().duration(E).call(a)},a.container=this,z.disabled=x.map(function(a){return!!a.disabled}),!A){var Q;A={};for(Q in z)A[Q]=z[Q]instanceof Array?z[Q].slice(0):z[Q]}var R=d3.behavior.drag().on("dragstart",I).on("drag",J).on("dragend",K);if(!(x&&x.length&&x.filter(function(a){return a.values.length}).length)){var S=M.selectAll(".nv-noData").data([B]);return S.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),S.attr("x",l.left+O/2).attr("y",l.top+P/2).text(function(a){return a}),a}if(M.selectAll(".nv-noData").remove(),d=f.xScale(),e=f.yScale(),w)f.yDomain(null);else{var T=x.filter(function(a){return!a.disabled}).map(function(a){var b=d3.extent(a.values,f.y());return b[0]<-.95&&(b[0]=-.95),[(b[0]-b[1])/(1+b[1]),(b[1]-b[0])/(1+b[0])]}),U=[d3.min(T,function(a){return a[0]}),d3.max(T,function(a){return a[1]})];f.yDomain(U)}F.domain([0,x[0].values.length-1]).range([0,O]).clamp(!0);var x=b(G.i,x),V=v?"none":"all",W=M.selectAll("g.nv-wrap.nv-cumulativeLine").data([x]),X=W.enter().append("g").attr("class","nvd3 nv-wrap nv-cumulativeLine").append("g"),Y=W.select("g"); +if(X.append("g").attr("class","nv-interactive"),X.append("g").attr("class","nv-x nv-axis").style("pointer-events","none"),X.append("g").attr("class","nv-y nv-axis"),X.append("g").attr("class","nv-background"),X.append("g").attr("class","nv-linesWrap").style("pointer-events",V),X.append("g").attr("class","nv-avgLinesWrap").style("pointer-events","none"),X.append("g").attr("class","nv-legendWrap"),X.append("g").attr("class","nv-controlsWrap"),p&&(i.width(O),Y.select(".nv-legendWrap").datum(x).call(i),l.top!=i.height()&&(l.top=i.height(),P=(o||parseInt(M.style("height"))||400)-l.top-l.bottom),Y.select(".nv-legendWrap").attr("transform","translate(0,"+-l.top+")")),u){var Z=[{key:"Re-scale y-axis",disabled:!w}];j.width(140).color(["#444","#444","#444"]),Y.select(".nv-controlsWrap").datum(Z).attr("transform","translate(0,"+-l.top+")").call(j)}W.attr("transform","translate("+l.left+","+l.top+")"),s&&Y.select(".nv-y.nv-axis").attr("transform","translate("+O+",0)");var $=x.filter(function(a){return a.tempDisabled});W.select(".tempDisabled").remove(),$.length&&W.append("text").attr("class","tempDisabled").attr("x",O/2).attr("y","-.71em").style("text-anchor","end").text($.map(function(a){return a.key}).join(", ")+" values cannot be calculated for this time period."),v&&(k.width(O).height(P).margin({left:l.left,top:l.top}).svgContainer(M).xScale(d),W.select(".nv-interactive").call(k)),X.select(".nv-background").append("rect"),Y.select(".nv-background rect").attr("width",O).attr("height",P),f.y(function(a){return a.display.y}).width(O).height(P).color(x.map(function(a,b){return a.color||m(a,b)}).filter(function(a,b){return!x[b].disabled&&!x[b].tempDisabled}));var _=Y.select(".nv-linesWrap").datum(x.filter(function(a){return!a.disabled&&!a.tempDisabled}));_.call(f),x.forEach(function(a,b){a.seriesIndex=b});var ab=x.filter(function(a){return!a.disabled&&!!C(a)}),bb=Y.select(".nv-avgLinesWrap").selectAll("line").data(ab,function(a){return a.key}),cb=function(a){var b=e(C(a));return 0>b?0:b>P?P:b};bb.enter().append("line").style("stroke-width",2).style("stroke-dasharray","10,10").style("stroke",function(a){return f.color()(a,a.seriesIndex)}).attr("x1",0).attr("x2",O).attr("y1",cb).attr("y2",cb),bb.style("stroke-opacity",function(a){var b=e(C(a));return 0>b||b>P?0:1}).attr("x1",0).attr("x2",O).attr("y1",cb).attr("y2",cb),bb.exit().remove();var db=_.selectAll(".nv-indexLine").data([G]);db.enter().append("rect").attr("class","nv-indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).style("pointer-events","all").call(R),db.attr("transform",function(a){return"translate("+F(a.i)+",0)"}).attr("height",P),q&&(g.scale(d).ticks(Math.min(x[0].values.length,O/70)).tickSize(-P,0),Y.select(".nv-x.nv-axis").attr("transform","translate(0,"+e.range()[0]+")"),d3.transition(Y.select(".nv-x.nv-axis")).call(g)),r&&(h.scale(e).ticks(P/36).tickSize(-O,0),d3.transition(Y.select(".nv-y.nv-axis")).call(h)),Y.select(".nv-background rect").on("click",function(){G.x=d3.mouse(this)[0],G.i=Math.round(F.invert(G.x)),z.index=G.i,D.stateChange(z),L()}),f.dispatch.on("elementClick",function(a){G.i=a.pointIndex,G.x=F(G.i),z.index=G.i,D.stateChange(z),L()}),j.dispatch.on("legendClick",function(b){b.disabled=!b.disabled,w=!b.disabled,z.rescaleY=w,D.stateChange(z),a.update()}),i.dispatch.on("stateChange",function(b){z.disabled=b.disabled,D.stateChange(z),a.update()}),k.dispatch.on("elementMousemove",function(b){f.clearHighlights();var d,e,i,j=[];if(x.filter(function(a,b){return a.seriesIndex=b,!a.disabled}).forEach(function(g,h){e=c.interactiveBisect(g.values,b.pointXValue,a.x()),f.highlightPoint(h,e,!0);var k=g.values[e];"undefined"!=typeof k&&("undefined"==typeof d&&(d=k),"undefined"==typeof i&&(i=a.xScale()(a.x()(k,e))),j.push({key:g.key,value:a.y()(k,e),color:m(g,g.seriesIndex)}))}),j.length>2){var n=a.yScale().invert(b.mouseY),o=Math.abs(a.yScale().domain()[0]-a.yScale().domain()[1]),p=.03*o,q=c.nearestValueIndex(j.map(function(a){return a.value}),n,p);null!==q&&(j[q].highlight=!0)}var r=g.tickFormat()(a.x()(d,e),e);k.tooltip.position({left:i+l.left,top:b.mouseY+l.top}).chartContainer(N.parentNode).enabled(t).valueFormatter(function(a){return h.tickFormat()(a)}).data({value:r,series:j})(),k.renderGuideLine(i)}),k.dispatch.on("elementMouseout",function(){D.tooltipHide(),f.clearHighlights()}),D.on("tooltipShow",function(a){t&&H(a,N.parentNode)}),D.on("changeState",function(b){"undefined"!=typeof b.disabled&&(x.forEach(function(a,c){a.disabled=b.disabled[c]}),z.disabled=b.disabled),"undefined"!=typeof b.index&&(G.i=b.index,G.x=F(G.i),z.index=b.index,db.data([G])),"undefined"!=typeof b.rescaleY&&(w=b.rescaleY),a.update()})}),a}function b(a,b){return b.map(function(b){if(!b.values)return b;var c=f.y()(b.values[a],a);return-.95>c?(b.tempDisabled=!0,b):(b.tempDisabled=!1,b.values=b.values.map(function(a,b){return a.display={y:(f.y()(a,b)-c)/(1+c)},a}),b)})}var d,e,f=c.models.line(),g=c.models.axis(),h=c.models.axis(),i=c.models.legend(),j=c.models.legend(),k=c.interactiveGuideline(),l={top:30,right:30,bottom:50,left:60},m=c.utils.defaultColor(),n=null,o=null,p=!0,q=!0,r=!0,s=!1,t=!0,u=!0,v=!1,w=!0,x=function(a,b,c){return"

"+a+"

"+"

"+c+" at "+b+"

"},y=f.id(),z={index:0,rescaleY:w},A=null,B="No Data Available.",C=function(a){return a.average},D=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),E=250;g.orient("bottom").tickPadding(7),h.orient(s?"right":"left"),j.updateState(!1);var F=d3.scale.linear(),G={i:0,x:0},H=function(b,d){var e=b.pos[0]+(d.offsetLeft||0),i=b.pos[1]+(d.offsetTop||0),j=g.tickFormat()(f.x()(b.point,b.pointIndex)),k=h.tickFormat()(f.y()(b.point,b.pointIndex)),l=x(b.series.key,j,k,b,a);c.tooltip.show([e,i],l,null,null,d)};return f.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+l.left,a.pos[1]+l.top],D.tooltipShow(a)}),f.dispatch.on("elementMouseout.tooltip",function(a){D.tooltipHide(a)}),D.on("tooltipHide",function(){t&&c.tooltip.cleanup()}),a.dispatch=D,a.lines=f,a.legend=i,a.xAxis=g,a.yAxis=h,a.interactiveLayer=k,d3.rebind(a,f,"defined","isArea","x","y","xScale","yScale","size","xDomain","yDomain","xRange","yRange","forceX","forceY","interactive","clipEdge","clipVoronoi","useVoronoi","id"),a.options=c.utils.optionsFunc.bind(a),a.margin=function(b){return arguments.length?(l.top="undefined"!=typeof b.top?b.top:l.top,l.right="undefined"!=typeof b.right?b.right:l.right,l.bottom="undefined"!=typeof b.bottom?b.bottom:l.bottom,l.left="undefined"!=typeof b.left?b.left:l.left,a):l},a.width=function(b){return arguments.length?(n=b,a):n},a.height=function(b){return arguments.length?(o=b,a):o},a.color=function(b){return arguments.length?(m=c.utils.getColor(b),i.color(m),a):m},a.rescaleY=function(b){return arguments.length?(w=b,a):w},a.showControls=function(b){return arguments.length?(u=b,a):u},a.useInteractiveGuideline=function(b){return arguments.length?(v=b,b===!0&&(a.interactive(!1),a.useVoronoi(!1)),a):v},a.showLegend=function(b){return arguments.length?(p=b,a):p},a.showXAxis=function(b){return arguments.length?(q=b,a):q},a.showYAxis=function(b){return arguments.length?(r=b,a):r},a.rightAlignYAxis=function(b){return arguments.length?(s=b,h.orient(b?"right":"left"),a):s},a.tooltips=function(b){return arguments.length?(t=b,a):t},a.tooltipContent=function(b){return arguments.length?(x=b,a):x},a.state=function(b){return arguments.length?(z=b,a):z},a.defaultState=function(b){return arguments.length?(A=b,a):A},a.noData=function(b){return arguments.length?(B=b,a):B},a.average=function(b){return arguments.length?(C=b,a):C},a.transitionDuration=function(b){return arguments.length?(E=b,a):E},a},c.models.discreteBar=function(){"use strict";function a(c){return c.each(function(a){var c=j-i.left-i.right,l=k-i.top-i.bottom,w=d3.select(this);a.forEach(function(a,b){a.values.forEach(function(a){a.series=b})});var x=b&&d?[]:a.map(function(a){return a.values.map(function(a,b){return{x:o(a,b),y:p(a,b),y0:a.y0}})});m.domain(b||d3.merge(x).map(function(a){return a.x})).rangeBands(e||[0,c],.1),n.domain(d||d3.extent(d3.merge(x).map(function(a){return a.y}).concat(q))),s?n.range(f||[l-(n.domain()[0]<0?12:0),n.domain()[1]>0?12:0]):n.range(f||[l,0]),g=g||m,h=h||n.copy().range([n(0),n(0)]);var y=w.selectAll("g.nv-wrap.nv-discretebar").data([a]),z=y.enter().append("g").attr("class","nvd3 nv-wrap nv-discretebar"),A=z.append("g");y.select("g"),A.append("g").attr("class","nv-groups"),y.attr("transform","translate("+i.left+","+i.top+")");var B=y.select(".nv-groups").selectAll(".nv-group").data(function(a){return a},function(a){return a.key});B.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),B.exit().transition().style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),B.attr("class",function(a,b){return"nv-group nv-series-"+b}).classed("hover",function(a){return a.hover}),B.transition().style("stroke-opacity",1).style("fill-opacity",.75);var C=B.selectAll("g.nv-bar").data(function(a){return a.values});C.exit().remove();var D=C.enter().append("g").attr("transform",function(a,b){return"translate("+(m(o(a,b))+.05*m.rangeBand())+", "+n(0)+")"}).on("mouseover",function(b,c){d3.select(this).classed("hover",!0),u.elementMouseover({value:p(b,c),point:b,series:a[b.series],pos:[m(o(b,c))+m.rangeBand()*(b.series+.5)/a.length,n(p(b,c))],pointIndex:c,seriesIndex:b.series,e:d3.event})}).on("mouseout",function(b,c){d3.select(this).classed("hover",!1),u.elementMouseout({value:p(b,c),point:b,series:a[b.series],pointIndex:c,seriesIndex:b.series,e:d3.event})}).on("click",function(b,c){u.elementClick({value:p(b,c),point:b,series:a[b.series],pos:[m(o(b,c))+m.rangeBand()*(b.series+.5)/a.length,n(p(b,c))],pointIndex:c,seriesIndex:b.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(b,c){u.elementDblClick({value:p(b,c),point:b,series:a[b.series],pos:[m(o(b,c))+m.rangeBand()*(b.series+.5)/a.length,n(p(b,c))],pointIndex:c,seriesIndex:b.series,e:d3.event}),d3.event.stopPropagation()});D.append("rect").attr("height",0).attr("width",.9*m.rangeBand()/a.length),s?(D.append("text").attr("text-anchor","middle"),C.select("text").text(function(a,b){return t(p(a,b))}).transition().attr("x",.9*m.rangeBand()/2).attr("y",function(a,b){return p(a,b)<0?n(p(a,b))-n(0)+12:-4})):C.selectAll("text").remove(),C.attr("class",function(a,b){return p(a,b)<0?"nv-bar negative":"nv-bar positive"}).style("fill",function(a,b){return a.color||r(a,b)}).style("stroke",function(a,b){return a.color||r(a,b)}).select("rect").attr("class",v).transition().attr("width",.9*m.rangeBand()/a.length),C.transition().attr("transform",function(a,b){var c=m(o(a,b))+.05*m.rangeBand(),d=p(a,b)<0?n(0):n(0)-n(p(a,b))<1?n(0)-1:n(p(a,b));return"translate("+c+", "+d+")"}).select("rect").attr("height",function(a,b){return Math.max(Math.abs(n(p(a,b))-n(d&&d[0]||0))||1)}),g=m.copy(),h=n.copy()}),a}var b,d,e,f,g,h,i={top:0,right:0,bottom:0,left:0},j=960,k=500,l=Math.floor(1e4*Math.random()),m=d3.scale.ordinal(),n=d3.scale.linear(),o=function(a){return a.x},p=function(a){return a.y},q=[0],r=c.utils.defaultColor(),s=!1,t=d3.format(",.2f"),u=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout"),v="discreteBar";return a.dispatch=u,a.options=c.utils.optionsFunc.bind(a),a.x=function(b){return arguments.length?(o=b,a):o},a.y=function(b){return arguments.length?(p=b,a):p},a.margin=function(b){return arguments.length?(i.top="undefined"!=typeof b.top?b.top:i.top,i.right="undefined"!=typeof b.right?b.right:i.right,i.bottom="undefined"!=typeof b.bottom?b.bottom:i.bottom,i.left="undefined"!=typeof b.left?b.left:i.left,a):i},a.width=function(b){return arguments.length?(j=b,a):j},a.height=function(b){return arguments.length?(k=b,a):k},a.xScale=function(b){return arguments.length?(m=b,a):m},a.yScale=function(b){return arguments.length?(n=b,a):n},a.xDomain=function(c){return arguments.length?(b=c,a):b},a.yDomain=function(b){return arguments.length?(d=b,a):d},a.xRange=function(b){return arguments.length?(e=b,a):e},a.yRange=function(b){return arguments.length?(f=b,a):f},a.forceY=function(b){return arguments.length?(q=b,a):q},a.color=function(b){return arguments.length?(r=c.utils.getColor(b),a):r},a.id=function(b){return arguments.length?(l=b,a):l},a.showValues=function(b){return arguments.length?(s=b,a):s},a.valueFormat=function(b){return arguments.length?(t=b,a):t},a.rectClass=function(b){return arguments.length?(v=b,a):v},a},c.models.discreteBarChart=function(){"use strict";function a(c){return c.each(function(c){var k=d3.select(this),q=this,v=(i||parseInt(k.style("width"))||960)-h.left-h.right,w=(j||parseInt(k.style("height"))||400)-h.top-h.bottom;if(a.update=function(){s.beforeUpdate(),k.transition().duration(t).call(a)},a.container=this,!(c&&c.length&&c.filter(function(a){return a.values.length}).length)){var x=k.selectAll(".nv-noData").data([r]);return x.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),x.attr("x",h.left+v/2).attr("y",h.top+w/2).text(function(a){return a}),a}k.selectAll(".nv-noData").remove(),b=e.xScale(),d=e.yScale().clamp(!0);var y=k.selectAll("g.nv-wrap.nv-discreteBarWithAxes").data([c]),z=y.enter().append("g").attr("class","nvd3 nv-wrap nv-discreteBarWithAxes").append("g"),A=z.append("defs"),B=y.select("g");z.append("g").attr("class","nv-x nv-axis"),z.append("g").attr("class","nv-y nv-axis"),z.append("g").attr("class","nv-barsWrap"),B.attr("transform","translate("+h.left+","+h.top+")"),n&&B.select(".nv-y.nv-axis").attr("transform","translate("+v+",0)"),e.width(v).height(w);var C=B.select(".nv-barsWrap").datum(c.filter(function(a){return!a.disabled}));if(C.transition().call(e),A.append("clipPath").attr("id","nv-x-label-clip-"+e.id()).append("rect"),B.select("#nv-x-label-clip-"+e.id()+" rect").attr("width",b.rangeBand()*(o?2:1)).attr("height",16).attr("x",-b.rangeBand()/(o?1:2)),l){f.scale(b).ticks(v/100).tickSize(-w,0),B.select(".nv-x.nv-axis").attr("transform","translate(0,"+(d.range()[0]+(e.showValues()&&d.domain()[0]<0?16:0))+")"),B.select(".nv-x.nv-axis").transition().call(f);var D=B.select(".nv-x.nv-axis").selectAll("g");o&&D.selectAll("text").attr("transform",function(a,b,c){return"translate(0,"+(0==c%2?"5":"17")+")"})}m&&(g.scale(d).ticks(w/36).tickSize(-v,0),B.select(".nv-y.nv-axis").transition().call(g)),s.on("tooltipShow",function(a){p&&u(a,q.parentNode)})}),a}var b,d,e=c.models.discreteBar(),f=c.models.axis(),g=c.models.axis(),h={top:15,right:10,bottom:50,left:60},i=null,j=null,k=c.utils.getColor(),l=!0,m=!0,n=!1,o=!1,p=!0,q=function(a,b,c){return"

"+b+"

"+"

"+c+"

"},r="No Data Available.",s=d3.dispatch("tooltipShow","tooltipHide","beforeUpdate"),t=250;f.orient("bottom").highlightZero(!1).showMaxMin(!1).tickFormat(function(a){return a}),g.orient(n?"right":"left").tickFormat(d3.format(",.1f"));var u=function(b,d){var h=b.pos[0]+(d.offsetLeft||0),i=b.pos[1]+(d.offsetTop||0),j=f.tickFormat()(e.x()(b.point,b.pointIndex)),k=g.tickFormat()(e.y()(b.point,b.pointIndex)),l=q(b.series.key,j,k,b,a);c.tooltip.show([h,i],l,b.value<0?"n":"s",null,d)};return e.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+h.left,a.pos[1]+h.top],s.tooltipShow(a)}),e.dispatch.on("elementMouseout.tooltip",function(a){s.tooltipHide(a)}),s.on("tooltipHide",function(){p&&c.tooltip.cleanup()}),a.dispatch=s,a.discretebar=e,a.xAxis=f,a.yAxis=g,d3.rebind(a,e,"x","y","xDomain","yDomain","xRange","yRange","forceX","forceY","id","showValues","valueFormat"),a.options=c.utils.optionsFunc.bind(a),a.margin=function(b){return arguments.length?(h.top="undefined"!=typeof b.top?b.top:h.top,h.right="undefined"!=typeof b.right?b.right:h.right,h.bottom="undefined"!=typeof b.bottom?b.bottom:h.bottom,h.left="undefined"!=typeof b.left?b.left:h.left,a):h},a.width=function(b){return arguments.length?(i=b,a):i},a.height=function(b){return arguments.length?(j=b,a):j},a.color=function(b){return arguments.length?(k=c.utils.getColor(b),e.color(k),a):k},a.showXAxis=function(b){return arguments.length?(l=b,a):l},a.showYAxis=function(b){return arguments.length?(m=b,a):m},a.rightAlignYAxis=function(b){return arguments.length?(n=b,g.orient(b?"right":"left"),a):n},a.staggerLabels=function(b){return arguments.length?(o=b,a):o},a.tooltips=function(b){return arguments.length?(p=b,a):p},a.tooltipContent=function(b){return arguments.length?(q=b,a):q},a.noData=function(b){return arguments.length?(r=b,a):r},a.transitionDuration=function(b){return arguments.length?(t=b,a):t},a},c.models.distribution=function(){"use strict";function a(c){return c.each(function(a){var c=(e-("x"===g?d.left+d.right:d.top+d.bottom),"x"==g?"y":"x"),k=d3.select(this);b=b||j;var l=k.selectAll("g.nv-distribution").data([a]),m=l.enter().append("g").attr("class","nvd3 nv-distribution");m.append("g");var n=l.select("g");l.attr("transform","translate("+d.left+","+d.top+")");var o=n.selectAll("g.nv-dist").data(function(a){return a},function(a){return a.key});o.enter().append("g"),o.attr("class",function(a,b){return"nv-dist nv-series-"+b}).style("stroke",function(a,b){return i(a,b)});var p=o.selectAll("line.nv-dist"+g).data(function(a){return a.values});p.enter().append("line").attr(g+"1",function(a,c){return b(h(a,c))}).attr(g+"2",function(a,c){return b(h(a,c))}),o.exit().selectAll("line.nv-dist"+g).transition().attr(g+"1",function(a,b){return j(h(a,b))}).attr(g+"2",function(a,b){return j(h(a,b))}).style("stroke-opacity",0).remove(),p.attr("class",function(a,b){return"nv-dist"+g+" nv-dist"+g+"-"+b}).attr(c+"1",0).attr(c+"2",f),p.transition().attr(g+"1",function(a,b){return j(h(a,b))}).attr(g+"2",function(a,b){return j(h(a,b))}),b=j.copy()}),a}var b,d={top:0,right:0,bottom:0,left:0},e=400,f=8,g="x",h=function(a){return a[g]},i=c.utils.defaultColor(),j=d3.scale.linear();return a.options=c.utils.optionsFunc.bind(a),a.margin=function(b){return arguments.length?(d.top="undefined"!=typeof b.top?b.top:d.top,d.right="undefined"!=typeof b.right?b.right:d.right,d.bottom="undefined"!=typeof b.bottom?b.bottom:d.bottom,d.left="undefined"!=typeof b.left?b.left:d.left,a):d},a.width=function(b){return arguments.length?(e=b,a):e},a.axis=function(b){return arguments.length?(g=b,a):g},a.size=function(b){return arguments.length?(f=b,a):f},a.getData=function(b){return arguments.length?(h=d3.functor(b),a):h},a.scale=function(b){return arguments.length?(j=b,a):j},a.color=function(b){return arguments.length?(i=c.utils.getColor(b),a):i},a},c.models.historicalBarChart=function(){"use strict";function a(c){return c.each(function(r){var y=d3.select(this),z=this,A=(k||parseInt(y.style("width"))||960)-i.left-i.right,B=(l||parseInt(y.style("height"))||400)-i.top-i.bottom;if(a.update=function(){y.transition().duration(w).call(a)},a.container=this,s.disabled=r.map(function(a){return!!a.disabled}),!t){var C;t={};for(C in s)t[C]=s[C]instanceof Array?s[C].slice(0):s[C]}if(!(r&&r.length&&r.filter(function(a){return a.values.length}).length)){var D=y.selectAll(".nv-noData").data([u]);return D.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),D.attr("x",i.left+A/2).attr("y",i.top+B/2).text(function(a){return a}),a}y.selectAll(".nv-noData").remove(),b=e.xScale(),d=e.yScale();var E=y.selectAll("g.nv-wrap.nv-historicalBarChart").data([r]),F=E.enter().append("g").attr("class","nvd3 nv-wrap nv-historicalBarChart").append("g"),G=E.select("g");F.append("g").attr("class","nv-x nv-axis"),F.append("g").attr("class","nv-y nv-axis"),F.append("g").attr("class","nv-barsWrap"),F.append("g").attr("class","nv-legendWrap"),m&&(h.width(A),G.select(".nv-legendWrap").datum(r).call(h),i.top!=h.height()&&(i.top=h.height(),B=(l||parseInt(y.style("height"))||400)-i.top-i.bottom),E.select(".nv-legendWrap").attr("transform","translate(0,"+-i.top+")")),E.attr("transform","translate("+i.left+","+i.top+")"),p&&G.select(".nv-y.nv-axis").attr("transform","translate("+A+",0)"),e.width(A).height(B).color(r.map(function(a,b){return a.color||j(a,b)}).filter(function(a,b){return!r[b].disabled}));var H=G.select(".nv-barsWrap").datum(r.filter(function(a){return!a.disabled}));H.transition().call(e),n&&(f.scale(b).tickSize(-B,0),G.select(".nv-x.nv-axis").attr("transform","translate(0,"+d.range()[0]+")"),G.select(".nv-x.nv-axis").transition().call(f)),o&&(g.scale(d).ticks(B/36).tickSize(-A,0),G.select(".nv-y.nv-axis").transition().call(g)),h.dispatch.on("legendClick",function(b){b.disabled=!b.disabled,r.filter(function(a){return!a.disabled}).length||r.map(function(a){return a.disabled=!1,E.selectAll(".nv-series").classed("disabled",!1),a}),s.disabled=r.map(function(a){return!!a.disabled}),v.stateChange(s),c.transition().call(a)}),h.dispatch.on("legendDblclick",function(b){r.forEach(function(a){a.disabled=!0}),b.disabled=!1,s.disabled=r.map(function(a){return!!a.disabled}),v.stateChange(s),a.update()}),v.on("tooltipShow",function(a){q&&x(a,z.parentNode)}),v.on("changeState",function(b){"undefined"!=typeof b.disabled&&(r.forEach(function(a,c){a.disabled=b.disabled[c]}),s.disabled=b.disabled),a.update()})}),a}var b,d,e=c.models.historicalBar(),f=c.models.axis(),g=c.models.axis(),h=c.models.legend(),i={top:30,right:90,bottom:50,left:90},j=c.utils.defaultColor(),k=null,l=null,m=!1,n=!0,o=!0,p=!1,q=!0,r=function(a,b,c){return"

"+a+"

"+"

"+c+" at "+b+"

"},s={},t=null,u="No Data Available.",v=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),w=250;f.orient("bottom").tickPadding(7),g.orient(p?"right":"left");var x=function(b,d){if(d){var h=d3.select(d).select("svg"),i=h.node()?h.attr("viewBox"):null;if(i){i=i.split(" ");var j=parseInt(h.style("width"))/i[2];b.pos[0]=b.pos[0]*j,b.pos[1]=b.pos[1]*j}}var k=b.pos[0]+(d.offsetLeft||0),l=b.pos[1]+(d.offsetTop||0),m=f.tickFormat()(e.x()(b.point,b.pointIndex)),n=g.tickFormat()(e.y()(b.point,b.pointIndex)),o=r(b.series.key,m,n,b,a);c.tooltip.show([k,l],o,null,null,d)};return e.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+i.left,a.pos[1]+i.top],v.tooltipShow(a)}),e.dispatch.on("elementMouseout.tooltip",function(a){v.tooltipHide(a)}),v.on("tooltipHide",function(){q&&c.tooltip.cleanup()}),a.dispatch=v,a.bars=e,a.legend=h,a.xAxis=f,a.yAxis=g,d3.rebind(a,e,"defined","isArea","x","y","size","xScale","yScale","xDomain","yDomain","xRange","yRange","forceX","forceY","interactive","clipEdge","clipVoronoi","id","interpolate","highlightPoint","clearHighlights","interactive"),a.options=c.utils.optionsFunc.bind(a),a.margin=function(b){return arguments.length?(i.top="undefined"!=typeof b.top?b.top:i.top,i.right="undefined"!=typeof b.right?b.right:i.right,i.bottom="undefined"!=typeof b.bottom?b.bottom:i.bottom,i.left="undefined"!=typeof b.left?b.left:i.left,a):i},a.width=function(b){return arguments.length?(k=b,a):k},a.height=function(b){return arguments.length?(l=b,a):l},a.color=function(b){return arguments.length?(j=c.utils.getColor(b),h.color(j),a):j},a.showLegend=function(b){return arguments.length?(m=b,a):m},a.showXAxis=function(b){return arguments.length?(n=b,a):n},a.showYAxis=function(b){return arguments.length?(o=b,a):o},a.rightAlignYAxis=function(b){return arguments.length?(p=b,g.orient(b?"right":"left"),a):p},a.tooltips=function(b){return arguments.length?(q=b,a):q},a.tooltipContent=function(b){return arguments.length?(r=b,a):r},a.state=function(b){return arguments.length?(s=b,a):s},a.defaultState=function(b){return arguments.length?(t=b,a):t},a.noData=function(b){return arguments.length?(u=b,a):u},a.transitionDuration=function(b){return arguments.length?(w=b,a):w},a},c.models.indentedTree=function(){"use strict";function a(b){return b.each(function(b){function c(b,d,e){return d3.event.stopPropagation(),d3.event.shiftKey&&!e?(d3.event.shiftKey=!1,b.values&&b.values.forEach(function(a){(a.values||a._values)&&c(a,0,!0)}),!0):g(b)?(b.values?(b._values=b.values,b.values=null):(b.values=b._values,b._values=null),a.update(),void 0):!0}function d(a){return a._values&&a._values.length?n:a.values&&a.values.length?o:""}function f(a){return a._values&&a._values.length}function g(a){var b=a.values||a._values;return b&&b.length}var s=1,t=d3.select(this),u=d3.layout.tree().children(function(a){return a.values}).size([e,k]);a.update=function(){t.transition().duration(600).call(a)},b[0]||(b[0]={key:j});var v=u.nodes(b[0]),w=d3.select(this).selectAll("div").data([[v]]),x=w.enter().append("div").attr("class","nvd3 nv-wrap nv-indentedtree"),y=x.append("table"),z=w.select("table").attr("width","100%").attr("class",m);if(h){var A=y.append("thead"),B=A.append("tr");l.forEach(function(a){B.append("th").attr("width",a.width?a.width:"10%").style("text-align","numeric"==a.type?"right":"left").append("span").text(a.label)})}var C=z.selectAll("tbody").data(function(a){return a});C.enter().append("tbody"),s=d3.max(v,function(a){return a.depth}),u.size([e,s*k]);var D=C.selectAll("tr").data(function(a){return a.filter(function(a){return i&&!a.children?i(a):!0})},function(a){return a.id||a.id||++r});D.exit().remove(),D.select("img.nv-treeicon").attr("src",d).classed("folded",f);var E=D.enter().append("tr");l.forEach(function(a,b){var e=E.append("td").style("padding-left",function(a){return(b?0:a.depth*k+12+(d(a)?0:16))+"px"},"important").style("text-align","numeric"==a.type?"right":"left");0==b&&e.append("img").classed("nv-treeicon",!0).classed("nv-folded",f).attr("src",d).style("width","14px").style("height","14px").style("padding","0 1px").style("display",function(a){return d(a)?"inline-block":"none"}).on("click",c),e.each(function(c){!b&&q(c)?d3.select(this).append("a").attr("href",q).attr("class",d3.functor(a.classes)).append("span"):d3.select(this).append("span"),d3.select(this).select("span").attr("class",d3.functor(a.classes)).text(function(b){return a.format?a.format(b):b[a.key]||"-"})}),a.showCount&&(e.append("span").attr("class","nv-childrenCount"),D.selectAll("span.nv-childrenCount").text(function(a){return a.values&&a.values.length||a._values&&a._values.length?"("+(a.values&&a.values.filter(function(a){return i?i(a):!0}).length||a._values&&a._values.filter(function(a){return i?i(a):!0}).length||0)+")":""}))}),D.order().on("click",function(a){p.elementClick({row:this,data:a,pos:[a.x,a.y]})}).on("dblclick",function(a){p.elementDblclick({row:this,data:a,pos:[a.x,a.y]})}).on("mouseover",function(a){p.elementMouseover({row:this,data:a,pos:[a.x,a.y]})}).on("mouseout",function(a){p.elementMouseout({row:this,data:a,pos:[a.x,a.y]})})}),a}var b={top:0,right:0,bottom:0,left:0},d=960,e=500,f=c.utils.defaultColor(),g=Math.floor(1e4*Math.random()),h=!0,i=!1,j="No Data Available.",k=20,l=[{key:"key",label:"Name",type:"text"}],m=null,n="images/grey-plus.png",o="images/grey-minus.png",p=d3.dispatch("elementClick","elementDblclick","elementMouseover","elementMouseout"),q=function(a){return a.url},r=0;return a.options=c.utils.optionsFunc.bind(a),a.margin=function(c){return arguments.length?(b.top="undefined"!=typeof c.top?c.top:b.top,b.right="undefined"!=typeof c.right?c.right:b.right,b.bottom="undefined"!=typeof c.bottom?c.bottom:b.bottom,b.left="undefined"!=typeof c.left?c.left:b.left,a):b},a.width=function(b){return arguments.length?(d=b,a):d},a.height=function(b){return arguments.length?(e=b,a):e},a.color=function(b){return arguments.length?(f=c.utils.getColor(b),scatter.color(f),a):f},a.id=function(b){return arguments.length?(g=b,a):g},a.header=function(b){return arguments.length?(h=b,a):h},a.noData=function(b){return arguments.length?(j=b,a):j},a.filterZero=function(b){return arguments.length?(i=b,a):i},a.columns=function(b){return arguments.length?(l=b,a):l},a.tableClass=function(b){return arguments.length?(m=b,a):m},a.iconOpen=function(b){return arguments.length?(n=b,a):n},a.iconClose=function(b){return arguments.length?(o=b,a):o},a.getUrl=function(b){return arguments.length?(q=b,a):q},a},c.models.legend=function(){"use strict";function a(m){return m.each(function(a){var m=d-b.left-b.right,n=d3.select(this),o=n.selectAll("g.nv-legend").data([a]);o.enter().append("g").attr("class","nvd3 nv-legend").append("g");var p=o.select("g");o.attr("transform","translate("+b.left+","+b.top+")");var q=p.selectAll(".nv-series").data(function(a){return a}),r=q.enter().append("g").attr("class","nv-series").on("mouseover",function(a,b){l.legendMouseover(a,b)}).on("mouseout",function(a,b){l.legendMouseout(a,b)}).on("click",function(b,c){l.legendClick(b,c),j&&(k?(a.forEach(function(a){a.disabled=!0}),b.disabled=!1):(b.disabled=!b.disabled,a.every(function(a){return a.disabled})&&a.forEach(function(a){a.disabled=!1})),l.stateChange({disabled:a.map(function(a){return!!a.disabled})}))}).on("dblclick",function(b,c){l.legendDblclick(b,c),j&&(a.forEach(function(a){a.disabled=!0}),b.disabled=!1,l.stateChange({disabled:a.map(function(a){return!!a.disabled})}))});if(r.append("circle").style("stroke-width",2).attr("class","nv-legend-symbol").attr("r",5),r.append("text").attr("text-anchor","start").attr("class","nv-legend-text").attr("dy",".32em").attr("dx","8"),q.classed("disabled",function(a){return a.disabled}),q.exit().remove(),q.select("circle").style("fill",function(a,b){return a.color||g(a,b)}).style("stroke",function(a,b){return a.color||g(a,b)}),q.select("text").text(f),h){var s=[];q.each(function(){var a,b=d3.select(this).select("text");try{a=b.node().getComputedTextLength()}catch(d){a=c.utils.calcApproxTextWidth(b)}s.push(a+28)});for(var t=0,u=0,v=[];m>u&&tm&&t>1;){v=[],t--;for(var w=0;w(v[w%t]||0)&&(v[w%t]=s[w]);u=v.reduce(function(a,b){return a+b})}for(var x=[],y=0,z=0;t>y;y++)x[y]=z,z+=v[y];q.attr("transform",function(a,b){return"translate("+x[b%t]+","+(5+20*Math.floor(b/t))+")"}),i?p.attr("transform","translate("+(d-b.right-u)+","+b.top+")"):p.attr("transform","translate(0,"+b.top+")"),e=b.top+b.bottom+20*Math.ceil(s.length/t)}else{var A,B=5,C=5,D=0;q.attr("transform",function(){var a=d3.select(this).select("text").node().getComputedTextLength()+28;return A=C,dD&&(D=C),"translate("+A+","+B+")"}),p.attr("transform","translate("+(d-b.right-D)+","+b.top+")"),e=b.top+b.bottom+B+15}}),a}var b={top:5,right:0,bottom:5,left:0},d=400,e=20,f=function(a){return a.key},g=c.utils.defaultColor(),h=!0,i=!0,j=!0,k=!1,l=d3.dispatch("legendClick","legendDblclick","legendMouseover","legendMouseout","stateChange");return a.dispatch=l,a.options=c.utils.optionsFunc.bind(a),a.margin=function(c){return arguments.length?(b.top="undefined"!=typeof c.top?c.top:b.top,b.right="undefined"!=typeof c.right?c.right:b.right,b.bottom="undefined"!=typeof c.bottom?c.bottom:b.bottom,b.left="undefined"!=typeof c.left?c.left:b.left,a):b},a.width=function(b){return arguments.length?(d=b,a):d},a.height=function(b){return arguments.length?(e=b,a):e},a.key=function(b){return arguments.length?(f=b,a):f},a.color=function(b){return arguments.length?(g=c.utils.getColor(b),a):g},a.align=function(b){return arguments.length?(h=b,a):h},a.rightAlign=function(b){return arguments.length?(i=b,a):i},a.updateState=function(b){return arguments.length?(j=b,a):j},a.radioButtonMode=function(b){return arguments.length?(k=b,a):k},a},c.models.line=function(){"use strict";function a(r){return r.each(function(a){var r=g-f.left-f.right,s=h-f.top-f.bottom,t=d3.select(this);b=e.xScale(),d=e.yScale(),p=p||b,q=q||d;var u=t.selectAll("g.nv-wrap.nv-line").data([a]),v=u.enter().append("g").attr("class","nvd3 nv-wrap nv-line"),w=v.append("defs"),x=v.append("g"),y=u.select("g");x.append("g").attr("class","nv-groups"),x.append("g").attr("class","nv-scatterWrap"),u.attr("transform","translate("+f.left+","+f.top+")"),e.width(r).height(s);var z=u.select(".nv-scatterWrap");z.transition().call(e),w.append("clipPath").attr("id","nv-edge-clip-"+e.id()).append("rect"),u.select("#nv-edge-clip-"+e.id()+" rect").attr("width",r).attr("height",s),y.attr("clip-path",n?"url(#nv-edge-clip-"+e.id()+")":""),z.attr("clip-path",n?"url(#nv-edge-clip-"+e.id()+")":""); +var A=u.select(".nv-groups").selectAll(".nv-group").data(function(a){return a},function(a){return a.key});A.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),A.exit().remove(),A.attr("class",function(a,b){return"nv-group nv-series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return i(a,b)}).style("stroke",function(a,b){return i(a,b)}),A.transition().style("stroke-opacity",1).style("fill-opacity",.5);var B=A.selectAll("path.nv-area").data(function(a){return m(a)?[a]:[]});B.enter().append("path").attr("class","nv-area").attr("d",function(a){return d3.svg.area().interpolate(o).defined(l).x(function(a,b){return c.utils.NaNtoZero(p(j(a,b)))}).y0(function(a,b){return c.utils.NaNtoZero(q(k(a,b)))}).y1(function(){return q(d.domain()[0]<=0?d.domain()[1]>=0?0:d.domain()[1]:d.domain()[0])}).apply(this,[a.values])}),A.exit().selectAll("path.nv-area").remove(),B.transition().attr("d",function(a){return d3.svg.area().interpolate(o).defined(l).x(function(a,d){return c.utils.NaNtoZero(b(j(a,d)))}).y0(function(a,b){return c.utils.NaNtoZero(d(k(a,b)))}).y1(function(){return d(d.domain()[0]<=0?d.domain()[1]>=0?0:d.domain()[1]:d.domain()[0])}).apply(this,[a.values])});var C=A.selectAll("path.nv-line").data(function(a){return[a.values]});C.enter().append("path").attr("class","nv-line").attr("d",d3.svg.line().interpolate(o).defined(l).x(function(a,b){return c.utils.NaNtoZero(p(j(a,b)))}).y(function(a,b){return c.utils.NaNtoZero(q(k(a,b)))})),C.transition().attr("d",d3.svg.line().interpolate(o).defined(l).x(function(a,d){return c.utils.NaNtoZero(b(j(a,d)))}).y(function(a,b){return c.utils.NaNtoZero(d(k(a,b)))})),p=b.copy(),q=d.copy()}),a}var b,d,e=c.models.scatter(),f={top:0,right:0,bottom:0,left:0},g=960,h=500,i=c.utils.defaultColor(),j=function(a){return a.x},k=function(a){return a.y},l=function(a,b){return!isNaN(k(a,b))&&null!==k(a,b)},m=function(a){return a.area},n=!1,o="linear";e.size(16).sizeDomain([16,256]);var p,q;return a.dispatch=e.dispatch,a.scatter=e,d3.rebind(a,e,"id","interactive","size","xScale","yScale","zScale","xDomain","yDomain","xRange","yRange","sizeDomain","forceX","forceY","forceSize","clipVoronoi","useVoronoi","clipRadius","padData","highlightPoint","clearHighlights"),a.options=c.utils.optionsFunc.bind(a),a.margin=function(b){return arguments.length?(f.top="undefined"!=typeof b.top?b.top:f.top,f.right="undefined"!=typeof b.right?b.right:f.right,f.bottom="undefined"!=typeof b.bottom?b.bottom:f.bottom,f.left="undefined"!=typeof b.left?b.left:f.left,a):f},a.width=function(b){return arguments.length?(g=b,a):g},a.height=function(b){return arguments.length?(h=b,a):h},a.x=function(b){return arguments.length?(j=b,e.x(b),a):j},a.y=function(b){return arguments.length?(k=b,e.y(b),a):k},a.clipEdge=function(b){return arguments.length?(n=b,a):n},a.color=function(b){return arguments.length?(i=c.utils.getColor(b),e.color(i),a):i},a.interpolate=function(b){return arguments.length?(o=b,a):o},a.defined=function(b){return arguments.length?(l=b,a):l},a.isArea=function(b){return arguments.length?(m=d3.functor(b),a):m},a},c.models.lineChart=function(){"use strict";function a(t){return t.each(function(t){var A=d3.select(this),B=this,C=(l||parseInt(A.style("width"))||960)-j.left-j.right,D=(m||parseInt(A.style("height"))||400)-j.top-j.bottom;if(a.update=function(){A.transition().duration(y).call(a)},a.container=this,u.disabled=t.map(function(a){return!!a.disabled}),!v){var E;v={};for(E in u)v[E]=u[E]instanceof Array?u[E].slice(0):u[E]}if(!(t&&t.length&&t.filter(function(a){return a.values.length}).length)){var F=A.selectAll(".nv-noData").data([w]);return F.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),F.attr("x",j.left+C/2).attr("y",j.top+D/2).text(function(a){return a}),a}A.selectAll(".nv-noData").remove(),b=e.xScale(),d=e.yScale();var G=A.selectAll("g.nv-wrap.nv-lineChart").data([t]),H=G.enter().append("g").attr("class","nvd3 nv-wrap nv-lineChart").append("g"),I=G.select("g");H.append("rect").style("opacity",0),H.append("g").attr("class","nv-x nv-axis"),H.append("g").attr("class","nv-y nv-axis"),H.append("g").attr("class","nv-linesWrap"),H.append("g").attr("class","nv-legendWrap"),H.append("g").attr("class","nv-interactive"),I.select("rect").attr("width",C).attr("height",D),n&&(h.width(C),I.select(".nv-legendWrap").datum(t).call(h),j.top!=h.height()&&(j.top=h.height(),D=(m||parseInt(A.style("height"))||400)-j.top-j.bottom),G.select(".nv-legendWrap").attr("transform","translate(0,"+-j.top+")")),G.attr("transform","translate("+j.left+","+j.top+")"),q&&I.select(".nv-y.nv-axis").attr("transform","translate("+C+",0)"),r&&(i.width(C).height(D).margin({left:j.left,top:j.top}).svgContainer(A).xScale(b),G.select(".nv-interactive").call(i)),e.width(C).height(D).color(t.map(function(a,b){return a.color||k(a,b)}).filter(function(a,b){return!t[b].disabled}));var J=I.select(".nv-linesWrap").datum(t.filter(function(a){return!a.disabled}));J.transition().call(e),o&&(f.scale(b).ticks(C/100).tickSize(-D,0),I.select(".nv-x.nv-axis").attr("transform","translate(0,"+d.range()[0]+")"),I.select(".nv-x.nv-axis").transition().call(f)),p&&(g.scale(d).ticks(D/36).tickSize(-C,0),I.select(".nv-y.nv-axis").transition().call(g)),h.dispatch.on("stateChange",function(b){u=b,x.stateChange(u),a.update()}),i.dispatch.on("elementMousemove",function(b){e.clearHighlights();var d,h,l,m=[];if(t.filter(function(a,b){return a.seriesIndex=b,!a.disabled}).forEach(function(f,g){h=c.interactiveBisect(f.values,b.pointXValue,a.x()),e.highlightPoint(g,h,!0);var i=f.values[h];"undefined"!=typeof i&&("undefined"==typeof d&&(d=i),"undefined"==typeof l&&(l=a.xScale()(a.x()(i,h))),m.push({key:f.key,value:a.y()(i,h),color:k(f,f.seriesIndex)}))}),m.length>2){var n=a.yScale().invert(b.mouseY),o=Math.abs(a.yScale().domain()[0]-a.yScale().domain()[1]),p=.03*o,q=c.nearestValueIndex(m.map(function(a){return a.value}),n,p);null!==q&&(m[q].highlight=!0)}var r=f.tickFormat()(a.x()(d,h));i.tooltip.position({left:l+j.left,top:b.mouseY+j.top}).chartContainer(B.parentNode).enabled(s).valueFormatter(function(a){return g.tickFormat()(a)}).data({value:r,series:m})(),i.renderGuideLine(l)}),i.dispatch.on("elementMouseout",function(){x.tooltipHide(),e.clearHighlights()}),x.on("tooltipShow",function(a){s&&z(a,B.parentNode)}),x.on("changeState",function(b){"undefined"!=typeof b.disabled&&(t.forEach(function(a,c){a.disabled=b.disabled[c]}),u.disabled=b.disabled),a.update()})}),a}var b,d,e=c.models.line(),f=c.models.axis(),g=c.models.axis(),h=c.models.legend(),i=c.interactiveGuideline(),j={top:30,right:20,bottom:50,left:60},k=c.utils.defaultColor(),l=null,m=null,n=!0,o=!0,p=!0,q=!1,r=!1,s=!0,t=function(a,b,c){return"

"+a+"

"+"

"+c+" at "+b+"

"},u={},v=null,w="No Data Available.",x=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),y=250;f.orient("bottom").tickPadding(7),g.orient(q?"right":"left");var z=function(b,d){var h=b.pos[0]+(d.offsetLeft||0),i=b.pos[1]+(d.offsetTop||0),j=f.tickFormat()(e.x()(b.point,b.pointIndex)),k=g.tickFormat()(e.y()(b.point,b.pointIndex)),l=t(b.series.key,j,k,b,a);c.tooltip.show([h,i],l,null,null,d)};return e.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+j.left,a.pos[1]+j.top],x.tooltipShow(a)}),e.dispatch.on("elementMouseout.tooltip",function(a){x.tooltipHide(a)}),x.on("tooltipHide",function(){s&&c.tooltip.cleanup()}),a.dispatch=x,a.lines=e,a.legend=h,a.xAxis=f,a.yAxis=g,a.interactiveLayer=i,d3.rebind(a,e,"defined","isArea","x","y","size","xScale","yScale","xDomain","yDomain","xRange","yRange","forceX","forceY","interactive","clipEdge","clipVoronoi","useVoronoi","id","interpolate"),a.options=c.utils.optionsFunc.bind(a),a.margin=function(b){return arguments.length?(j.top="undefined"!=typeof b.top?b.top:j.top,j.right="undefined"!=typeof b.right?b.right:j.right,j.bottom="undefined"!=typeof b.bottom?b.bottom:j.bottom,j.left="undefined"!=typeof b.left?b.left:j.left,a):j},a.width=function(b){return arguments.length?(l=b,a):l},a.height=function(b){return arguments.length?(m=b,a):m},a.color=function(b){return arguments.length?(k=c.utils.getColor(b),h.color(k),a):k},a.showLegend=function(b){return arguments.length?(n=b,a):n},a.showXAxis=function(b){return arguments.length?(o=b,a):o},a.showYAxis=function(b){return arguments.length?(p=b,a):p},a.rightAlignYAxis=function(b){return arguments.length?(q=b,g.orient(b?"right":"left"),a):q},a.useInteractiveGuideline=function(b){return arguments.length?(r=b,b===!0&&(a.interactive(!1),a.useVoronoi(!1)),a):r},a.tooltips=function(b){return arguments.length?(s=b,a):s},a.tooltipContent=function(b){return arguments.length?(t=b,a):t},a.state=function(b){return arguments.length?(u=b,a):u},a.defaultState=function(b){return arguments.length?(v=b,a):v},a.noData=function(b){return arguments.length?(w=b,a):w},a.transitionDuration=function(b){return arguments.length?(y=b,a):y},a},c.models.linePlusBarChart=function(){"use strict";function a(c){return c.each(function(c){var o=d3.select(this),p=this,t=(m||parseInt(o.style("width"))||960)-l.left-l.right,z=(n||parseInt(o.style("height"))||400)-l.top-l.bottom;if(a.update=function(){o.transition().call(a)},u.disabled=c.map(function(a){return!!a.disabled}),!v){var A;v={};for(A in u)v[A]=u[A]instanceof Array?u[A].slice(0):u[A]}if(!(c&&c.length&&c.filter(function(a){return a.values.length}).length)){var B=o.selectAll(".nv-noData").data([w]);return B.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),B.attr("x",l.left+t/2).attr("y",l.top+z/2).text(function(a){return a}),a}o.selectAll(".nv-noData").remove();var C=c.filter(function(a){return!a.disabled&&a.bar}),D=c.filter(function(a){return!a.bar});b=D.filter(function(a){return!a.disabled}).length&&D.filter(function(a){return!a.disabled})[0].values.length?f.xScale():g.xScale(),d=g.yScale(),e=f.yScale();var E=d3.select(this).selectAll("g.nv-wrap.nv-linePlusBar").data([c]),F=E.enter().append("g").attr("class","nvd3 nv-wrap nv-linePlusBar").append("g"),G=E.select("g");F.append("g").attr("class","nv-x nv-axis"),F.append("g").attr("class","nv-y1 nv-axis"),F.append("g").attr("class","nv-y2 nv-axis"),F.append("g").attr("class","nv-barsWrap"),F.append("g").attr("class","nv-linesWrap"),F.append("g").attr("class","nv-legendWrap"),r&&(k.width(t/2),G.select(".nv-legendWrap").datum(c.map(function(a){return a.originalKey=void 0===a.originalKey?a.key:a.originalKey,a.key=a.originalKey+(a.bar?" (left axis)":" (right axis)"),a})).call(k),l.top!=k.height()&&(l.top=k.height(),z=(n||parseInt(o.style("height"))||400)-l.top-l.bottom),G.select(".nv-legendWrap").attr("transform","translate("+t/2+","+-l.top+")")),E.attr("transform","translate("+l.left+","+l.top+")"),f.width(t).height(z).color(c.map(function(a,b){return a.color||q(a,b)}).filter(function(a,b){return!c[b].disabled&&!c[b].bar})),g.width(t).height(z).color(c.map(function(a,b){return a.color||q(a,b)}).filter(function(a,b){return!c[b].disabled&&c[b].bar}));var H=G.select(".nv-barsWrap").datum(C.length?C:[{values:[]}]),I=G.select(".nv-linesWrap").datum(D[0]&&!D[0].disabled?D:[{values:[]}]);d3.transition(H).call(g),d3.transition(I).call(f),h.scale(b).ticks(t/100).tickSize(-z,0),G.select(".nv-x.nv-axis").attr("transform","translate(0,"+d.range()[0]+")"),d3.transition(G.select(".nv-x.nv-axis")).call(h),i.scale(d).ticks(z/36).tickSize(-t,0),d3.transition(G.select(".nv-y1.nv-axis")).style("opacity",C.length?1:0).call(i),j.scale(e).ticks(z/36).tickSize(C.length?0:-t,0),G.select(".nv-y2.nv-axis").style("opacity",D.length?1:0).attr("transform","translate("+t+",0)"),d3.transition(G.select(".nv-y2.nv-axis")).call(j),k.dispatch.on("stateChange",function(b){u=b,x.stateChange(u),a.update()}),x.on("tooltipShow",function(a){s&&y(a,p.parentNode)}),x.on("changeState",function(b){"undefined"!=typeof b.disabled&&(c.forEach(function(a,c){a.disabled=b.disabled[c]}),u.disabled=b.disabled),a.update()})}),a}var b,d,e,f=c.models.line(),g=c.models.historicalBar(),h=c.models.axis(),i=c.models.axis(),j=c.models.axis(),k=c.models.legend(),l={top:30,right:60,bottom:50,left:60},m=null,n=null,o=function(a){return a.x},p=function(a){return a.y},q=c.utils.defaultColor(),r=!0,s=!0,t=function(a,b,c){return"

"+a+"

"+"

"+c+" at "+b+"

"},u={},v=null,w="No Data Available.",x=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState");g.padData(!0),f.clipEdge(!1).padData(!0),h.orient("bottom").tickPadding(7).highlightZero(!1),i.orient("left"),j.orient("right");var y=function(b,d){var e=b.pos[0]+(d.offsetLeft||0),g=b.pos[1]+(d.offsetTop||0),k=h.tickFormat()(f.x()(b.point,b.pointIndex)),l=(b.series.bar?i:j).tickFormat()(f.y()(b.point,b.pointIndex)),m=t(b.series.key,k,l,b,a);c.tooltip.show([e,g],m,b.value<0?"n":"s",null,d)};return f.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+l.left,a.pos[1]+l.top],x.tooltipShow(a)}),f.dispatch.on("elementMouseout.tooltip",function(a){x.tooltipHide(a)}),g.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+l.left,a.pos[1]+l.top],x.tooltipShow(a)}),g.dispatch.on("elementMouseout.tooltip",function(a){x.tooltipHide(a)}),x.on("tooltipHide",function(){s&&c.tooltip.cleanup()}),a.dispatch=x,a.legend=k,a.lines=f,a.bars=g,a.xAxis=h,a.y1Axis=i,a.y2Axis=j,d3.rebind(a,f,"defined","size","clipVoronoi","interpolate"),a.options=c.utils.optionsFunc.bind(a),a.x=function(b){return arguments.length?(o=b,f.x(b),g.x(b),a):o},a.y=function(b){return arguments.length?(p=b,f.y(b),g.y(b),a):p},a.margin=function(b){return arguments.length?(l.top="undefined"!=typeof b.top?b.top:l.top,l.right="undefined"!=typeof b.right?b.right:l.right,l.bottom="undefined"!=typeof b.bottom?b.bottom:l.bottom,l.left="undefined"!=typeof b.left?b.left:l.left,a):l},a.width=function(b){return arguments.length?(m=b,a):m},a.height=function(b){return arguments.length?(n=b,a):n},a.color=function(b){return arguments.length?(q=c.utils.getColor(b),k.color(q),a):q},a.showLegend=function(b){return arguments.length?(r=b,a):r},a.tooltips=function(b){return arguments.length?(s=b,a):s},a.tooltipContent=function(b){return arguments.length?(t=b,a):t},a.state=function(b){return arguments.length?(u=b,a):u},a.defaultState=function(b){return arguments.length?(v=b,a):v},a.noData=function(b){return arguments.length?(w=b,a):w},a},c.models.lineWithFocusChart=function(){"use strict";function a(c){return c.each(function(c){function x(a){var b=+("e"==a),c=b?1:-1,d=I/3;return"M"+.5*c+","+d+"A6,6 0 0 "+b+" "+6.5*c+","+(d+6)+"V"+(2*d-6)+"A6,6 0 0 "+b+" "+.5*c+","+2*d+"Z"+"M"+2.5*c+","+(d+8)+"V"+(2*d-8)+"M"+4.5*c+","+(d+8)+"V"+(2*d-8)}function C(){n.empty()||n.extent(v),Q.data([n.empty()?e.domain():v]).each(function(a){var c=e(a[0])-b.range()[0],d=b.range()[1]-e(a[1]);d3.select(this).select(".left").attr("width",0>c?0:c),d3.select(this).select(".right").attr("x",e(a[1])).attr("width",0>d?0:d)})}function D(){v=n.empty()?null:n.extent();var a=n.empty()?e.domain():n.extent();if(!(Math.abs(a[0]-a[1])<=1)){z.brush({extent:a,brush:n}),C();var b=M.select(".nv-focus .nv-linesWrap").datum(c.filter(function(a){return!a.disabled}).map(function(b){return{key:b.key,values:b.values.filter(function(b,c){return g.x()(b,c)>=a[0]&&g.x()(b,c)<=a[1]})}}));b.transition().duration(A).call(g),M.select(".nv-focus .nv-x.nv-axis").transition().duration(A).call(i),M.select(".nv-focus .nv-y.nv-axis").transition().duration(A).call(j)}}var E=d3.select(this),F=this,G=(r||parseInt(E.style("width"))||960)-o.left-o.right,H=(s||parseInt(E.style("height"))||400)-o.top-o.bottom-t,I=t-p.top-p.bottom;if(a.update=function(){E.transition().duration(A).call(a)},a.container=this,!(c&&c.length&&c.filter(function(a){return a.values.length}).length)){var J=E.selectAll(".nv-noData").data([y]);return J.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),J.attr("x",o.left+G/2).attr("y",o.top+H/2).text(function(a){return a}),a}E.selectAll(".nv-noData").remove(),b=g.xScale(),d=g.yScale(),e=h.xScale(),f=h.yScale();var K=E.selectAll("g.nv-wrap.nv-lineWithFocusChart").data([c]),L=K.enter().append("g").attr("class","nvd3 nv-wrap nv-lineWithFocusChart").append("g"),M=K.select("g");L.append("g").attr("class","nv-legendWrap");var N=L.append("g").attr("class","nv-focus");N.append("g").attr("class","nv-x nv-axis"),N.append("g").attr("class","nv-y nv-axis"),N.append("g").attr("class","nv-linesWrap");var O=L.append("g").attr("class","nv-context");O.append("g").attr("class","nv-x nv-axis"),O.append("g").attr("class","nv-y nv-axis"),O.append("g").attr("class","nv-linesWrap"),O.append("g").attr("class","nv-brushBackground"),O.append("g").attr("class","nv-x nv-brush"),u&&(m.width(G),M.select(".nv-legendWrap").datum(c).call(m),o.top!=m.height()&&(o.top=m.height(),H=(s||parseInt(E.style("height"))||400)-o.top-o.bottom-t),M.select(".nv-legendWrap").attr("transform","translate(0,"+-o.top+")")),K.attr("transform","translate("+o.left+","+o.top+")"),g.width(G).height(H).color(c.map(function(a,b){return a.color||q(a,b)}).filter(function(a,b){return!c[b].disabled})),h.defined(g.defined()).width(G).height(I).color(c.map(function(a,b){return a.color||q(a,b)}).filter(function(a,b){return!c[b].disabled})),M.select(".nv-context").attr("transform","translate(0,"+(H+o.bottom+p.top)+")");var P=M.select(".nv-context .nv-linesWrap").datum(c.filter(function(a){return!a.disabled}));d3.transition(P).call(h),i.scale(b).ticks(G/100).tickSize(-H,0),j.scale(d).ticks(H/36).tickSize(-G,0),M.select(".nv-focus .nv-x.nv-axis").attr("transform","translate(0,"+H+")"),n.x(e).on("brush",function(){var b=a.transitionDuration();a.transitionDuration(0),D(),a.transitionDuration(b)}),v&&n.extent(v);var Q=M.select(".nv-brushBackground").selectAll("g").data([v||n.extent()]),R=Q.enter().append("g");R.append("rect").attr("class","left").attr("x",0).attr("y",0).attr("height",I),R.append("rect").attr("class","right").attr("x",0).attr("y",0).attr("height",I);var S=M.select(".nv-x.nv-brush").call(n);S.selectAll("rect").attr("height",I),S.selectAll(".resize").append("path").attr("d",x),D(),k.scale(e).ticks(G/100).tickSize(-I,0),M.select(".nv-context .nv-x.nv-axis").attr("transform","translate(0,"+f.range()[0]+")"),d3.transition(M.select(".nv-context .nv-x.nv-axis")).call(k),l.scale(f).ticks(I/36).tickSize(-G,0),d3.transition(M.select(".nv-context .nv-y.nv-axis")).call(l),M.select(".nv-context .nv-x.nv-axis").attr("transform","translate(0,"+f.range()[0]+")"),m.dispatch.on("stateChange",function(){a.update()}),z.on("tooltipShow",function(a){w&&B(a,F.parentNode)})}),a}var b,d,e,f,g=c.models.line(),h=c.models.line(),i=c.models.axis(),j=c.models.axis(),k=c.models.axis(),l=c.models.axis(),m=c.models.legend(),n=d3.svg.brush(),o={top:30,right:30,bottom:30,left:60},p={top:0,right:30,bottom:20,left:60},q=c.utils.defaultColor(),r=null,s=null,t=100,u=!0,v=null,w=!0,x=function(a,b,c){return"

"+a+"

"+"

"+c+" at "+b+"

"},y="No Data Available.",z=d3.dispatch("tooltipShow","tooltipHide","brush"),A=250;g.clipEdge(!0),h.interactive(!1),i.orient("bottom").tickPadding(5),j.orient("left"),k.orient("bottom").tickPadding(5),l.orient("left");var B=function(b,d){var e=b.pos[0]+(d.offsetLeft||0),f=b.pos[1]+(d.offsetTop||0),h=i.tickFormat()(g.x()(b.point,b.pointIndex)),k=j.tickFormat()(g.y()(b.point,b.pointIndex)),l=x(b.series.key,h,k,b,a);c.tooltip.show([e,f],l,null,null,d)};return g.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+o.left,a.pos[1]+o.top],z.tooltipShow(a)}),g.dispatch.on("elementMouseout.tooltip",function(a){z.tooltipHide(a)}),z.on("tooltipHide",function(){w&&c.tooltip.cleanup()}),a.dispatch=z,a.legend=m,a.lines=g,a.lines2=h,a.xAxis=i,a.yAxis=j,a.x2Axis=k,a.y2Axis=l,d3.rebind(a,g,"defined","isArea","size","xDomain","yDomain","xRange","yRange","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),a.options=c.utils.optionsFunc.bind(a),a.x=function(b){return arguments.length?(g.x(b),h.x(b),a):g.x},a.y=function(b){return arguments.length?(g.y(b),h.y(b),a):g.y},a.margin=function(b){return arguments.length?(o.top="undefined"!=typeof b.top?b.top:o.top,o.right="undefined"!=typeof b.right?b.right:o.right,o.bottom="undefined"!=typeof b.bottom?b.bottom:o.bottom,o.left="undefined"!=typeof b.left?b.left:o.left,a):o},a.margin2=function(b){return arguments.length?(p=b,a):p},a.width=function(b){return arguments.length?(r=b,a):r},a.height=function(b){return arguments.length?(s=b,a):s},a.height2=function(b){return arguments.length?(t=b,a):t},a.color=function(b){return arguments.length?(q=c.utils.getColor(b),m.color(q),a):q},a.showLegend=function(b){return arguments.length?(u=b,a):u},a.tooltips=function(b){return arguments.length?(w=b,a):w},a.tooltipContent=function(b){return arguments.length?(x=b,a):x},a.interpolate=function(b){return arguments.length?(g.interpolate(b),h.interpolate(b),a):g.interpolate()},a.noData=function(b){return arguments.length?(y=b,a):y},a.xTickFormat=function(b){return arguments.length?(i.tickFormat(b),k.tickFormat(b),a):i.tickFormat()},a.yTickFormat=function(b){return arguments.length?(j.tickFormat(b),l.tickFormat(b),a):j.tickFormat()},a.brushExtent=function(b){return arguments.length?(v=b,a):v},a.transitionDuration=function(b){return arguments.length?(A=b,a):A},a},c.models.linePlusBarWithFocusChart=function(){"use strict";function a(c){return c.each(function(c){function G(a){var b=+("e"==a),c=b?1:-1,d=R/3;return"M"+.5*c+","+d+"A6,6 0 0 "+b+" "+6.5*c+","+(d+6)+"V"+(2*d-6)+"A6,6 0 0 "+b+" "+.5*c+","+2*d+"Z"+"M"+2.5*c+","+(d+8)+"V"+(2*d-8)+"M"+4.5*c+","+(d+8)+"V"+(2*d-8)}function L(){u.empty()||u.extent(E),cb.data([u.empty()?e.domain():E]).each(function(a){var b=e(a[0])-e.range()[0],c=e.range()[1]-e(a[1]);d3.select(this).select(".left").attr("width",0>b?0:b),d3.select(this).select(".right").attr("x",e(a[1])).attr("width",0>c?0:c)})}function M(){E=u.empty()?null:u.extent(),b=u.empty()?e.domain():u.extent(),I.brush({extent:b,brush:u}),L(),l.width(P).height(Q).color(c.map(function(a,b){return a.color||C(a,b)}).filter(function(a,b){return!c[b].disabled&&c[b].bar})),j.width(P).height(Q).color(c.map(function(a,b){return a.color||C(a,b)}).filter(function(a,b){return!c[b].disabled&&!c[b].bar}));var a=Z.select(".nv-focus .nv-barsWrap").datum(T.length?T.map(function(a){return{key:a.key,values:a.values.filter(function(a,c){return l.x()(a,c)>=b[0]&&l.x()(a,c)<=b[1]})}}):[{values:[]}]),h=Z.select(".nv-focus .nv-linesWrap").datum(U[0].disabled?[{values:[]}]:U.map(function(a){return{key:a.key,values:a.values.filter(function(a,c){return j.x()(a,c)>=b[0]&&j.x()(a,c)<=b[1]})}}));d=T.length?l.xScale():j.xScale(),n.scale(d).ticks(P/100).tickSize(-Q,0),n.domain([Math.ceil(b[0]),Math.floor(b[1])]),Z.select(".nv-x.nv-axis").transition().duration(J).call(n),a.transition().duration(J).call(l),h.transition().duration(J).call(j),Z.select(".nv-focus .nv-x.nv-axis").attr("transform","translate(0,"+f.range()[0]+")"),p.scale(f).ticks(Q/36).tickSize(-P,0),Z.select(".nv-focus .nv-y1.nv-axis").style("opacity",T.length?1:0),q.scale(g).ticks(Q/36).tickSize(T.length?0:-P,0),Z.select(".nv-focus .nv-y2.nv-axis").style("opacity",U.length?1:0).attr("transform","translate("+d.range()[1]+",0)"),Z.select(".nv-focus .nv-y1.nv-axis").transition().duration(J).call(p),Z.select(".nv-focus .nv-y2.nv-axis").transition().duration(J).call(q)}var N=d3.select(this),O=this,P=(x||parseInt(N.style("width"))||960)-v.left-v.right,Q=(y||parseInt(N.style("height"))||400)-v.top-v.bottom-z,R=z-w.top-w.bottom;if(a.update=function(){N.transition().duration(J).call(a)},a.container=this,!(c&&c.length&&c.filter(function(a){return a.values.length}).length)){var S=N.selectAll(".nv-noData").data([H]);return S.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),S.attr("x",v.left+P/2).attr("y",v.top+Q/2).text(function(a){return a}),a}N.selectAll(".nv-noData").remove();var T=c.filter(function(a){return!a.disabled&&a.bar}),U=c.filter(function(a){return!a.bar});d=l.xScale(),e=o.scale(),f=l.yScale(),g=j.yScale(),h=m.yScale(),i=k.yScale();var V=c.filter(function(a){return!a.disabled&&a.bar}).map(function(a){return a.values.map(function(a,b){return{x:A(a,b),y:B(a,b)}})}),W=c.filter(function(a){return!a.disabled&&!a.bar}).map(function(a){return a.values.map(function(a,b){return{x:A(a,b),y:B(a,b)}})});d.range([0,P]),e.domain(d3.extent(d3.merge(V.concat(W)),function(a){return a.x})).range([0,P]);var X=N.selectAll("g.nv-wrap.nv-linePlusBar").data([c]),Y=X.enter().append("g").attr("class","nvd3 nv-wrap nv-linePlusBar").append("g"),Z=X.select("g");Y.append("g").attr("class","nv-legendWrap");var $=Y.append("g").attr("class","nv-focus");$.append("g").attr("class","nv-x nv-axis"),$.append("g").attr("class","nv-y1 nv-axis"),$.append("g").attr("class","nv-y2 nv-axis"),$.append("g").attr("class","nv-barsWrap"),$.append("g").attr("class","nv-linesWrap");var _=Y.append("g").attr("class","nv-context");_.append("g").attr("class","nv-x nv-axis"),_.append("g").attr("class","nv-y1 nv-axis"),_.append("g").attr("class","nv-y2 nv-axis"),_.append("g").attr("class","nv-barsWrap"),_.append("g").attr("class","nv-linesWrap"),_.append("g").attr("class","nv-brushBackground"),_.append("g").attr("class","nv-x nv-brush"),D&&(t.width(P/2),Z.select(".nv-legendWrap").datum(c.map(function(a){return a.originalKey=void 0===a.originalKey?a.key:a.originalKey,a.key=a.originalKey+(a.bar?" (left axis)":" (right axis)"),a})).call(t),v.top!=t.height()&&(v.top=t.height(),Q=(y||parseInt(N.style("height"))||400)-v.top-v.bottom-z),Z.select(".nv-legendWrap").attr("transform","translate("+P/2+","+-v.top+")")),X.attr("transform","translate("+v.left+","+v.top+")"),m.width(P).height(R).color(c.map(function(a,b){return a.color||C(a,b)}).filter(function(a,b){return!c[b].disabled&&c[b].bar})),k.width(P).height(R).color(c.map(function(a,b){return a.color||C(a,b)}).filter(function(a,b){return!c[b].disabled&&!c[b].bar}));var ab=Z.select(".nv-context .nv-barsWrap").datum(T.length?T:[{values:[]}]),bb=Z.select(".nv-context .nv-linesWrap").datum(U[0].disabled?[{values:[]}]:U);Z.select(".nv-context").attr("transform","translate(0,"+(Q+v.bottom+w.top)+")"),ab.transition().call(m),bb.transition().call(k),u.x(e).on("brush",M),E&&u.extent(E);var cb=Z.select(".nv-brushBackground").selectAll("g").data([E||u.extent()]),db=cb.enter().append("g");db.append("rect").attr("class","left").attr("x",0).attr("y",0).attr("height",R),db.append("rect").attr("class","right").attr("x",0).attr("y",0).attr("height",R);var eb=Z.select(".nv-x.nv-brush").call(u);eb.selectAll("rect").attr("height",R),eb.selectAll(".resize").append("path").attr("d",G),o.ticks(P/100).tickSize(-R,0),Z.select(".nv-context .nv-x.nv-axis").attr("transform","translate(0,"+h.range()[0]+")"),Z.select(".nv-context .nv-x.nv-axis").transition().call(o),r.scale(h).ticks(R/36).tickSize(-P,0),Z.select(".nv-context .nv-y1.nv-axis").style("opacity",T.length?1:0).attr("transform","translate(0,"+e.range()[0]+")"),Z.select(".nv-context .nv-y1.nv-axis").transition().call(r),s.scale(i).ticks(R/36).tickSize(T.length?0:-P,0),Z.select(".nv-context .nv-y2.nv-axis").style("opacity",U.length?1:0).attr("transform","translate("+e.range()[1]+",0)"),Z.select(".nv-context .nv-y2.nv-axis").transition().call(s),t.dispatch.on("stateChange",function(){a.update()}),I.on("tooltipShow",function(a){F&&K(a,O.parentNode)}),M()}),a}var b,d,e,f,g,h,i,j=c.models.line(),k=c.models.line(),l=c.models.historicalBar(),m=c.models.historicalBar(),n=c.models.axis(),o=c.models.axis(),p=c.models.axis(),q=c.models.axis(),r=c.models.axis(),s=c.models.axis(),t=c.models.legend(),u=d3.svg.brush(),v={top:30,right:30,bottom:30,left:60},w={top:0,right:30,bottom:20,left:60},x=null,y=null,z=100,A=function(a){return a.x},B=function(a){return a.y},C=c.utils.defaultColor(),D=!0,E=null,F=!0,G=function(a,b,c){return"

"+a+"

"+"

"+c+" at "+b+"

"},H="No Data Available.",I=d3.dispatch("tooltipShow","tooltipHide","brush"),J=0;j.clipEdge(!0),k.interactive(!1),n.orient("bottom").tickPadding(5),p.orient("left"),q.orient("right"),o.orient("bottom").tickPadding(5),r.orient("left"),s.orient("right");var K=function(d,e){b&&(d.pointIndex+=Math.ceil(b[0]));var f=d.pos[0]+(e.offsetLeft||0),g=d.pos[1]+(e.offsetTop||0),h=n.tickFormat()(j.x()(d.point,d.pointIndex)),i=(d.series.bar?p:q).tickFormat()(j.y()(d.point,d.pointIndex)),k=G(d.series.key,h,i,d,a);c.tooltip.show([f,g],k,d.value<0?"n":"s",null,e)};return j.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+v.left,a.pos[1]+v.top],I.tooltipShow(a)}),j.dispatch.on("elementMouseout.tooltip",function(a){I.tooltipHide(a)}),l.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+v.left,a.pos[1]+v.top],I.tooltipShow(a)}),l.dispatch.on("elementMouseout.tooltip",function(a){I.tooltipHide(a)}),I.on("tooltipHide",function(){F&&c.tooltip.cleanup()}),a.dispatch=I,a.legend=t,a.lines=j,a.lines2=k,a.bars=l,a.bars2=m,a.xAxis=n,a.x2Axis=o,a.y1Axis=p,a.y2Axis=q,a.y3Axis=r,a.y4Axis=s,d3.rebind(a,j,"defined","size","clipVoronoi","interpolate"),a.options=c.utils.optionsFunc.bind(a),a.x=function(b){return arguments.length?(A=b,j.x(b),l.x(b),a):A},a.y=function(b){return arguments.length?(B=b,j.y(b),l.y(b),a):B},a.margin=function(b){return arguments.length?(v.top="undefined"!=typeof b.top?b.top:v.top,v.right="undefined"!=typeof b.right?b.right:v.right,v.bottom="undefined"!=typeof b.bottom?b.bottom:v.bottom,v.left="undefined"!=typeof b.left?b.left:v.left,a):v},a.width=function(b){return arguments.length?(x=b,a):x},a.height=function(b){return arguments.length?(y=b,a):y},a.color=function(b){return arguments.length?(C=c.utils.getColor(b),t.color(C),a):C},a.showLegend=function(b){return arguments.length?(D=b,a):D},a.tooltips=function(b){return arguments.length?(F=b,a):F},a.tooltipContent=function(b){return arguments.length?(G=b,a):G},a.noData=function(b){return arguments.length?(H=b,a):H},a.brushExtent=function(b){return arguments.length?(E=b,a):E},a},c.models.multiBar=function(){"use strict";function a(c){return c.each(function(a){var c=k-j.left-j.right,B=l-j.top-j.bottom,C=d3.select(this);w&&a.length&&(w=[{values:a[0].values.map(function(a){return{x:a.x,y:0,series:a.series,size:.01}})}]),t&&(a=d3.layout.stack().offset(u).values(function(a){return a.values}).y(q)(!a.length&&w?w:a)),a.forEach(function(a,b){a.values.forEach(function(a){a.series=b})}),t&&a[0].values.map(function(b,c){var d=0,e=0;a.map(function(a){var b=a.values[c];b.size=Math.abs(b.y),b.y<0?(b.y1=e,e-=b.size):(b.y1=b.size+d,d+=b.size)})});var D=d&&e?[]:a.map(function(a){return a.values.map(function(a,b){return{x:p(a,b),y:q(a,b),y0:a.y0,y1:a.y1}})});m.domain(d||d3.merge(D).map(function(a){return a.x})).rangeBands(f||[0,c],z),n.domain(e||d3.extent(d3.merge(D).map(function(a){return t?a.y>0?a.y1:a.y1+a.y:a.y}).concat(r))).range(g||[B,0]),m.domain()[0]===m.domain()[1]&&(m.domain()[0]?m.domain([m.domain()[0]-.01*m.domain()[0],m.domain()[1]+.01*m.domain()[1]]):m.domain([-1,1])),n.domain()[0]===n.domain()[1]&&(n.domain()[0]?n.domain([n.domain()[0]+.01*n.domain()[0],n.domain()[1]-.01*n.domain()[1]]):n.domain([-1,1])),h=h||m,i=i||n;var E=C.selectAll("g.nv-wrap.nv-multibar").data([a]),F=E.enter().append("g").attr("class","nvd3 nv-wrap nv-multibar"),G=F.append("defs"),H=F.append("g"),I=E.select("g");H.append("g").attr("class","nv-groups"),E.attr("transform","translate("+j.left+","+j.top+")"),G.append("clipPath").attr("id","nv-edge-clip-"+o).append("rect"),E.select("#nv-edge-clip-"+o+" rect").attr("width",c).attr("height",B),I.attr("clip-path",s?"url(#nv-edge-clip-"+o+")":"");var J=E.select(".nv-groups").selectAll(".nv-group").data(function(a){return a},function(a,b){return b});J.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),J.exit().transition().selectAll("rect.nv-bar").delay(function(b,c){return c*y/a[0].values.length}).attr("y",function(a){return t?i(a.y0):i(0)}).attr("height",0).remove(),J.attr("class",function(a,b){return"nv-group nv-series-"+b +}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return v(a,b)}).style("stroke",function(a,b){return v(a,b)}),J.transition().style("stroke-opacity",1).style("fill-opacity",.75);var K=J.selectAll("rect.nv-bar").data(function(b){return w&&!a.length?w.values:b.values});K.exit().remove(),K.enter().append("rect").attr("class",function(a,b){return q(a,b)<0?"nv-bar negative":"nv-bar positive"}).attr("x",function(b,c,d){return t?0:d*m.rangeBand()/a.length}).attr("y",function(a){return i(t?a.y0:0)}).attr("height",0).attr("width",m.rangeBand()/(t?1:a.length)).attr("transform",function(a,b){return"translate("+m(p(a,b))+",0)"}),K.style("fill",function(a,b,c){return v(a,c,b)}).style("stroke",function(a,b,c){return v(a,c,b)}).on("mouseover",function(b,c){d3.select(this).classed("hover",!0),A.elementMouseover({value:q(b,c),point:b,series:a[b.series],pos:[m(p(b,c))+m.rangeBand()*(t?a.length/2:b.series+.5)/a.length,n(q(b,c)+(t?b.y0:0))],pointIndex:c,seriesIndex:b.series,e:d3.event})}).on("mouseout",function(b,c){d3.select(this).classed("hover",!1),A.elementMouseout({value:q(b,c),point:b,series:a[b.series],pointIndex:c,seriesIndex:b.series,e:d3.event})}).on("click",function(b,c){A.elementClick({value:q(b,c),point:b,series:a[b.series],pos:[m(p(b,c))+m.rangeBand()*(t?a.length/2:b.series+.5)/a.length,n(q(b,c)+(t?b.y0:0))],pointIndex:c,seriesIndex:b.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(b,c){A.elementDblClick({value:q(b,c),point:b,series:a[b.series],pos:[m(p(b,c))+m.rangeBand()*(t?a.length/2:b.series+.5)/a.length,n(q(b,c)+(t?b.y0:0))],pointIndex:c,seriesIndex:b.series,e:d3.event}),d3.event.stopPropagation()}),K.attr("class",function(a,b){return q(a,b)<0?"nv-bar negative":"nv-bar positive"}).transition().attr("transform",function(a,b){return"translate("+m(p(a,b))+",0)"}),x&&(b||(b=a.map(function(){return!0})),K.style("fill",function(a,c,d){return d3.rgb(x(a,c)).darker(b.map(function(a,b){return b}).filter(function(a,c){return!b[c]})[d]).toString()}).style("stroke",function(a,c,d){return d3.rgb(x(a,c)).darker(b.map(function(a,b){return b}).filter(function(a,c){return!b[c]})[d]).toString()})),t?K.transition().delay(function(b,c){return c*y/a[0].values.length}).attr("y",function(a){return n(t?a.y1:0)}).attr("height",function(a){return Math.max(Math.abs(n(a.y+(t?a.y0:0))-n(t?a.y0:0)),1)}).attr("x",function(b){return t?0:b.series*m.rangeBand()/a.length}).attr("width",m.rangeBand()/(t?1:a.length)):K.transition().delay(function(b,c){return c*y/a[0].values.length}).attr("x",function(b){return b.series*m.rangeBand()/a.length}).attr("width",m.rangeBand()/a.length).attr("y",function(a,b){return q(a,b)<0?n(0):n(0)-n(q(a,b))<1?n(0)-1:n(q(a,b))||0}).attr("height",function(a,b){return Math.max(Math.abs(n(q(a,b))-n(0)),1)||0}),h=m.copy(),i=n.copy()}),a}var b,d,e,f,g,h,i,j={top:0,right:0,bottom:0,left:0},k=960,l=500,m=d3.scale.ordinal(),n=d3.scale.linear(),o=Math.floor(1e4*Math.random()),p=function(a){return a.x},q=function(a){return a.y},r=[0],s=!0,t=!1,u="zero",v=c.utils.defaultColor(),w=!1,x=null,y=1200,z=.1,A=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return a.dispatch=A,a.options=c.utils.optionsFunc.bind(a),a.x=function(b){return arguments.length?(p=b,a):p},a.y=function(b){return arguments.length?(q=b,a):q},a.margin=function(b){return arguments.length?(j.top="undefined"!=typeof b.top?b.top:j.top,j.right="undefined"!=typeof b.right?b.right:j.right,j.bottom="undefined"!=typeof b.bottom?b.bottom:j.bottom,j.left="undefined"!=typeof b.left?b.left:j.left,a):j},a.width=function(b){return arguments.length?(k=b,a):k},a.height=function(b){return arguments.length?(l=b,a):l},a.xScale=function(b){return arguments.length?(m=b,a):m},a.yScale=function(b){return arguments.length?(n=b,a):n},a.xDomain=function(b){return arguments.length?(d=b,a):d},a.yDomain=function(b){return arguments.length?(e=b,a):e},a.xRange=function(b){return arguments.length?(f=b,a):f},a.yRange=function(b){return arguments.length?(g=b,a):g},a.forceY=function(b){return arguments.length?(r=b,a):r},a.stacked=function(b){return arguments.length?(t=b,a):t},a.stackOffset=function(b){return arguments.length?(u=b,a):u},a.clipEdge=function(b){return arguments.length?(s=b,a):s},a.color=function(b){return arguments.length?(v=c.utils.getColor(b),a):v},a.barColor=function(b){return arguments.length?(x=c.utils.getColor(b),a):x},a.disabled=function(c){return arguments.length?(b=c,a):b},a.id=function(b){return arguments.length?(o=b,a):o},a.hideable=function(b){return arguments.length?(w=b,a):w},a.delay=function(b){return arguments.length?(y=b,a):y},a.groupSpacing=function(b){return arguments.length?(z=b,a):z},a},c.models.multiBarChart=function(){"use strict";function a(c){return c.each(function(c){var w=d3.select(this),E=this,F=(k||parseInt(w.style("width"))||960)-j.left-j.right,G=(l||parseInt(w.style("height"))||400)-j.top-j.bottom;if(a.update=function(){w.transition().duration(C).call(a)},a.container=this,x.disabled=c.map(function(a){return!!a.disabled}),!y){var H;y={};for(H in x)y[H]=x[H]instanceof Array?x[H].slice(0):x[H]}if(!(c&&c.length&&c.filter(function(a){return a.values.length}).length)){var I=w.selectAll(".nv-noData").data([z]);return I.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),I.attr("x",j.left+F/2).attr("y",j.top+G/2).text(function(a){return a}),a}w.selectAll(".nv-noData").remove(),b=e.xScale(),d=e.yScale();var J=w.selectAll("g.nv-wrap.nv-multiBarWithLegend").data([c]),K=J.enter().append("g").attr("class","nvd3 nv-wrap nv-multiBarWithLegend").append("g"),L=J.select("g");if(K.append("g").attr("class","nv-x nv-axis"),K.append("g").attr("class","nv-y nv-axis"),K.append("g").attr("class","nv-barsWrap"),K.append("g").attr("class","nv-legendWrap"),K.append("g").attr("class","nv-controlsWrap"),o&&(h.width(F-B()),e.barColor()&&c.forEach(function(a,b){a.color=d3.rgb("#ccc").darker(1.5*b).toString()}),L.select(".nv-legendWrap").datum(c).call(h),j.top!=h.height()&&(j.top=h.height(),G=(l||parseInt(w.style("height"))||400)-j.top-j.bottom),L.select(".nv-legendWrap").attr("transform","translate("+B()+","+-j.top+")")),n){var M=[{key:"Grouped",disabled:e.stacked()},{key:"Stacked",disabled:!e.stacked()}];i.width(B()).color(["#444","#444","#444"]),L.select(".nv-controlsWrap").datum(M).attr("transform","translate(0,"+-j.top+")").call(i)}J.attr("transform","translate("+j.left+","+j.top+")"),r&&L.select(".nv-y.nv-axis").attr("transform","translate("+F+",0)"),e.disabled(c.map(function(a){return a.disabled})).width(F).height(G).color(c.map(function(a,b){return a.color||m(a,b)}).filter(function(a,b){return!c[b].disabled}));var N=L.select(".nv-barsWrap").datum(c.filter(function(a){return!a.disabled}));if(N.transition().call(e),p){f.scale(b).ticks(F/100).tickSize(-G,0),L.select(".nv-x.nv-axis").attr("transform","translate(0,"+d.range()[0]+")"),L.select(".nv-x.nv-axis").transition().call(f);var O=L.select(".nv-x.nv-axis > g").selectAll("g");if(O.selectAll("line, text").style("opacity",1),t){var P=function(a,b){return"translate("+a+","+b+")"},Q=5,R=17;O.selectAll("text").attr("transform",function(a,b,c){return P(0,0==c%2?Q:R)});var S=d3.selectAll(".nv-x.nv-axis .nv-wrap g g text")[0].length;L.selectAll(".nv-x.nv-axis .nv-axisMaxMin text").attr("transform",function(a,b){return P(0,0===b||0!==S%2?R:Q)})}s&&O.filter(function(a,b){return 0!==b%Math.ceil(c[0].values.length/(F/100))}).selectAll("text, line").style("opacity",0),u&&O.selectAll(".tick text").attr("transform","rotate("+u+" 0,0)").style("text-anchor",u>0?"start":"end"),L.select(".nv-x.nv-axis").selectAll("g.nv-axisMaxMin text").style("opacity",1)}q&&(g.scale(d).ticks(G/36).tickSize(-F,0),L.select(".nv-y.nv-axis").transition().call(g)),h.dispatch.on("stateChange",function(b){x=b,A.stateChange(x),a.update()}),i.dispatch.on("legendClick",function(b){if(b.disabled){switch(M=M.map(function(a){return a.disabled=!0,a}),b.disabled=!1,b.key){case"Grouped":e.stacked(!1);break;case"Stacked":e.stacked(!0)}x.stacked=e.stacked(),A.stateChange(x),a.update()}}),A.on("tooltipShow",function(a){v&&D(a,E.parentNode)}),A.on("changeState",function(b){"undefined"!=typeof b.disabled&&(c.forEach(function(a,c){a.disabled=b.disabled[c]}),x.disabled=b.disabled),"undefined"!=typeof b.stacked&&(e.stacked(b.stacked),x.stacked=b.stacked),a.update()})}),a}var b,d,e=c.models.multiBar(),f=c.models.axis(),g=c.models.axis(),h=c.models.legend(),i=c.models.legend(),j={top:30,right:20,bottom:50,left:60},k=null,l=null,m=c.utils.defaultColor(),n=!0,o=!0,p=!0,q=!0,r=!1,s=!0,t=!1,u=0,v=!0,w=function(a,b,c){return"

"+a+"

"+"

"+c+" on "+b+"

"},x={stacked:!1},y=null,z="No Data Available.",A=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),B=function(){return n?180:0},C=250;e.stacked(!1),f.orient("bottom").tickPadding(7).highlightZero(!0).showMaxMin(!1).tickFormat(function(a){return a}),g.orient(r?"right":"left").tickFormat(d3.format(",.1f")),i.updateState(!1);var D=function(b,d){var h=b.pos[0]+(d.offsetLeft||0),i=b.pos[1]+(d.offsetTop||0),j=f.tickFormat()(e.x()(b.point,b.pointIndex)),k=g.tickFormat()(e.y()(b.point,b.pointIndex)),l=w(b.series.key,j,k,b,a);c.tooltip.show([h,i],l,b.value<0?"n":"s",null,d)};return e.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+j.left,a.pos[1]+j.top],A.tooltipShow(a)}),e.dispatch.on("elementMouseout.tooltip",function(a){A.tooltipHide(a)}),A.on("tooltipHide",function(){v&&c.tooltip.cleanup()}),a.dispatch=A,a.multibar=e,a.legend=h,a.xAxis=f,a.yAxis=g,d3.rebind(a,e,"x","y","xDomain","yDomain","xRange","yRange","forceX","forceY","clipEdge","id","stacked","stackOffset","delay","barColor","groupSpacing"),a.options=c.utils.optionsFunc.bind(a),a.margin=function(b){return arguments.length?(j.top="undefined"!=typeof b.top?b.top:j.top,j.right="undefined"!=typeof b.right?b.right:j.right,j.bottom="undefined"!=typeof b.bottom?b.bottom:j.bottom,j.left="undefined"!=typeof b.left?b.left:j.left,a):j},a.width=function(b){return arguments.length?(k=b,a):k},a.height=function(b){return arguments.length?(l=b,a):l},a.color=function(b){return arguments.length?(m=c.utils.getColor(b),h.color(m),a):m},a.showControls=function(b){return arguments.length?(n=b,a):n},a.showLegend=function(b){return arguments.length?(o=b,a):o},a.showXAxis=function(b){return arguments.length?(p=b,a):p},a.showYAxis=function(b){return arguments.length?(q=b,a):q},a.rightAlignYAxis=function(b){return arguments.length?(r=b,g.orient(b?"right":"left"),a):r},a.reduceXTicks=function(b){return arguments.length?(s=b,a):s},a.rotateLabels=function(b){return arguments.length?(u=b,a):u},a.staggerLabels=function(b){return arguments.length?(t=b,a):t},a.tooltip=function(b){return arguments.length?(w=b,a):w},a.tooltips=function(b){return arguments.length?(v=b,a):v},a.tooltipContent=function(b){return arguments.length?(w=b,a):w},a.state=function(b){return arguments.length?(x=b,a):x},a.defaultState=function(b){return arguments.length?(y=b,a):y},a.noData=function(b){return arguments.length?(z=b,a):z},a.transitionDuration=function(b){return arguments.length?(C=b,a):C},a},c.models.multiBarHorizontal=function(){"use strict";function a(c){return c.each(function(a){var c=k-j.left-j.right,m=l-j.top-j.bottom;d3.select(this),u&&(a=d3.layout.stack().offset("zero").values(function(a){return a.values}).y(q)(a)),a.forEach(function(a,b){a.values.forEach(function(a){a.series=b})}),u&&a[0].values.map(function(b,c){var d=0,e=0;a.map(function(a){var b=a.values[c];b.size=Math.abs(b.y),b.y<0?(b.y1=e-b.size,e-=b.size):(b.y1=d,d+=b.size)})});var y=d&&e?[]:a.map(function(a){return a.values.map(function(a,b){return{x:p(a,b),y:q(a,b),y0:a.y0,y1:a.y1}})});n.domain(d||d3.merge(y).map(function(a){return a.x})).rangeBands(f||[0,m],.1),o.domain(e||d3.extent(d3.merge(y).map(function(a){return u?a.y>0?a.y1+a.y:a.y1:a.y}).concat(r))),v&&!u?o.range(g||[o.domain()[0]<0?w:0,c-(o.domain()[1]>0?w:0)]):o.range(g||[0,c]),h=h||n,i=i||d3.scale.linear().domain(o.domain()).range([o(0),o(0)]);var A=d3.select(this).selectAll("g.nv-wrap.nv-multibarHorizontal").data([a]),B=A.enter().append("g").attr("class","nvd3 nv-wrap nv-multibarHorizontal");B.append("defs");var C=B.append("g");A.select("g"),C.append("g").attr("class","nv-groups"),A.attr("transform","translate("+j.left+","+j.top+")");var D=A.select(".nv-groups").selectAll(".nv-group").data(function(a){return a},function(a,b){return b});D.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),D.exit().transition().style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),D.attr("class",function(a,b){return"nv-group nv-series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return s(a,b)}).style("stroke",function(a,b){return s(a,b)}),D.transition().style("stroke-opacity",1).style("fill-opacity",.75);var E=D.selectAll("g.nv-bar").data(function(a){return a.values});E.exit().remove();var F=E.enter().append("g").attr("transform",function(b,c,d){return"translate("+i(u?b.y0:0)+","+(u?0:d*n.rangeBand()/a.length+n(p(b,c)))+")"});F.append("rect").attr("width",0).attr("height",n.rangeBand()/(u?1:a.length)),E.on("mouseover",function(b,c){d3.select(this).classed("hover",!0),z.elementMouseover({value:q(b,c),point:b,series:a[b.series],pos:[o(q(b,c)+(u?b.y0:0)),n(p(b,c))+n.rangeBand()*(u?a.length/2:b.series+.5)/a.length],pointIndex:c,seriesIndex:b.series,e:d3.event})}).on("mouseout",function(b,c){d3.select(this).classed("hover",!1),z.elementMouseout({value:q(b,c),point:b,series:a[b.series],pointIndex:c,seriesIndex:b.series,e:d3.event})}).on("click",function(b,c){z.elementClick({value:q(b,c),point:b,series:a[b.series],pos:[n(p(b,c))+n.rangeBand()*(u?a.length/2:b.series+.5)/a.length,o(q(b,c)+(u?b.y0:0))],pointIndex:c,seriesIndex:b.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(b,c){z.elementDblClick({value:q(b,c),point:b,series:a[b.series],pos:[n(p(b,c))+n.rangeBand()*(u?a.length/2:b.series+.5)/a.length,o(q(b,c)+(u?b.y0:0))],pointIndex:c,seriesIndex:b.series,e:d3.event}),d3.event.stopPropagation()}),F.append("text"),v&&!u?(E.select("text").attr("text-anchor",function(a,b){return q(a,b)<0?"end":"start"}).attr("y",n.rangeBand()/(2*a.length)).attr("dy",".32em").text(function(a,b){return x(q(a,b))}),E.transition().select("text").attr("x",function(a,b){return q(a,b)<0?-4:o(q(a,b))-o(0)+4})):E.selectAll("text").text(""),E.attr("class",function(a,b){return q(a,b)<0?"nv-bar negative":"nv-bar positive"}),t&&(b||(b=a.map(function(){return!0})),E.style("fill",function(a,c,d){return d3.rgb(t(a,c)).darker(b.map(function(a,b){return b}).filter(function(a,c){return!b[c]})[d]).toString()}).style("stroke",function(a,c,d){return d3.rgb(t(a,c)).darker(b.map(function(a,b){return b}).filter(function(a,c){return!b[c]})[d]).toString()})),u?E.transition().attr("transform",function(a,b){return"translate("+o(a.y1)+","+n(p(a,b))+")"}).select("rect").attr("width",function(a,b){return Math.abs(o(q(a,b)+a.y0)-o(a.y0))}).attr("height",n.rangeBand()):E.transition().attr("transform",function(b,c){return"translate("+(q(b,c)<0?o(q(b,c)):o(0))+","+(b.series*n.rangeBand()/a.length+n(p(b,c)))+")"}).select("rect").attr("height",n.rangeBand()/a.length).attr("width",function(a,b){return Math.max(Math.abs(o(q(a,b))-o(0)),1)}),h=n.copy(),i=o.copy()}),a}var b,d,e,f,g,h,i,j={top:0,right:0,bottom:0,left:0},k=960,l=500,m=Math.floor(1e4*Math.random()),n=d3.scale.ordinal(),o=d3.scale.linear(),p=function(a){return a.x},q=function(a){return a.y},r=[0],s=c.utils.defaultColor(),t=null,u=!1,v=!1,w=60,x=d3.format(",.2f"),y=1200,z=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return a.dispatch=z,a.options=c.utils.optionsFunc.bind(a),a.x=function(b){return arguments.length?(p=b,a):p},a.y=function(b){return arguments.length?(q=b,a):q},a.margin=function(b){return arguments.length?(j.top="undefined"!=typeof b.top?b.top:j.top,j.right="undefined"!=typeof b.right?b.right:j.right,j.bottom="undefined"!=typeof b.bottom?b.bottom:j.bottom,j.left="undefined"!=typeof b.left?b.left:j.left,a):j},a.width=function(b){return arguments.length?(k=b,a):k},a.height=function(b){return arguments.length?(l=b,a):l},a.xScale=function(b){return arguments.length?(n=b,a):n},a.yScale=function(b){return arguments.length?(o=b,a):o},a.xDomain=function(b){return arguments.length?(d=b,a):d},a.yDomain=function(b){return arguments.length?(e=b,a):e},a.xRange=function(b){return arguments.length?(f=b,a):f},a.yRange=function(b){return arguments.length?(g=b,a):g},a.forceY=function(b){return arguments.length?(r=b,a):r},a.stacked=function(b){return arguments.length?(u=b,a):u},a.color=function(b){return arguments.length?(s=c.utils.getColor(b),a):s},a.barColor=function(b){return arguments.length?(t=c.utils.getColor(b),a):t},a.disabled=function(c){return arguments.length?(b=c,a):b},a.id=function(b){return arguments.length?(m=b,a):m},a.delay=function(b){return arguments.length?(y=b,a):y},a.showValues=function(b){return arguments.length?(v=b,a):v},a.valueFormat=function(b){return arguments.length?(x=b,a):x},a.valuePadding=function(b){return arguments.length?(w=b,a):w},a},c.models.multiBarHorizontalChart=function(){"use strict";function a(c){return c.each(function(c){var p=d3.select(this),r=this,z=(k||parseInt(p.style("width"))||960)-j.left-j.right,A=(l||parseInt(p.style("height"))||400)-j.top-j.bottom;if(a.update=function(){p.transition().duration(x).call(a)},a.container=this,s.disabled=c.map(function(a){return!!a.disabled}),!t){var B;t={};for(B in s)t[B]=s[B]instanceof Array?s[B].slice(0):s[B]}if(!(c&&c.length&&c.filter(function(a){return a.values.length}).length)){var C=p.selectAll(".nv-noData").data([u]);return C.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),C.attr("x",j.left+z/2).attr("y",j.top+A/2).text(function(a){return a}),a}p.selectAll(".nv-noData").remove(),b=e.xScale(),d=e.yScale();var D=p.selectAll("g.nv-wrap.nv-multiBarHorizontalChart").data([c]),E=D.enter().append("g").attr("class","nvd3 nv-wrap nv-multiBarHorizontalChart").append("g"),F=D.select("g");if(E.append("g").attr("class","nv-x nv-axis"),E.append("g").attr("class","nv-y nv-axis"),E.append("g").attr("class","nv-barsWrap"),E.append("g").attr("class","nv-legendWrap"),E.append("g").attr("class","nv-controlsWrap"),o&&(h.width(z-w()),e.barColor()&&c.forEach(function(a,b){a.color=d3.rgb("#ccc").darker(1.5*b).toString()}),F.select(".nv-legendWrap").datum(c).call(h),j.top!=h.height()&&(j.top=h.height(),A=(l||parseInt(p.style("height"))||400)-j.top-j.bottom),F.select(".nv-legendWrap").attr("transform","translate("+w()+","+-j.top+")")),n){var G=[{key:"Grouped",disabled:e.stacked()},{key:"Stacked",disabled:!e.stacked()}];i.width(w()).color(["#444","#444","#444"]),F.select(".nv-controlsWrap").datum(G).attr("transform","translate(0,"+-j.top+")").call(i)}D.attr("transform","translate("+j.left+","+j.top+")"),e.disabled(c.map(function(a){return a.disabled})).width(z).height(A).color(c.map(function(a,b){return a.color||m(a,b)}).filter(function(a,b){return!c[b].disabled}));var H=F.select(".nv-barsWrap").datum(c.filter(function(a){return!a.disabled}));H.transition().call(e),f.scale(b).ticks(A/24).tickSize(-z,0),F.select(".nv-x.nv-axis").transition().call(f);var I=F.select(".nv-x.nv-axis").selectAll("g");I.selectAll("line, text").style("opacity",1),g.scale(d).ticks(z/100).tickSize(-A,0),F.select(".nv-y.nv-axis").attr("transform","translate(0,"+A+")"),F.select(".nv-y.nv-axis").transition().call(g),h.dispatch.on("stateChange",function(b){s=b,v.stateChange(s),a.update()}),i.dispatch.on("legendClick",function(b){if(b.disabled){switch(G=G.map(function(a){return a.disabled=!0,a}),b.disabled=!1,b.key){case"Grouped":e.stacked(!1);break;case"Stacked":e.stacked(!0)}s.stacked=e.stacked(),v.stateChange(s),a.update()}}),v.on("tooltipShow",function(a){q&&y(a,r.parentNode)}),v.on("changeState",function(b){"undefined"!=typeof b.disabled&&(c.forEach(function(a,c){a.disabled=b.disabled[c]}),s.disabled=b.disabled),"undefined"!=typeof b.stacked&&(e.stacked(b.stacked),s.stacked=b.stacked),a.update()})}),a}var b,d,e=c.models.multiBarHorizontal(),f=c.models.axis(),g=c.models.axis(),h=c.models.legend().height(30),i=c.models.legend().height(30),j={top:30,right:20,bottom:50,left:60},k=null,l=null,m=c.utils.defaultColor(),n=!0,o=!0,p=!1,q=!0,r=function(a,b,c){return"

"+a+" - "+b+"

"+"

"+c+"

"},s={stacked:p},t=null,u="No Data Available.",v=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),w=function(){return n?180:0},x=250;e.stacked(p),f.orient("left").tickPadding(5).highlightZero(!1).showMaxMin(!1).tickFormat(function(a){return a}),g.orient("bottom").tickFormat(d3.format(",.1f")),i.updateState(!1);var y=function(b,d){var h=b.pos[0]+(d.offsetLeft||0),i=b.pos[1]+(d.offsetTop||0),j=f.tickFormat()(e.x()(b.point,b.pointIndex)),k=g.tickFormat()(e.y()(b.point,b.pointIndex)),l=r(b.series.key,j,k,b,a);c.tooltip.show([h,i],l,b.value<0?"e":"w",null,d)};return e.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+j.left,a.pos[1]+j.top],v.tooltipShow(a)}),e.dispatch.on("elementMouseout.tooltip",function(a){v.tooltipHide(a)}),v.on("tooltipHide",function(){q&&c.tooltip.cleanup()}),a.dispatch=v,a.multibar=e,a.legend=h,a.xAxis=f,a.yAxis=g,d3.rebind(a,e,"x","y","xDomain","yDomain","xRange","yRange","forceX","forceY","clipEdge","id","delay","showValues","valueFormat","stacked","barColor"),a.options=c.utils.optionsFunc.bind(a),a.margin=function(b){return arguments.length?(j.top="undefined"!=typeof b.top?b.top:j.top,j.right="undefined"!=typeof b.right?b.right:j.right,j.bottom="undefined"!=typeof b.bottom?b.bottom:j.bottom,j.left="undefined"!=typeof b.left?b.left:j.left,a):j},a.width=function(b){return arguments.length?(k=b,a):k},a.height=function(b){return arguments.length?(l=b,a):l},a.color=function(b){return arguments.length?(m=c.utils.getColor(b),h.color(m),a):m},a.showControls=function(b){return arguments.length?(n=b,a):n},a.showLegend=function(b){return arguments.length?(o=b,a):o},a.tooltip=function(b){return arguments.length?(r=b,a):r},a.tooltips=function(b){return arguments.length?(q=b,a):q},a.tooltipContent=function(b){return arguments.length?(r=b,a):r},a.state=function(b){return arguments.length?(s=b,a):s},a.defaultState=function(b){return arguments.length?(t=b,a):t},a.noData=function(b){return arguments.length?(u=b,a):u},a.transitionDuration=function(b){return arguments.length?(x=b,a):x},a},c.models.multiChart=function(){"use strict";function a(c){return c.each(function(c){var l=d3.select(this),A=this;a.update=function(){l.transition().call(a)},a.container=this;var B=(h||parseInt(l.style("width"))||960)-f.left-f.right,C=(i||parseInt(l.style("height"))||400)-f.top-f.bottom,D=c.filter(function(a){return!a.disabled&&"line"==a.type&&1==a.yAxis}),E=c.filter(function(a){return!a.disabled&&"line"==a.type&&2==a.yAxis}),F=c.filter(function(a){return!a.disabled&&"bar"==a.type&&1==a.yAxis}),G=c.filter(function(a){return!a.disabled&&"bar"==a.type&&2==a.yAxis}),H=c.filter(function(a){return!a.disabled&&"area"==a.type&&1==a.yAxis}),I=c.filter(function(a){return!a.disabled&&"area"==a.type&&2==a.yAxis}),J=c.filter(function(a){return!a.disabled&&1==a.yAxis}).map(function(a){return a.values.map(function(a){return{x:a.x,y:a.y}})}),K=c.filter(function(a){return!a.disabled&&2==a.yAxis}).map(function(a){return a.values.map(function(a){return{x:a.x,y:a.y}})});b.domain(d3.extent(d3.merge(J.concat(K)),function(a){return a.x})).range([0,B]);var L=l.selectAll("g.wrap.multiChart").data([c]),M=L.enter().append("g").attr("class","wrap nvd3 multiChart").append("g");M.append("g").attr("class","x axis"),M.append("g").attr("class","y1 axis"),M.append("g").attr("class","y2 axis"),M.append("g").attr("class","lines1Wrap"),M.append("g").attr("class","lines2Wrap"),M.append("g").attr("class","bars1Wrap"),M.append("g").attr("class","bars2Wrap"),M.append("g").attr("class","stack1Wrap"),M.append("g").attr("class","stack2Wrap"),M.append("g").attr("class","legendWrap");var N=L.select("g");j&&(x.width(B/2),N.select(".legendWrap").datum(c.map(function(a){return a.originalKey=void 0===a.originalKey?a.key:a.originalKey,a.key=a.originalKey+(1==a.yAxis?"":" (right axis)"),a})).call(x),f.top!=x.height()&&(f.top=x.height(),C=(i||parseInt(l.style("height"))||400)-f.top-f.bottom),N.select(".legendWrap").attr("transform","translate("+B/2+","+-f.top+")")),o.width(B).height(C).interpolate("monotone").color(c.map(function(a,b){return a.color||g[b%g.length]}).filter(function(a,b){return!c[b].disabled&&1==c[b].yAxis&&"line"==c[b].type})),p.width(B).height(C).interpolate("monotone").color(c.map(function(a,b){return a.color||g[b%g.length]}).filter(function(a,b){return!c[b].disabled&&2==c[b].yAxis&&"line"==c[b].type})),q.width(B).height(C).color(c.map(function(a,b){return a.color||g[b%g.length]}).filter(function(a,b){return!c[b].disabled&&1==c[b].yAxis&&"bar"==c[b].type})),r.width(B).height(C).color(c.map(function(a,b){return a.color||g[b%g.length]}).filter(function(a,b){return!c[b].disabled&&2==c[b].yAxis&&"bar"==c[b].type})),s.width(B).height(C).color(c.map(function(a,b){return a.color||g[b%g.length]}).filter(function(a,b){return!c[b].disabled&&1==c[b].yAxis&&"area"==c[b].type})),t.width(B).height(C).color(c.map(function(a,b){return a.color||g[b%g.length]}).filter(function(a,b){return!c[b].disabled&&2==c[b].yAxis&&"area"==c[b].type})),N.attr("transform","translate("+f.left+","+f.top+")");var O=N.select(".lines1Wrap").datum(D),P=N.select(".bars1Wrap").datum(F),Q=N.select(".stack1Wrap").datum(H),R=N.select(".lines2Wrap").datum(E),S=N.select(".bars2Wrap").datum(G),T=N.select(".stack2Wrap").datum(I),U=H.length?H.map(function(a){return a.values}).reduce(function(a,b){return a.map(function(a,c){return{x:a.x,y:a.y+b[c].y}})}).concat([{x:0,y:0}]):[],V=I.length?I.map(function(a){return a.values}).reduce(function(a,b){return a.map(function(a,c){return{x:a.x,y:a.y+b[c].y}})}).concat([{x:0,y:0}]):[];m.domain(d||d3.extent(d3.merge(J).concat(U),function(a){return a.y})).range([0,C]),n.domain(e||d3.extent(d3.merge(K).concat(V),function(a){return a.y})).range([0,C]),o.yDomain(m.domain()),q.yDomain(m.domain()),s.yDomain(m.domain()),p.yDomain(n.domain()),r.yDomain(n.domain()),t.yDomain(n.domain()),H.length&&d3.transition(Q).call(s),I.length&&d3.transition(T).call(t),F.length&&d3.transition(P).call(q),G.length&&d3.transition(S).call(r),D.length&&d3.transition(O).call(o),E.length&&d3.transition(R).call(p),u.ticks(B/100).tickSize(-C,0),N.select(".x.axis").attr("transform","translate(0,"+C+")"),d3.transition(N.select(".x.axis")).call(u),v.ticks(C/36).tickSize(-B,0),d3.transition(N.select(".y1.axis")).call(v),w.ticks(C/36).tickSize(-B,0),d3.transition(N.select(".y2.axis")).call(w),N.select(".y2.axis").style("opacity",K.length?1:0).attr("transform","translate("+b.range()[1]+",0)"),x.dispatch.on("stateChange",function(){a.update()}),y.on("tooltipShow",function(a){k&&z(a,A.parentNode)})}),a}var b,d,e,f={top:30,right:20,bottom:50,left:60},g=d3.scale.category20().range(),h=null,i=null,j=!0,k=!0,l=function(a,b,c){return"

"+a+"

"+"

"+c+" at "+b+"

"},b=d3.scale.linear(),m=d3.scale.linear(),n=d3.scale.linear(),o=c.models.line().yScale(m),p=c.models.line().yScale(n),q=c.models.multiBar().stacked(!1).yScale(m),r=c.models.multiBar().stacked(!1).yScale(n),s=c.models.stackedArea().yScale(m),t=c.models.stackedArea().yScale(n),u=c.models.axis().scale(b).orient("bottom").tickPadding(5),v=c.models.axis().scale(m).orient("left"),w=c.models.axis().scale(n).orient("right"),x=c.models.legend().height(30),y=d3.dispatch("tooltipShow","tooltipHide"),z=function(b,d){var e=b.pos[0]+(d.offsetLeft||0),f=b.pos[1]+(d.offsetTop||0),g=u.tickFormat()(o.x()(b.point,b.pointIndex)),h=(2==b.series.yAxis?w:v).tickFormat()(o.y()(b.point,b.pointIndex)),i=l(b.series.key,g,h,b,a);c.tooltip.show([e,f],i,void 0,void 0,d.offsetParent)};return o.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+f.left,a.pos[1]+f.top],y.tooltipShow(a)}),o.dispatch.on("elementMouseout.tooltip",function(a){y.tooltipHide(a)}),p.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+f.left,a.pos[1]+f.top],y.tooltipShow(a)}),p.dispatch.on("elementMouseout.tooltip",function(a){y.tooltipHide(a)}),q.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+f.left,a.pos[1]+f.top],y.tooltipShow(a)}),q.dispatch.on("elementMouseout.tooltip",function(a){y.tooltipHide(a)}),r.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+f.left,a.pos[1]+f.top],y.tooltipShow(a)}),r.dispatch.on("elementMouseout.tooltip",function(a){y.tooltipHide(a)}),s.dispatch.on("tooltipShow",function(a){return Math.round(100*s.y()(a.point))?(a.pos=[a.pos[0]+f.left,a.pos[1]+f.top],y.tooltipShow(a),void 0):(setTimeout(function(){d3.selectAll(".point.hover").classed("hover",!1)},0),!1)}),s.dispatch.on("tooltipHide",function(a){y.tooltipHide(a)}),t.dispatch.on("tooltipShow",function(a){return Math.round(100*t.y()(a.point))?(a.pos=[a.pos[0]+f.left,a.pos[1]+f.top],y.tooltipShow(a),void 0):(setTimeout(function(){d3.selectAll(".point.hover").classed("hover",!1)},0),!1)}),t.dispatch.on("tooltipHide",function(a){y.tooltipHide(a)}),o.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+f.left,a.pos[1]+f.top],y.tooltipShow(a)}),o.dispatch.on("elementMouseout.tooltip",function(a){y.tooltipHide(a)}),p.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+f.left,a.pos[1]+f.top],y.tooltipShow(a)}),p.dispatch.on("elementMouseout.tooltip",function(a){y.tooltipHide(a)}),y.on("tooltipHide",function(){k&&c.tooltip.cleanup()}),a.dispatch=y,a.lines1=o,a.lines2=p,a.bars1=q,a.bars2=r,a.stack1=s,a.stack2=t,a.xAxis=u,a.yAxis1=v,a.yAxis2=w,a.options=c.utils.optionsFunc.bind(a),a.x=function(b){return arguments.length?(getX=b,o.x(b),q.x(b),a):getX},a.y=function(b){return arguments.length?(getY=b,o.y(b),q.y(b),a):getY},a.yDomain1=function(b){return arguments.length?(d=b,a):d},a.yDomain2=function(b){return arguments.length?(e=b,a):e},a.margin=function(b){return arguments.length?(f=b,a):f},a.width=function(b){return arguments.length?(h=b,a):h},a.height=function(b){return arguments.length?(i=b,a):i},a.color=function(b){return arguments.length?(g=b,x.color(b),a):g},a.showLegend=function(b){return arguments.length?(j=b,a):j},a.tooltips=function(b){return arguments.length?(k=b,a):k},a.tooltipContent=function(b){return arguments.length?(l=b,a):l},a},c.models.ohlcBar=function(){"use strict";function a(c){return c.each(function(a){var c=h-g.left-g.right,w=i-g.top-g.bottom,y=d3.select(this);k.domain(b||d3.extent(a[0].values.map(m).concat(s))),u?k.range(e||[.5*c/a[0].values.length,c*(a[0].values.length-.5)/a[0].values.length]):k.range(e||[0,c]),l.domain(d||[d3.min(a[0].values.map(r).concat(t)),d3.max(a[0].values.map(q).concat(t))]).range(f||[w,0]),k.domain()[0]===k.domain()[1]&&(k.domain()[0]?k.domain([k.domain()[0]-.01*k.domain()[0],k.domain()[1]+.01*k.domain()[1]]):k.domain([-1,1])),l.domain()[0]===l.domain()[1]&&(l.domain()[0]?l.domain([l.domain()[0]+.01*l.domain()[0],l.domain()[1]-.01*l.domain()[1]]):l.domain([-1,1]));var z=d3.select(this).selectAll("g.nv-wrap.nv-ohlcBar").data([a[0].values]),A=z.enter().append("g").attr("class","nvd3 nv-wrap nv-ohlcBar"),B=A.append("defs"),C=A.append("g"),D=z.select("g");C.append("g").attr("class","nv-ticks"),z.attr("transform","translate("+g.left+","+g.top+")"),y.on("click",function(a,b){x.chartClick({data:a,index:b,pos:d3.event,id:j})}),B.append("clipPath").attr("id","nv-chart-clip-path-"+j).append("rect"),z.select("#nv-chart-clip-path-"+j+" rect").attr("width",c).attr("height",w),D.attr("clip-path",v?"url(#nv-chart-clip-path-"+j+")":"");var E=z.select(".nv-ticks").selectAll(".nv-tick").data(function(a){return a});E.exit().remove(),E.enter().append("path").attr("class",function(a,b,c){return(o(a,b)>p(a,b)?"nv-tick negative":"nv-tick positive")+" nv-tick-"+c+"-"+b}).attr("d",function(b,d){var e=.9*(c/a[0].values.length); +return"m0,0l0,"+(l(o(b,d))-l(q(b,d)))+"l"+-e/2+",0l"+e/2+",0l0,"+(l(r(b,d))-l(o(b,d)))+"l0,"+(l(p(b,d))-l(r(b,d)))+"l"+e/2+",0l"+-e/2+",0z"}).attr("transform",function(a,b){return"translate("+k(m(a,b))+","+l(q(a,b))+")"}).on("mouseover",function(b,c){d3.select(this).classed("hover",!0),x.elementMouseover({point:b,series:a[0],pos:[k(m(b,c)),l(n(b,c))],pointIndex:c,seriesIndex:0,e:d3.event})}).on("mouseout",function(b,c){d3.select(this).classed("hover",!1),x.elementMouseout({point:b,series:a[0],pointIndex:c,seriesIndex:0,e:d3.event})}).on("click",function(a,b){x.elementClick({value:n(a,b),data:a,index:b,pos:[k(m(a,b)),l(n(a,b))],e:d3.event,id:j}),d3.event.stopPropagation()}).on("dblclick",function(a,b){x.elementDblClick({value:n(a,b),data:a,index:b,pos:[k(m(a,b)),l(n(a,b))],e:d3.event,id:j}),d3.event.stopPropagation()}),E.attr("class",function(a,b,c){return(o(a,b)>p(a,b)?"nv-tick negative":"nv-tick positive")+" nv-tick-"+c+"-"+b}),d3.transition(E).attr("transform",function(a,b){return"translate("+k(m(a,b))+","+l(q(a,b))+")"}).attr("d",function(b,d){var e=.9*(c/a[0].values.length);return"m0,0l0,"+(l(o(b,d))-l(q(b,d)))+"l"+-e/2+",0l"+e/2+",0l0,"+(l(r(b,d))-l(o(b,d)))+"l0,"+(l(p(b,d))-l(r(b,d)))+"l"+e/2+",0l"+-e/2+",0z"})}),a}var b,d,e,f,g={top:0,right:0,bottom:0,left:0},h=960,i=500,j=Math.floor(1e4*Math.random()),k=d3.scale.linear(),l=d3.scale.linear(),m=function(a){return a.x},n=function(a){return a.y},o=function(a){return a.open},p=function(a){return a.close},q=function(a){return a.high},r=function(a){return a.low},s=[],t=[],u=!1,v=!0,w=c.utils.defaultColor(),x=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return a.dispatch=x,a.options=c.utils.optionsFunc.bind(a),a.x=function(b){return arguments.length?(m=b,a):m},a.y=function(b){return arguments.length?(n=b,a):n},a.open=function(b){return arguments.length?(o=b,a):o},a.close=function(b){return arguments.length?(p=b,a):p},a.high=function(b){return arguments.length?(q=b,a):q},a.low=function(b){return arguments.length?(r=b,a):r},a.margin=function(b){return arguments.length?(g.top="undefined"!=typeof b.top?b.top:g.top,g.right="undefined"!=typeof b.right?b.right:g.right,g.bottom="undefined"!=typeof b.bottom?b.bottom:g.bottom,g.left="undefined"!=typeof b.left?b.left:g.left,a):g},a.width=function(b){return arguments.length?(h=b,a):h},a.height=function(b){return arguments.length?(i=b,a):i},a.xScale=function(b){return arguments.length?(k=b,a):k},a.yScale=function(b){return arguments.length?(l=b,a):l},a.xDomain=function(c){return arguments.length?(b=c,a):b},a.yDomain=function(b){return arguments.length?(d=b,a):d},a.xRange=function(b){return arguments.length?(e=b,a):e},a.yRange=function(b){return arguments.length?(f=b,a):f},a.forceX=function(b){return arguments.length?(s=b,a):s},a.forceY=function(b){return arguments.length?(t=b,a):t},a.padData=function(b){return arguments.length?(u=b,a):u},a.clipEdge=function(b){return arguments.length?(v=b,a):v},a.color=function(b){return arguments.length?(w=c.utils.getColor(b),a):w},a.id=function(b){return arguments.length?(j=b,a):j},a},c.models.pie=function(){"use strict";function a(c){return c.each(function(a){function c(a){a.endAngle=isNaN(a.endAngle)?0:a.endAngle,a.startAngle=isNaN(a.startAngle)?0:a.startAngle,q||(a.innerRadius=0);var b=d3.interpolate(this._current,a);return this._current=b(0),function(a){return D(b(a))}}var h=d-b.left-b.right,k=e-b.top-b.bottom,w=Math.min(h,k)/2,x=w-w/5,y=d3.select(this),z=y.selectAll(".nv-wrap.nv-pie").data(a),A=z.enter().append("g").attr("class","nvd3 nv-wrap nv-pie nv-chart-"+i),B=A.append("g"),C=z.select("g");B.append("g").attr("class","nv-pie"),z.attr("transform","translate("+b.left+","+b.top+")"),C.select(".nv-pie").attr("transform","translate("+h/2+","+k/2+")"),y.on("click",function(a,b){v.chartClick({data:a,index:b,pos:d3.event,id:i})});var D=d3.svg.arc().outerRadius(x);s&&D.startAngle(s),t&&D.endAngle(t),q&&D.innerRadius(w*u);var E=d3.layout.pie().sort(null).value(function(a){return a.disabled?0:g(a)}),F=z.select(".nv-pie").selectAll(".nv-slice").data(E);F.exit().remove();var G=F.enter().append("g").attr("class","nv-slice").on("mouseover",function(a,b){d3.select(this).classed("hover",!0),v.elementMouseover({label:f(a.data),value:g(a.data),point:a.data,pointIndex:b,pos:[d3.event.pageX,d3.event.pageY],id:i})}).on("mouseout",function(a,b){d3.select(this).classed("hover",!1),v.elementMouseout({label:f(a.data),value:g(a.data),point:a.data,index:b,id:i})}).on("click",function(a,b){v.elementClick({label:f(a.data),value:g(a.data),point:a.data,index:b,pos:d3.event,id:i}),d3.event.stopPropagation()}).on("dblclick",function(a,b){v.elementDblClick({label:f(a.data),value:g(a.data),point:a.data,index:b,pos:d3.event,id:i}),d3.event.stopPropagation()});if(F.attr("fill",function(a,b){return j(a,b)}).attr("stroke",function(a,b){return j(a,b)}),G.append("path").each(function(a){this._current=a}),F.select("path").transition().attr("d",D).attrTween("d",c),l){var H=d3.svg.arc().innerRadius(0);m&&(H=D),n&&(H=d3.svg.arc().outerRadius(D.outerRadius())),G.append("g").classed("nv-label",!0).each(function(a){var b=d3.select(this);b.attr("transform",function(a){if(r){a.outerRadius=x+10,a.innerRadius=x+15;var b=(a.startAngle+a.endAngle)/2*(180/Math.PI);return(a.startAngle+a.endAngle)/2p?c[o]:""});var c=b.select("text").node().getBBox();b.select(".nv-label rect").attr("width",c.width+10).attr("height",c.height+10).attr("transform",function(){return"translate("+[c.x-5,c.y-5]+")"})})}}),a}var b={top:0,right:0,bottom:0,left:0},d=500,e=500,f=function(a){return a.x},g=function(a){return a.y},h=function(a){return a.description},i=Math.floor(1e4*Math.random()),j=c.utils.defaultColor(),k=d3.format(",.2f"),l=!0,m=!0,n=!1,o="key",p=.02,q=!1,r=!1,s=!1,t=!1,u=.5,v=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return a.dispatch=v,a.options=c.utils.optionsFunc.bind(a),a.margin=function(c){return arguments.length?(b.top="undefined"!=typeof c.top?c.top:b.top,b.right="undefined"!=typeof c.right?c.right:b.right,b.bottom="undefined"!=typeof c.bottom?c.bottom:b.bottom,b.left="undefined"!=typeof c.left?c.left:b.left,a):b},a.width=function(b){return arguments.length?(d=b,a):d},a.height=function(b){return arguments.length?(e=b,a):e},a.values=function(){return c.log("pie.values() is no longer supported."),a},a.x=function(b){return arguments.length?(f=b,a):f},a.y=function(b){return arguments.length?(g=d3.functor(b),a):g},a.description=function(b){return arguments.length?(h=b,a):h},a.showLabels=function(b){return arguments.length?(l=b,a):l},a.labelSunbeamLayout=function(b){return arguments.length?(r=b,a):r},a.donutLabelsOutside=function(b){return arguments.length?(n=b,a):n},a.pieLabelsOutside=function(b){return arguments.length?(m=b,a):m},a.labelType=function(b){return arguments.length?(o=b,o=o||"key",a):o},a.donut=function(b){return arguments.length?(q=b,a):q},a.donutRatio=function(b){return arguments.length?(u=b,a):u},a.startAngle=function(b){return arguments.length?(s=b,a):s},a.endAngle=function(b){return arguments.length?(t=b,a):t},a.id=function(b){return arguments.length?(i=b,a):i},a.color=function(b){return arguments.length?(j=c.utils.getColor(b),a):j},a.valueFormat=function(b){return arguments.length?(k=b,a):k},a.labelThreshold=function(b){return arguments.length?(p=b,a):p},a},c.models.pieChart=function(){"use strict";function a(c){return c.each(function(c){var i=d3.select(this),j=(f||parseInt(i.style("width"))||960)-e.left-e.right,k=(g||parseInt(i.style("height"))||400)-e.top-e.bottom;if(a.update=function(){i.transition().call(a)},a.container=this,l.disabled=c.map(function(a){return!!a.disabled}),!m){var p;m={};for(p in l)m[p]=l[p]instanceof Array?l[p].slice(0):l[p]}if(!c||!c.length){var q=i.selectAll(".nv-noData").data([n]);return q.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),q.attr("x",e.left+j/2).attr("y",e.top+k/2).text(function(a){return a}),a}i.selectAll(".nv-noData").remove();var r=i.selectAll("g.nv-wrap.nv-pieChart").data([c]),s=r.enter().append("g").attr("class","nvd3 nv-wrap nv-pieChart").append("g"),t=r.select("g");s.append("g").attr("class","nv-pieWrap"),s.append("g").attr("class","nv-legendWrap"),h&&(d.width(j).key(b.x()),r.select(".nv-legendWrap").datum(c).call(d),e.top!=d.height()&&(e.top=d.height(),k=(g||parseInt(i.style("height"))||400)-e.top-e.bottom),r.select(".nv-legendWrap").attr("transform","translate(0,"+-e.top+")")),r.attr("transform","translate("+e.left+","+e.top+")"),b.width(j).height(k);var u=t.select(".nv-pieWrap").datum([c]);d3.transition(u).call(b),d.dispatch.on("stateChange",function(b){l=b,o.stateChange(l),a.update()}),b.dispatch.on("elementMouseout.tooltip",function(a){o.tooltipHide(a)}),o.on("changeState",function(b){"undefined"!=typeof b.disabled&&(c.forEach(function(a,c){a.disabled=b.disabled[c]}),l.disabled=b.disabled),a.update()})}),a}var b=c.models.pie(),d=c.models.legend(),e={top:30,right:20,bottom:20,left:20},f=null,g=null,h=!0,i=c.utils.defaultColor(),j=!0,k=function(a,b){return"

"+a+"

"+"

"+b+"

"},l={},m=null,n="No Data Available.",o=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),p=function(d,e){var f=b.description()(d.point)||b.x()(d.point),g=d.pos[0]+(e&&e.offsetLeft||0),h=d.pos[1]+(e&&e.offsetTop||0),i=b.valueFormat()(b.y()(d.point)),j=k(f,i,d,a);c.tooltip.show([g,h],j,d.value<0?"n":"s",null,e)};return b.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+e.left,a.pos[1]+e.top],o.tooltipShow(a)}),o.on("tooltipShow",function(a){j&&p(a)}),o.on("tooltipHide",function(){j&&c.tooltip.cleanup()}),a.legend=d,a.dispatch=o,a.pie=b,d3.rebind(a,b,"valueFormat","values","x","y","description","id","showLabels","donutLabelsOutside","pieLabelsOutside","labelType","donut","donutRatio","labelThreshold"),a.options=c.utils.optionsFunc.bind(a),a.margin=function(b){return arguments.length?(e.top="undefined"!=typeof b.top?b.top:e.top,e.right="undefined"!=typeof b.right?b.right:e.right,e.bottom="undefined"!=typeof b.bottom?b.bottom:e.bottom,e.left="undefined"!=typeof b.left?b.left:e.left,a):e},a.width=function(b){return arguments.length?(f=b,a):f},a.height=function(b){return arguments.length?(g=b,a):g},a.color=function(e){return arguments.length?(i=c.utils.getColor(e),d.color(i),b.color(i),a):i},a.showLegend=function(b){return arguments.length?(h=b,a):h},a.tooltips=function(b){return arguments.length?(j=b,a):j},a.tooltipContent=function(b){return arguments.length?(k=b,a):k},a.state=function(b){return arguments.length?(l=b,a):l},a.defaultState=function(b){return arguments.length?(m=b,a):m},a.noData=function(b){return arguments.length?(n=b,a):n},a},c.models.scatter=function(){"use strict";function a(O){return O.each(function(a){function O(){if(!w)return!1;var b=d3.merge(a.map(function(a,b){return a.values.map(function(a,c){var d=o(a,c),e=p(a,c);return[l(d)+1e-7*Math.random(),m(e)+1e-7*Math.random(),b,c,a]}).filter(function(a,b){return y(a[4],b)})}));if(M===!0){if(C){var c=T.select("defs").selectAll(".nv-point-clips").data([k]).enter();c.append("clipPath").attr("class","nv-point-clips").attr("id","nv-points-clip-"+k);var d=T.select("#nv-points-clip-"+k).selectAll("circle").data(b);d.enter().append("circle").attr("r",D),d.exit().remove(),d.attr("cx",function(a){return a[0]}).attr("cy",function(a){return a[1]}),T.select(".nv-point-paths").attr("clip-path","url(#nv-points-clip-"+k+")")}b.length&&(b.push([l.range()[0]-20,m.range()[0]-20,null,null]),b.push([l.range()[1]+20,m.range()[1]+20,null,null]),b.push([l.range()[0]-20,m.range()[0]+20,null,null]),b.push([l.range()[1]+20,m.range()[1]-20,null,null]));var e=d3.geom.polygon([[-10,-10],[-10,i+10],[h+10,i+10],[h+10,-10]]),f=d3.geom.voronoi(b).map(function(a,c){return{data:e.clip(a),series:b[c][2],point:b[c][3]}}),j=T.select(".nv-point-paths").selectAll("path").data(f);j.enter().append("path").attr("class",function(a,b){return"nv-path-"+b}),j.exit().remove(),j.attr("d",function(a){return 0===a.data.length?"M 0 0":"M"+a.data.join("L")+"Z"});var n=function(b,c){if(N)return 0;var d=a[b.series];if("undefined"!=typeof d){var e=d.values[b.point];c({point:e,series:d,pos:[l(o(e,b.point))+g.left,m(p(e,b.point))+g.top],seriesIndex:b.series,pointIndex:b.point})}};j.on("click",function(a){n(a,L.elementClick)}).on("mouseover",function(a){n(a,L.elementMouseover)}).on("mouseout",function(a){n(a,L.elementMouseout)})}else T.select(".nv-groups").selectAll(".nv-group").selectAll(".nv-point").on("click",function(b,c){if(N||!a[b.series])return 0;var d=a[b.series],e=d.values[c];L.elementClick({point:e,series:d,pos:[l(o(e,c))+g.left,m(p(e,c))+g.top],seriesIndex:b.series,pointIndex:c})}).on("mouseover",function(b,c){if(N||!a[b.series])return 0;var d=a[b.series],e=d.values[c];L.elementMouseover({point:e,series:d,pos:[l(o(e,c))+g.left,m(p(e,c))+g.top],seriesIndex:b.series,pointIndex:c})}).on("mouseout",function(b,c){if(N||!a[b.series])return 0;var d=a[b.series],e=d.values[c];L.elementMouseout({point:e,series:d,seriesIndex:b.series,pointIndex:c})});N=!1}var P=h-g.left-g.right,Q=i-g.top-g.bottom,R=d3.select(this);a.forEach(function(a,b){a.values.forEach(function(a){a.series=b})});var S=E&&F&&I?[]:d3.merge(a.map(function(a){return a.values.map(function(a,b){return{x:o(a,b),y:p(a,b),size:q(a,b)}})}));l.domain(E||d3.extent(S.map(function(a){return a.x}).concat(t))),z&&a[0]?l.range(G||[(P*A+P)/(2*a[0].values.length),P-P*(1+A)/(2*a[0].values.length)]):l.range(G||[0,P]),m.domain(F||d3.extent(S.map(function(a){return a.y}).concat(u))).range(H||[Q,0]),n.domain(I||d3.extent(S.map(function(a){return a.size}).concat(v))).range(J||[16,256]),(l.domain()[0]===l.domain()[1]||m.domain()[0]===m.domain()[1])&&(K=!0),l.domain()[0]===l.domain()[1]&&(l.domain()[0]?l.domain([l.domain()[0]-.01*l.domain()[0],l.domain()[1]+.01*l.domain()[1]]):l.domain([-1,1])),m.domain()[0]===m.domain()[1]&&(m.domain()[0]?m.domain([m.domain()[0]-.01*m.domain()[0],m.domain()[1]+.01*m.domain()[1]]):m.domain([-1,1])),isNaN(l.domain()[0])&&l.domain([-1,1]),isNaN(m.domain()[0])&&m.domain([-1,1]),b=b||l,d=d||m,e=e||n;var T=R.selectAll("g.nv-wrap.nv-scatter").data([a]),U=T.enter().append("g").attr("class","nvd3 nv-wrap nv-scatter nv-chart-"+k+(K?" nv-single-point":"")),V=U.append("defs"),W=U.append("g"),X=T.select("g");W.append("g").attr("class","nv-groups"),W.append("g").attr("class","nv-point-paths"),T.attr("transform","translate("+g.left+","+g.top+")"),V.append("clipPath").attr("id","nv-edge-clip-"+k).append("rect"),T.select("#nv-edge-clip-"+k+" rect").attr("width",P).attr("height",Q),X.attr("clip-path",B?"url(#nv-edge-clip-"+k+")":""),N=!0;var Y=T.select(".nv-groups").selectAll(".nv-group").data(function(a){return a},function(a){return a.key});if(Y.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),Y.exit().remove(),Y.attr("class",function(a,b){return"nv-group nv-series-"+b}).classed("hover",function(a){return a.hover}),Y.transition().style("fill",function(a,b){return j(a,b)}).style("stroke",function(a,b){return j(a,b)}).style("stroke-opacity",1).style("fill-opacity",.5),s){var Z=Y.selectAll("circle.nv-point").data(function(a){return a.values},x);Z.enter().append("circle").style("fill",function(a){return a.color}).style("stroke",function(a){return a.color}).attr("cx",function(a,d){return c.utils.NaNtoZero(b(o(a,d)))}).attr("cy",function(a,b){return c.utils.NaNtoZero(d(p(a,b)))}).attr("r",function(a,b){return Math.sqrt(n(q(a,b))/Math.PI)}),Z.exit().remove(),Y.exit().selectAll("path.nv-point").transition().attr("cx",function(a,b){return c.utils.NaNtoZero(l(o(a,b)))}).attr("cy",function(a,b){return c.utils.NaNtoZero(m(p(a,b)))}).remove(),Z.each(function(a,b){d3.select(this).classed("nv-point",!0).classed("nv-point-"+b,!0).classed("hover",!1)}),Z.transition().attr("cx",function(a,b){return c.utils.NaNtoZero(l(o(a,b)))}).attr("cy",function(a,b){return c.utils.NaNtoZero(m(p(a,b)))}).attr("r",function(a,b){return Math.sqrt(n(q(a,b))/Math.PI)})}else{var Z=Y.selectAll("path.nv-point").data(function(a){return a.values});Z.enter().append("path").style("fill",function(a){return a.color}).style("stroke",function(a){return a.color}).attr("transform",function(a,c){return"translate("+b(o(a,c))+","+d(p(a,c))+")"}).attr("d",d3.svg.symbol().type(r).size(function(a,b){return n(q(a,b))})),Z.exit().remove(),Y.exit().selectAll("path.nv-point").transition().attr("transform",function(a,b){return"translate("+l(o(a,b))+","+m(p(a,b))+")"}).remove(),Z.each(function(a,b){d3.select(this).classed("nv-point",!0).classed("nv-point-"+b,!0).classed("hover",!1)}),Z.transition().attr("transform",function(a,b){return"translate("+l(o(a,b))+","+m(p(a,b))+")"}).attr("d",d3.svg.symbol().type(r).size(function(a,b){return n(q(a,b))}))}clearTimeout(f),f=setTimeout(O,300),b=l.copy(),d=m.copy(),e=n.copy()}),a}var b,d,e,f,g={top:0,right:0,bottom:0,left:0},h=960,i=500,j=c.utils.defaultColor(),k=Math.floor(1e5*Math.random()),l=d3.scale.linear(),m=d3.scale.linear(),n=d3.scale.linear(),o=function(a){return a.x},p=function(a){return a.y},q=function(a){return a.size||1},r=function(a){return a.shape||"circle"},s=!0,t=[],u=[],v=[],w=!0,x=null,y=function(a){return!a.notActive},z=!1,A=.1,B=!1,C=!0,D=function(){return 25},E=null,F=null,G=null,H=null,I=null,J=null,K=!1,L=d3.dispatch("elementClick","elementMouseover","elementMouseout"),M=!0,N=!1;return a.clearHighlights=function(){d3.selectAll(".nv-chart-"+k+" .nv-point.hover").classed("hover",!1)},a.highlightPoint=function(a,b,c){d3.select(".nv-chart-"+k+" .nv-series-"+a+" .nv-point-"+b).classed("hover",c)},L.on("elementMouseover.point",function(b){w&&a.highlightPoint(b.seriesIndex,b.pointIndex,!0)}),L.on("elementMouseout.point",function(b){w&&a.highlightPoint(b.seriesIndex,b.pointIndex,!1)}),a.dispatch=L,a.options=c.utils.optionsFunc.bind(a),a.x=function(b){return arguments.length?(o=d3.functor(b),a):o},a.y=function(b){return arguments.length?(p=d3.functor(b),a):p},a.size=function(b){return arguments.length?(q=d3.functor(b),a):q},a.margin=function(b){return arguments.length?(g.top="undefined"!=typeof b.top?b.top:g.top,g.right="undefined"!=typeof b.right?b.right:g.right,g.bottom="undefined"!=typeof b.bottom?b.bottom:g.bottom,g.left="undefined"!=typeof b.left?b.left:g.left,a):g},a.width=function(b){return arguments.length?(h=b,a):h},a.height=function(b){return arguments.length?(i=b,a):i},a.xScale=function(b){return arguments.length?(l=b,a):l},a.yScale=function(b){return arguments.length?(m=b,a):m},a.zScale=function(b){return arguments.length?(n=b,a):n},a.xDomain=function(b){return arguments.length?(E=b,a):E},a.yDomain=function(b){return arguments.length?(F=b,a):F},a.sizeDomain=function(b){return arguments.length?(I=b,a):I},a.xRange=function(b){return arguments.length?(G=b,a):G},a.yRange=function(b){return arguments.length?(H=b,a):H},a.sizeRange=function(b){return arguments.length?(J=b,a):J},a.forceX=function(b){return arguments.length?(t=b,a):t},a.forceY=function(b){return arguments.length?(u=b,a):u},a.forceSize=function(b){return arguments.length?(v=b,a):v},a.interactive=function(b){return arguments.length?(w=b,a):w},a.pointKey=function(b){return arguments.length?(x=b,a):x},a.pointActive=function(b){return arguments.length?(y=b,a):y},a.padData=function(b){return arguments.length?(z=b,a):z},a.padDataOuter=function(b){return arguments.length?(A=b,a):A},a.clipEdge=function(b){return arguments.length?(B=b,a):B},a.clipVoronoi=function(b){return arguments.length?(C=b,a):C},a.useVoronoi=function(b){return arguments.length?(M=b,M===!1&&(C=!1),a):M},a.clipRadius=function(b){return arguments.length?(D=b,a):D},a.color=function(b){return arguments.length?(j=c.utils.getColor(b),a):j},a.shape=function(b){return arguments.length?(r=b,a):r},a.onlyCircles=function(b){return arguments.length?(s=b,a):s},a.id=function(b){return arguments.length?(k=b,a):k},a.singlePoint=function(b){return arguments.length?(K=b,a):K},a},c.models.scatterChart=function(){"use strict";function a(c){return c.each(function(c){function B(){if(z)return U.select(".nv-point-paths").style("pointer-events","all"),!1;U.select(".nv-point-paths").style("pointer-events","none");var a=d3.mouse(this);n.distortion(y).focus(a[0]),o.distortion(y).focus(a[1]),U.select(".nv-scatterWrap").call(b),u&&U.select(".nv-x.nv-axis").call(d),v&&U.select(".nv-y.nv-axis").call(e),U.select(".nv-distributionX").datum(c.filter(function(a){return!a.disabled})).call(h),U.select(".nv-distributionY").datum(c.filter(function(a){return!a.disabled})).call(i)}var C=d3.select(this),D=this,N=(k||parseInt(C.style("width"))||960)-j.left-j.right,O=(l||parseInt(C.style("height"))||400)-j.top-j.bottom;if(a.update=function(){C.transition().duration(I).call(a)},a.container=this,E.disabled=c.map(function(a){return!!a.disabled}),!F){var P;F={};for(P in E)F[P]=E[P]instanceof Array?E[P].slice(0):E[P]}if(!(c&&c.length&&c.filter(function(a){return a.values.length}).length)){var Q=C.selectAll(".nv-noData").data([H]);return Q.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),Q.attr("x",j.left+N/2).attr("y",j.top+O/2).text(function(a){return a}),a}C.selectAll(".nv-noData").remove(),J=J||n,K=K||o;var R=C.selectAll("g.nv-wrap.nv-scatterChart").data([c]),S=R.enter().append("g").attr("class","nvd3 nv-wrap nv-scatterChart nv-chart-"+b.id()),T=S.append("g"),U=R.select("g");if(T.append("rect").attr("class","nvd3 nv-background"),T.append("g").attr("class","nv-x nv-axis"),T.append("g").attr("class","nv-y nv-axis"),T.append("g").attr("class","nv-scatterWrap"),T.append("g").attr("class","nv-distWrap"),T.append("g").attr("class","nv-legendWrap"),T.append("g").attr("class","nv-controlsWrap"),t){var V=x?N/2:N;f.width(V),R.select(".nv-legendWrap").datum(c).call(f),j.top!=f.height()&&(j.top=f.height(),O=(l||parseInt(C.style("height"))||400)-j.top-j.bottom),R.select(".nv-legendWrap").attr("transform","translate("+(N-V)+","+-j.top+")")}if(x&&(g.width(180).color(["#444"]),U.select(".nv-controlsWrap").datum(M).attr("transform","translate(0,"+-j.top+")").call(g)),R.attr("transform","translate("+j.left+","+j.top+")"),w&&U.select(".nv-y.nv-axis").attr("transform","translate("+N+",0)"),b.width(N).height(O).color(c.map(function(a,b){return a.color||m(a,b)}).filter(function(a,b){return!c[b].disabled})),0!==p&&b.xDomain(null),0!==q&&b.yDomain(null),R.select(".nv-scatterWrap").datum(c.filter(function(a){return!a.disabled})).call(b),0!==p){var W=n.domain()[1]-n.domain()[0];b.xDomain([n.domain()[0]-p*W,n.domain()[1]+p*W])}if(0!==q){var X=o.domain()[1]-o.domain()[0];b.yDomain([o.domain()[0]-q*X,o.domain()[1]+q*X])}(0!==q||0!==p)&&R.select(".nv-scatterWrap").datum(c.filter(function(a){return!a.disabled})).call(b),u&&(d.scale(n).ticks(d.ticks()&&d.ticks().length?d.ticks():N/100).tickSize(-O,0),U.select(".nv-x.nv-axis").attr("transform","translate(0,"+o.range()[0]+")").call(d)),v&&(e.scale(o).ticks(e.ticks()&&e.ticks().length?e.ticks():O/36).tickSize(-N,0),U.select(".nv-y.nv-axis").call(e)),r&&(h.getData(b.x()).scale(n).width(N).color(c.map(function(a,b){return a.color||m(a,b)}).filter(function(a,b){return!c[b].disabled})),T.select(".nv-distWrap").append("g").attr("class","nv-distributionX"),U.select(".nv-distributionX").attr("transform","translate(0,"+o.range()[0]+")").datum(c.filter(function(a){return!a.disabled})).call(h)),s&&(i.getData(b.y()).scale(o).width(O).color(c.map(function(a,b){return a.color||m(a,b)}).filter(function(a,b){return!c[b].disabled})),T.select(".nv-distWrap").append("g").attr("class","nv-distributionY"),U.select(".nv-distributionY").attr("transform","translate("+(w?N:-i.size())+",0)").datum(c.filter(function(a){return!a.disabled})).call(i)),d3.fisheye&&(U.select(".nv-background").attr("width",N).attr("height",O),U.select(".nv-background").on("mousemove",B),U.select(".nv-background").on("click",function(){z=!z}),b.dispatch.on("elementClick.freezeFisheye",function(){z=!z})),g.dispatch.on("legendClick",function(c){c.disabled=!c.disabled,y=c.disabled?0:2.5,U.select(".nv-background").style("pointer-events",c.disabled?"none":"all"),U.select(".nv-point-paths").style("pointer-events",c.disabled?"all":"none"),c.disabled?(n.distortion(y).focus(0),o.distortion(y).focus(0),U.select(".nv-scatterWrap").call(b),U.select(".nv-x.nv-axis").call(d),U.select(".nv-y.nv-axis").call(e)):z=!1,a.update()}),f.dispatch.on("stateChange",function(b){E.disabled=b.disabled,G.stateChange(E),a.update()}),b.dispatch.on("elementMouseover.tooltip",function(a){d3.select(".nv-chart-"+b.id()+" .nv-series-"+a.seriesIndex+" .nv-distx-"+a.pointIndex).attr("y1",function(){return a.pos[1]-O}),d3.select(".nv-chart-"+b.id()+" .nv-series-"+a.seriesIndex+" .nv-disty-"+a.pointIndex).attr("x2",a.pos[0]+h.size()),a.pos=[a.pos[0]+j.left,a.pos[1]+j.top],G.tooltipShow(a)}),G.on("tooltipShow",function(a){A&&L(a,D.parentNode)}),G.on("changeState",function(b){"undefined"!=typeof b.disabled&&(c.forEach(function(a,c){a.disabled=b.disabled[c]}),E.disabled=b.disabled),a.update()}),J=n.copy(),K=o.copy()}),a}var b=c.models.scatter(),d=c.models.axis(),e=c.models.axis(),f=c.models.legend(),g=c.models.legend(),h=c.models.distribution(),i=c.models.distribution(),j={top:30,right:20,bottom:50,left:75},k=null,l=null,m=c.utils.defaultColor(),n=d3.fisheye?d3.fisheye.scale(d3.scale.linear).distortion(0):b.xScale(),o=d3.fisheye?d3.fisheye.scale(d3.scale.linear).distortion(0):b.yScale(),p=0,q=0,r=!1,s=!1,t=!0,u=!0,v=!0,w=!1,x=!!d3.fisheye,y=0,z=!1,A=!0,B=function(a,b){return""+b+""},C=function(a,b,c){return""+c+""},D=null,E={},F=null,G=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),H="No Data Available.",I=250;b.xScale(n).yScale(o),d.orient("bottom").tickPadding(10),e.orient(w?"right":"left").tickPadding(10),h.axis("x"),i.axis("y"),g.updateState(!1);var J,K,L=function(f,g){var h=f.pos[0]+(g.offsetLeft||0),i=f.pos[1]+(g.offsetTop||0),k=f.pos[0]+(g.offsetLeft||0),l=o.range()[0]+j.top+(g.offsetTop||0),m=n.range()[0]+j.left+(g.offsetLeft||0),p=f.pos[1]+(g.offsetTop||0),q=d.tickFormat()(b.x()(f.point,f.pointIndex)),r=e.tickFormat()(b.y()(f.point,f.pointIndex));null!=B&&c.tooltip.show([k,l],B(f.series.key,q,r,f,a),"n",1,g,"x-nvtooltip"),null!=C&&c.tooltip.show([m,p],C(f.series.key,q,r,f,a),"e",1,g,"y-nvtooltip"),null!=D&&c.tooltip.show([h,i],D(f.series.key,q,r,f,a),f.value<0?"n":"s",null,g)},M=[{key:"Magnify",disabled:!0}];return b.dispatch.on("elementMouseout.tooltip",function(a){G.tooltipHide(a),d3.select(".nv-chart-"+b.id()+" .nv-series-"+a.seriesIndex+" .nv-distx-"+a.pointIndex).attr("y1",0),d3.select(".nv-chart-"+b.id()+" .nv-series-"+a.seriesIndex+" .nv-disty-"+a.pointIndex).attr("x2",i.size())}),G.on("tooltipHide",function(){A&&c.tooltip.cleanup()}),a.dispatch=G,a.scatter=b,a.legend=f,a.controls=g,a.xAxis=d,a.yAxis=e,a.distX=h,a.distY=i,d3.rebind(a,b,"id","interactive","pointActive","x","y","shape","size","xScale","yScale","zScale","xDomain","yDomain","xRange","yRange","sizeDomain","sizeRange","forceX","forceY","forceSize","clipVoronoi","clipRadius","useVoronoi"),a.options=c.utils.optionsFunc.bind(a),a.margin=function(b){return arguments.length?(j.top="undefined"!=typeof b.top?b.top:j.top,j.right="undefined"!=typeof b.right?b.right:j.right,j.bottom="undefined"!=typeof b.bottom?b.bottom:j.bottom,j.left="undefined"!=typeof b.left?b.left:j.left,a):j},a.width=function(b){return arguments.length?(k=b,a):k},a.height=function(b){return arguments.length?(l=b,a):l},a.color=function(b){return arguments.length?(m=c.utils.getColor(b),f.color(m),h.color(m),i.color(m),a):m},a.showDistX=function(b){return arguments.length?(r=b,a):r},a.showDistY=function(b){return arguments.length?(s=b,a):s},a.showControls=function(b){return arguments.length?(x=b,a):x},a.showLegend=function(b){return arguments.length?(t=b,a):t},a.showXAxis=function(b){return arguments.length?(u=b,a):u},a.showYAxis=function(b){return arguments.length?(v=b,a):v},a.rightAlignYAxis=function(b){return arguments.length?(w=b,e.orient(b?"right":"left"),a):w},a.fisheye=function(b){return arguments.length?(y=b,a):y},a.xPadding=function(b){return arguments.length?(p=b,a):p},a.yPadding=function(b){return arguments.length?(q=b,a):q},a.tooltips=function(b){return arguments.length?(A=b,a):A},a.tooltipContent=function(b){return arguments.length?(D=b,a):D},a.tooltipXContent=function(b){return arguments.length?(B=b,a):B},a.tooltipYContent=function(b){return arguments.length?(C=b,a):C},a.state=function(b){return arguments.length?(E=b,a):E},a.defaultState=function(b){return arguments.length?(F=b,a):F},a.noData=function(b){return arguments.length?(H=b,a):H},a.transitionDuration=function(b){return arguments.length?(I=b,a):I},a},c.models.scatterPlusLineChart=function(){"use strict";function a(c){return c.each(function(c){function z(){if(x)return S.select(".nv-point-paths").style("pointer-events","all"),!1;S.select(".nv-point-paths").style("pointer-events","none");var a=d3.mouse(this);n.distortion(w).focus(a[0]),o.distortion(w).focus(a[1]),S.select(".nv-scatterWrap").datum(c.filter(function(a){return!a.disabled})).call(b),s&&S.select(".nv-x.nv-axis").call(d),t&&S.select(".nv-y.nv-axis").call(e),S.select(".nv-distributionX").datum(c.filter(function(a){return!a.disabled})).call(h),S.select(".nv-distributionY").datum(c.filter(function(a){return!a.disabled})).call(i)}var A=d3.select(this),B=this,L=(k||parseInt(A.style("width"))||960)-j.left-j.right,M=(l||parseInt(A.style("height"))||400)-j.top-j.bottom;if(a.update=function(){A.transition().duration(G).call(a)},a.container=this,C.disabled=c.map(function(a){return!!a.disabled}),!D){var N;D={};for(N in C)D[N]=C[N]instanceof Array?C[N].slice(0):C[N]}if(!(c&&c.length&&c.filter(function(a){return a.values.length}).length)){var O=A.selectAll(".nv-noData").data([F]);return O.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),O.attr("x",j.left+L/2).attr("y",j.top+M/2).text(function(a){return a}),a}A.selectAll(".nv-noData").remove(),n=b.xScale(),o=b.yScale(),H=H||n,I=I||o;var P=A.selectAll("g.nv-wrap.nv-scatterChart").data([c]),Q=P.enter().append("g").attr("class","nvd3 nv-wrap nv-scatterChart nv-chart-"+b.id()),R=Q.append("g"),S=P.select("g");R.append("rect").attr("class","nvd3 nv-background").style("pointer-events","none"),R.append("g").attr("class","nv-x nv-axis"),R.append("g").attr("class","nv-y nv-axis"),R.append("g").attr("class","nv-scatterWrap"),R.append("g").attr("class","nv-regressionLinesWrap"),R.append("g").attr("class","nv-distWrap"),R.append("g").attr("class","nv-legendWrap"),R.append("g").attr("class","nv-controlsWrap"),P.attr("transform","translate("+j.left+","+j.top+")"),u&&S.select(".nv-y.nv-axis").attr("transform","translate("+L+",0)"),r&&(f.width(L/2),P.select(".nv-legendWrap").datum(c).call(f),j.top!=f.height()&&(j.top=f.height(),M=(l||parseInt(A.style("height"))||400)-j.top-j.bottom),P.select(".nv-legendWrap").attr("transform","translate("+L/2+","+-j.top+")")),v&&(g.width(180).color(["#444"]),S.select(".nv-controlsWrap").datum(K).attr("transform","translate(0,"+-j.top+")").call(g)),b.width(L).height(M).color(c.map(function(a,b){return a.color||m(a,b) +}).filter(function(a,b){return!c[b].disabled})),P.select(".nv-scatterWrap").datum(c.filter(function(a){return!a.disabled})).call(b),P.select(".nv-regressionLinesWrap").attr("clip-path","url(#nv-edge-clip-"+b.id()+")");var T=P.select(".nv-regressionLinesWrap").selectAll(".nv-regLines").data(function(a){return a});T.enter().append("g").attr("class","nv-regLines");var U=T.selectAll(".nv-regLine").data(function(a){return[a]});U.enter().append("line").attr("class","nv-regLine").style("stroke-opacity",0),U.transition().attr("x1",n.range()[0]).attr("x2",n.range()[1]).attr("y1",function(a){return o(n.domain()[0]*a.slope+a.intercept)}).attr("y2",function(a){return o(n.domain()[1]*a.slope+a.intercept)}).style("stroke",function(a,b,c){return m(a,c)}).style("stroke-opacity",function(a){return a.disabled||"undefined"==typeof a.slope||"undefined"==typeof a.intercept?0:1}),s&&(d.scale(n).ticks(d.ticks()?d.ticks():L/100).tickSize(-M,0),S.select(".nv-x.nv-axis").attr("transform","translate(0,"+o.range()[0]+")").call(d)),t&&(e.scale(o).ticks(e.ticks()?e.ticks():M/36).tickSize(-L,0),S.select(".nv-y.nv-axis").call(e)),p&&(h.getData(b.x()).scale(n).width(L).color(c.map(function(a,b){return a.color||m(a,b)}).filter(function(a,b){return!c[b].disabled})),R.select(".nv-distWrap").append("g").attr("class","nv-distributionX"),S.select(".nv-distributionX").attr("transform","translate(0,"+o.range()[0]+")").datum(c.filter(function(a){return!a.disabled})).call(h)),q&&(i.getData(b.y()).scale(o).width(M).color(c.map(function(a,b){return a.color||m(a,b)}).filter(function(a,b){return!c[b].disabled})),R.select(".nv-distWrap").append("g").attr("class","nv-distributionY"),S.select(".nv-distributionY").attr("transform","translate("+(u?L:-i.size())+",0)").datum(c.filter(function(a){return!a.disabled})).call(i)),d3.fisheye&&(S.select(".nv-background").attr("width",L).attr("height",M),S.select(".nv-background").on("mousemove",z),S.select(".nv-background").on("click",function(){x=!x}),b.dispatch.on("elementClick.freezeFisheye",function(){x=!x})),g.dispatch.on("legendClick",function(c){c.disabled=!c.disabled,w=c.disabled?0:2.5,S.select(".nv-background").style("pointer-events",c.disabled?"none":"all"),S.select(".nv-point-paths").style("pointer-events",c.disabled?"all":"none"),c.disabled?(n.distortion(w).focus(0),o.distortion(w).focus(0),S.select(".nv-scatterWrap").call(b),S.select(".nv-x.nv-axis").call(d),S.select(".nv-y.nv-axis").call(e)):x=!1,a.update()}),f.dispatch.on("stateChange",function(b){C=b,E.stateChange(C),a.update()}),b.dispatch.on("elementMouseover.tooltip",function(a){d3.select(".nv-chart-"+b.id()+" .nv-series-"+a.seriesIndex+" .nv-distx-"+a.pointIndex).attr("y1",a.pos[1]-M),d3.select(".nv-chart-"+b.id()+" .nv-series-"+a.seriesIndex+" .nv-disty-"+a.pointIndex).attr("x2",a.pos[0]+h.size()),a.pos=[a.pos[0]+j.left,a.pos[1]+j.top],E.tooltipShow(a)}),E.on("tooltipShow",function(a){y&&J(a,B.parentNode)}),E.on("changeState",function(b){"undefined"!=typeof b.disabled&&(c.forEach(function(a,c){a.disabled=b.disabled[c]}),C.disabled=b.disabled),a.update()}),H=n.copy(),I=o.copy()}),a}var b=c.models.scatter(),d=c.models.axis(),e=c.models.axis(),f=c.models.legend(),g=c.models.legend(),h=c.models.distribution(),i=c.models.distribution(),j={top:30,right:20,bottom:50,left:75},k=null,l=null,m=c.utils.defaultColor(),n=d3.fisheye?d3.fisheye.scale(d3.scale.linear).distortion(0):b.xScale(),o=d3.fisheye?d3.fisheye.scale(d3.scale.linear).distortion(0):b.yScale(),p=!1,q=!1,r=!0,s=!0,t=!0,u=!1,v=!!d3.fisheye,w=0,x=!1,y=!0,z=function(a,b){return""+b+""},A=function(a,b,c){return""+c+""},B=function(a,b,c,d){return"

"+a+"

"+"

"+d+"

"},C={},D=null,E=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),F="No Data Available.",G=250;b.xScale(n).yScale(o),d.orient("bottom").tickPadding(10),e.orient(u?"right":"left").tickPadding(10),h.axis("x"),i.axis("y"),g.updateState(!1);var H,I,J=function(f,g){var h=f.pos[0]+(g.offsetLeft||0),i=f.pos[1]+(g.offsetTop||0),k=f.pos[0]+(g.offsetLeft||0),l=o.range()[0]+j.top+(g.offsetTop||0),m=n.range()[0]+j.left+(g.offsetLeft||0),p=f.pos[1]+(g.offsetTop||0),q=d.tickFormat()(b.x()(f.point,f.pointIndex)),r=e.tickFormat()(b.y()(f.point,f.pointIndex));null!=z&&c.tooltip.show([k,l],z(f.series.key,q,r,f,a),"n",1,g,"x-nvtooltip"),null!=A&&c.tooltip.show([m,p],A(f.series.key,q,r,f,a),"e",1,g,"y-nvtooltip"),null!=B&&c.tooltip.show([h,i],B(f.series.key,q,r,f.point.tooltip,f,a),f.value<0?"n":"s",null,g)},K=[{key:"Magnify",disabled:!0}];return b.dispatch.on("elementMouseout.tooltip",function(a){E.tooltipHide(a),d3.select(".nv-chart-"+b.id()+" .nv-series-"+a.seriesIndex+" .nv-distx-"+a.pointIndex).attr("y1",0),d3.select(".nv-chart-"+b.id()+" .nv-series-"+a.seriesIndex+" .nv-disty-"+a.pointIndex).attr("x2",i.size())}),E.on("tooltipHide",function(){y&&c.tooltip.cleanup()}),a.dispatch=E,a.scatter=b,a.legend=f,a.controls=g,a.xAxis=d,a.yAxis=e,a.distX=h,a.distY=i,d3.rebind(a,b,"id","interactive","pointActive","x","y","shape","size","xScale","yScale","zScale","xDomain","yDomain","xRange","yRange","sizeDomain","sizeRange","forceX","forceY","forceSize","clipVoronoi","clipRadius","useVoronoi"),a.options=c.utils.optionsFunc.bind(a),a.margin=function(b){return arguments.length?(j.top="undefined"!=typeof b.top?b.top:j.top,j.right="undefined"!=typeof b.right?b.right:j.right,j.bottom="undefined"!=typeof b.bottom?b.bottom:j.bottom,j.left="undefined"!=typeof b.left?b.left:j.left,a):j},a.width=function(b){return arguments.length?(k=b,a):k},a.height=function(b){return arguments.length?(l=b,a):l},a.color=function(b){return arguments.length?(m=c.utils.getColor(b),f.color(m),h.color(m),i.color(m),a):m},a.showDistX=function(b){return arguments.length?(p=b,a):p},a.showDistY=function(b){return arguments.length?(q=b,a):q},a.showControls=function(b){return arguments.length?(v=b,a):v},a.showLegend=function(b){return arguments.length?(r=b,a):r},a.showXAxis=function(b){return arguments.length?(s=b,a):s},a.showYAxis=function(b){return arguments.length?(t=b,a):t},a.rightAlignYAxis=function(b){return arguments.length?(u=b,e.orient(b?"right":"left"),a):u},a.fisheye=function(b){return arguments.length?(w=b,a):w},a.tooltips=function(b){return arguments.length?(y=b,a):y},a.tooltipContent=function(b){return arguments.length?(B=b,a):B},a.tooltipXContent=function(b){return arguments.length?(z=b,a):z},a.tooltipYContent=function(b){return arguments.length?(A=b,a):A},a.state=function(b){return arguments.length?(C=b,a):C},a.defaultState=function(b){return arguments.length?(D=b,a):D},a.noData=function(b){return arguments.length?(F=b,a):F},a.transitionDuration=function(b){return arguments.length?(G=b,a):G},a},c.models.sparkline=function(){"use strict";function a(c){return c.each(function(a){var c=h-g.left-g.right,j=i-g.top-g.bottom,p=d3.select(this);k.domain(b||d3.extent(a,m)).range(e||[0,c]),l.domain(d||d3.extent(a,n)).range(f||[j,0]);var q=p.selectAll("g.nv-wrap.nv-sparkline").data([a]),r=q.enter().append("g").attr("class","nvd3 nv-wrap nv-sparkline");r.append("g"),q.select("g"),q.attr("transform","translate("+g.left+","+g.top+")");var s=q.selectAll("path").data(function(a){return[a]});s.enter().append("path"),s.exit().remove(),s.style("stroke",function(a,b){return a.color||o(a,b)}).attr("d",d3.svg.line().x(function(a,b){return k(m(a,b))}).y(function(a,b){return l(n(a,b))}));var t=q.selectAll("circle.nv-point").data(function(a){function b(b){if(-1!=b){var c=a[b];return c.pointIndex=b,c}return null}var c=a.map(function(a,b){return n(a,b)}),d=b(c.lastIndexOf(l.domain()[1])),e=b(c.indexOf(l.domain()[0])),f=b(c.length-1);return[e,d,f].filter(function(a){return null!=a})});t.enter().append("circle"),t.exit().remove(),t.attr("cx",function(a){return k(m(a,a.pointIndex))}).attr("cy",function(a){return l(n(a,a.pointIndex))}).attr("r",2).attr("class",function(a){return m(a,a.pointIndex)==k.domain()[1]?"nv-point nv-currentValue":n(a,a.pointIndex)==l.domain()[0]?"nv-point nv-minValue":"nv-point nv-maxValue"})}),a}var b,d,e,f,g={top:2,right:0,bottom:2,left:0},h=400,i=32,j=!0,k=d3.scale.linear(),l=d3.scale.linear(),m=function(a){return a.x},n=function(a){return a.y},o=c.utils.getColor(["#000"]);return a.options=c.utils.optionsFunc.bind(a),a.margin=function(b){return arguments.length?(g.top="undefined"!=typeof b.top?b.top:g.top,g.right="undefined"!=typeof b.right?b.right:g.right,g.bottom="undefined"!=typeof b.bottom?b.bottom:g.bottom,g.left="undefined"!=typeof b.left?b.left:g.left,a):g},a.width=function(b){return arguments.length?(h=b,a):h},a.height=function(b){return arguments.length?(i=b,a):i},a.x=function(b){return arguments.length?(m=d3.functor(b),a):m},a.y=function(b){return arguments.length?(n=d3.functor(b),a):n},a.xScale=function(b){return arguments.length?(k=b,a):k},a.yScale=function(b){return arguments.length?(l=b,a):l},a.xDomain=function(c){return arguments.length?(b=c,a):b},a.yDomain=function(b){return arguments.length?(d=b,a):d},a.xRange=function(b){return arguments.length?(e=b,a):e},a.yRange=function(b){return arguments.length?(f=b,a):f},a.animate=function(b){return arguments.length?(j=b,a):j},a.color=function(b){return arguments.length?(o=c.utils.getColor(b),a):o},a},c.models.sparklinePlus=function(){"use strict";function a(c){return c.each(function(m){function q(){if(!j){var a=A.selectAll(".nv-hoverValue").data(i),c=a.enter().append("g").attr("class","nv-hoverValue").style("stroke-opacity",0).style("fill-opacity",0);a.exit().transition().duration(250).style("stroke-opacity",0).style("fill-opacity",0).remove(),a.attr("transform",function(a){return"translate("+b(e.x()(m[a],a))+",0)"}).transition().duration(250).style("stroke-opacity",1).style("fill-opacity",1),i.length&&(c.append("line").attr("x1",0).attr("y1",-f.top).attr("x2",0).attr("y2",u),c.append("text").attr("class","nv-xValue").attr("x",-6).attr("y",-f.top).attr("text-anchor","end").attr("dy",".9em"),A.select(".nv-hoverValue .nv-xValue").text(k(e.x()(m[i[0]],i[0]))),c.append("text").attr("class","nv-yValue").attr("x",6).attr("y",-f.top).attr("text-anchor","start").attr("dy",".9em"),A.select(".nv-hoverValue .nv-yValue").text(l(e.y()(m[i[0]],i[0]))))}}function r(){function a(a,b){for(var c=Math.abs(e.x()(a[0],0)-b),d=0,f=0;fc;++c){for(b=0,d=0;bb;b++)a[b][c][1]/=d;else for(b=0;e>b;b++)a[b][c][1]=g}for(c=0;f>c;++c)h[c]=0;return h}}),a}var b,d,e={top:0,right:0,bottom:0,left:0},f=960,g=500,h=c.utils.defaultColor(),i=Math.floor(1e5*Math.random()),j=function(a){return a.x},k=function(a){return a.y},l="stack",m="zero",n="default",o="linear",p=!1,q=c.models.scatter(),r=d3.dispatch("tooltipShow","tooltipHide","areaClick","areaMouseover","areaMouseout");return q.size(2.2).sizeDomain([2.2,2.2]),q.dispatch.on("elementClick.area",function(a){r.areaClick(a)}),q.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+e.left,a.pos[1]+e.top],r.tooltipShow(a)}),q.dispatch.on("elementMouseout.tooltip",function(a){r.tooltipHide(a)}),a.dispatch=r,a.scatter=q,d3.rebind(a,q,"interactive","size","xScale","yScale","zScale","xDomain","yDomain","xRange","yRange","sizeDomain","forceX","forceY","forceSize","clipVoronoi","useVoronoi","clipRadius","highlightPoint","clearHighlights"),a.options=c.utils.optionsFunc.bind(a),a.x=function(b){return arguments.length?(j=d3.functor(b),a):j},a.y=function(b){return arguments.length?(k=d3.functor(b),a):k},a.margin=function(b){return arguments.length?(e.top="undefined"!=typeof b.top?b.top:e.top,e.right="undefined"!=typeof b.right?b.right:e.right,e.bottom="undefined"!=typeof b.bottom?b.bottom:e.bottom,e.left="undefined"!=typeof b.left?b.left:e.left,a):e},a.width=function(b){return arguments.length?(f=b,a):f},a.height=function(b){return arguments.length?(g=b,a):g},a.clipEdge=function(b){return arguments.length?(p=b,a):p},a.color=function(b){return arguments.length?(h=c.utils.getColor(b),a):h},a.offset=function(b){return arguments.length?(m=b,a):m},a.order=function(b){return arguments.length?(n=b,a):n},a.style=function(b){if(!arguments.length)return l;switch(l=b){case"stack":a.offset("zero"),a.order("default");break;case"stream":a.offset("wiggle"),a.order("inside-out");break;case"stream-center":a.offset("silhouette"),a.order("inside-out");break;case"expand":a.offset("expand"),a.order("default");break;case"stack_percent":a.offset(a.d3_stackedOffset_stackPercent),a.order("default")}return a},a.interpolate=function(b){return arguments.length?(o=b,a):o},a},c.models.stackedAreaChart=function(){"use strict";function a(v){return v.each(function(v){var G=d3.select(this),H=this,I=(l||parseInt(G.style("width"))||960)-k.left-k.right,J=(m||parseInt(G.style("height"))||400)-k.top-k.bottom;if(a.update=function(){G.transition().duration(E).call(a)},a.container=this,x.disabled=v.map(function(a){return!!a.disabled}),!y){var K;y={};for(K in x)y[K]=x[K]instanceof Array?x[K].slice(0):x[K]}if(!(v&&v.length&&v.filter(function(a){return a.values.length}).length)){var L=G.selectAll(".nv-noData").data([z]);return L.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),L.attr("x",k.left+I/2).attr("y",k.top+J/2).text(function(a){return a}),a}G.selectAll(".nv-noData").remove(),b=e.xScale(),d=e.yScale();var M=G.selectAll("g.nv-wrap.nv-stackedAreaChart").data([v]),N=M.enter().append("g").attr("class","nvd3 nv-wrap nv-stackedAreaChart").append("g"),O=M.select("g");if(N.append("rect").style("opacity",0),N.append("g").attr("class","nv-x nv-axis"),N.append("g").attr("class","nv-y nv-axis"),N.append("g").attr("class","nv-stackedWrap"),N.append("g").attr("class","nv-legendWrap"),N.append("g").attr("class","nv-controlsWrap"),N.append("g").attr("class","nv-interactive"),O.select("rect").attr("width",I).attr("height",J),p){var P=o?I-B:I;h.width(P),O.select(".nv-legendWrap").datum(v).call(h),k.top!=h.height()&&(k.top=h.height(),J=(m||parseInt(G.style("height"))||400)-k.top-k.bottom),O.select(".nv-legendWrap").attr("transform","translate("+(I-P)+","+-k.top+")")}if(o){var Q=[{key:D.stacked||"Stacked",metaKey:"Stacked",disabled:"stack"!=e.style(),style:"stack"},{key:D.stream||"Stream",metaKey:"Stream",disabled:"stream"!=e.style(),style:"stream"},{key:D.expanded||"Expanded",metaKey:"Expanded",disabled:"expand"!=e.style(),style:"expand"},{key:D.stack_percent||"Stack %",metaKey:"Stack_Percent",disabled:"stack_percent"!=e.style(),style:"stack_percent"}];B=260*(C.length/3),Q=Q.filter(function(a){return-1!==C.indexOf(a.metaKey)}),i.width(B).color(["#444","#444","#444"]),O.select(".nv-controlsWrap").datum(Q).call(i),k.top!=Math.max(i.height(),h.height())&&(k.top=Math.max(i.height(),h.height()),J=(m||parseInt(G.style("height"))||400)-k.top-k.bottom),O.select(".nv-controlsWrap").attr("transform","translate(0,"+-k.top+")")}M.attr("transform","translate("+k.left+","+k.top+")"),s&&O.select(".nv-y.nv-axis").attr("transform","translate("+I+",0)"),t&&(j.width(I).height(J).margin({left:k.left,top:k.top}).svgContainer(G).xScale(b),M.select(".nv-interactive").call(j)),e.width(I).height(J);var R=O.select(".nv-stackedWrap").datum(v);R.transition().call(e),q&&(f.scale(b).ticks(I/100).tickSize(-J,0),O.select(".nv-x.nv-axis").attr("transform","translate(0,"+J+")"),O.select(".nv-x.nv-axis").transition().duration(0).call(f)),r&&(g.scale(d).ticks("wiggle"==e.offset()?0:J/36).tickSize(-I,0).setTickFormat("expand"==e.style()||"stack_percent"==e.style()?d3.format("%"):w),O.select(".nv-y.nv-axis").transition().duration(0).call(g)),e.dispatch.on("areaClick.toggle",function(b){1===v.filter(function(a){return!a.disabled}).length?v.forEach(function(a){a.disabled=!1}):v.forEach(function(a,c){a.disabled=c!=b.seriesIndex}),x.disabled=v.map(function(a){return!!a.disabled}),A.stateChange(x),a.update()}),h.dispatch.on("stateChange",function(b){x.disabled=b.disabled,A.stateChange(x),a.update()}),i.dispatch.on("legendClick",function(b){b.disabled&&(Q=Q.map(function(a){return a.disabled=!0,a}),b.disabled=!1,e.style(b.style),x.style=e.style(),A.stateChange(x),a.update())}),j.dispatch.on("elementMousemove",function(b){e.clearHighlights();var d,h,i,l=[];if(v.filter(function(a,b){return a.seriesIndex=b,!a.disabled}).forEach(function(f,g){h=c.interactiveBisect(f.values,b.pointXValue,a.x()),e.highlightPoint(g,h,!0);var j=f.values[h];if("undefined"!=typeof j){"undefined"==typeof d&&(d=j),"undefined"==typeof i&&(i=a.xScale()(a.x()(j,h)));var k="expand"==e.style()?j.display.y:a.y()(j,h);l.push({key:f.key,value:k,color:n(f,f.seriesIndex),stackedValue:j.display})}}),l.reverse(),l.length>2){var m=a.yScale().invert(b.mouseY),o=null;l.forEach(function(a,b){return m>=a.stackedValue.y0&&m<=a.stackedValue.y0+a.stackedValue.y?(o=b,void 0):void 0}),null!=o&&(l[o].highlight=!0)}var p=f.tickFormat()(a.x()(d,h)),q="expand"==e.style()?function(a){return d3.format(".1%")(a)}:function(a){return g.tickFormat()(a)};j.tooltip.position({left:i+k.left,top:b.mouseY+k.top}).chartContainer(H.parentNode).enabled(u).valueFormatter(q).data({value:p,series:l})(),j.renderGuideLine(i)}),j.dispatch.on("elementMouseout",function(){A.tooltipHide(),e.clearHighlights()}),A.on("tooltipShow",function(a){u&&F(a,H.parentNode)}),A.on("changeState",function(b){"undefined"!=typeof b.disabled&&(v.forEach(function(a,c){a.disabled=b.disabled[c]}),x.disabled=b.disabled),"undefined"!=typeof b.style&&e.style(b.style),a.update()})}),a}var b,d,e=c.models.stackedArea(),f=c.models.axis(),g=c.models.axis(),h=c.models.legend(),i=c.models.legend(),j=c.interactiveGuideline(),k={top:30,right:25,bottom:50,left:60},l=null,m=null,n=c.utils.defaultColor(),o=!0,p=!0,q=!0,r=!0,s=!1,t=!1,u=!0,v=function(a,b,c){return"

"+a+"

"+"

"+c+" on "+b+"

"},w=d3.format(",.2f"),x={style:e.style()},y=null,z="No Data Available.",A=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),B=250,C=["Stacked","Stream","Expanded"],D={},E=250;f.orient("bottom").tickPadding(7),g.orient(s?"right":"left"),i.updateState(!1);var F=function(b,d){var h=b.pos[0]+(d.offsetLeft||0),i=b.pos[1]+(d.offsetTop||0),j=f.tickFormat()(e.x()(b.point,b.pointIndex)),k=g.tickFormat()(e.y()(b.point,b.pointIndex)),l=v(b.series.key,j,k,b,a);c.tooltip.show([h,i],l,b.value<0?"n":"s",null,d)};return e.dispatch.on("tooltipShow",function(a){a.pos=[a.pos[0]+k.left,a.pos[1]+k.top],A.tooltipShow(a)}),e.dispatch.on("tooltipHide",function(a){A.tooltipHide(a)}),A.on("tooltipHide",function(){u&&c.tooltip.cleanup()}),a.dispatch=A,a.stacked=e,a.legend=h,a.controls=i,a.xAxis=f,a.yAxis=g,a.interactiveLayer=j,d3.rebind(a,e,"x","y","size","xScale","yScale","xDomain","yDomain","xRange","yRange","sizeDomain","interactive","useVoronoi","offset","order","style","clipEdge","forceX","forceY","forceSize","interpolate"),a.options=c.utils.optionsFunc.bind(a),a.margin=function(b){return arguments.length?(k.top="undefined"!=typeof b.top?b.top:k.top,k.right="undefined"!=typeof b.right?b.right:k.right,k.bottom="undefined"!=typeof b.bottom?b.bottom:k.bottom,k.left="undefined"!=typeof b.left?b.left:k.left,a):k},a.width=function(b){return arguments.length?(l=b,a):l},a.height=function(b){return arguments.length?(m=b,a):m},a.color=function(b){return arguments.length?(n=c.utils.getColor(b),h.color(n),e.color(n),a):n},a.showControls=function(b){return arguments.length?(o=b,a):o},a.showLegend=function(b){return arguments.length?(p=b,a):p},a.showXAxis=function(b){return arguments.length?(q=b,a):q},a.showYAxis=function(b){return arguments.length?(r=b,a):r},a.rightAlignYAxis=function(b){return arguments.length?(s=b,g.orient(b?"right":"left"),a):s},a.useInteractiveGuideline=function(b){return arguments.length?(t=b,b===!0&&(a.interactive(!1),a.useVoronoi(!1)),a):t},a.tooltip=function(b){return arguments.length?(v=b,a):v},a.tooltips=function(b){return arguments.length?(u=b,a):u},a.tooltipContent=function(b){return arguments.length?(v=b,a):v},a.state=function(b){return arguments.length?(x=b,a):x},a.defaultState=function(b){return arguments.length?(y=b,a):y},a.noData=function(b){return arguments.length?(z=b,a):z},a.transitionDuration=function(b){return arguments.length?(E=b,a):E},a.controlsData=function(b){return arguments.length?(C=b,a):C},a.controlLabels=function(b){return arguments.length?"object"!=typeof b?D:(D=b,a):D},g.setTickFormat=g.tickFormat,g.tickFormat=function(a){return arguments.length?(w=a,g):w},a}}(); \ No newline at end of file diff --git a/src/models/historicalBarChart.js b/src/models/historicalBarChart.js index a5b4a09..07aab36 100644 --- a/src/models/historicalBarChart.js +++ b/src/models/historicalBarChart.js @@ -232,7 +232,7 @@ nv.models.historicalBarChart = function() { // Event Handling/Dispatching (in chart's scope) //------------------------------------------------------------ - 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) { @@ -254,7 +254,7 @@ nv.models.historicalBarChart = function() { data.forEach(function(d) { d.disabled = true; }); - d.disabled = false; + d.disabled = false; state.disabled = data.map(function(d) { return !!d.disabled }); dispatch.stateChange(state); @@ -276,7 +276,7 @@ nv.models.historicalBarChart = function() { state.disabled = e.disabled; } - selection.call(chart); + chart.update(); }); //============================================================ @@ -318,11 +318,11 @@ nv.models.historicalBarChart = function() { chart.xAxis = xAxis; chart.yAxis = yAxis; - d3.rebind(chart, bars, 'defined', 'isArea', 'x', 'y', 'size', 'xScale', 'yScale', + d3.rebind(chart, bars, 'defined', 'isArea', 'x', 'y', 'size', 'xScale', 'yScale', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id', 'interpolate','highlightPoint','clearHighlights', 'interactive'); chart.options = nv.utils.optionsFunc.bind(chart); - + chart.margin = function(_) { if (!arguments.length) return margin; margin.top = typeof _.top != 'undefined' ? _.top : margin.top; diff --git a/src/models/multiBarHorizontalChart.js b/src/models/multiBarHorizontalChart.js index 02aa6fa..2188862 100644 --- a/src/models/multiBarHorizontalChart.js +++ b/src/models/multiBarHorizontalChart.js @@ -252,7 +252,7 @@ nv.models.multiBarHorizontalChart = function() { // Event Handling/Dispatching (in chart's scope) //------------------------------------------------------------ - legend.dispatch.on('stateChange', function(newState) { + legend.dispatch.on('stateChange', function(newState) { state = newState; dispatch.stateChange(state); chart.update(); @@ -301,7 +301,7 @@ nv.models.multiBarHorizontalChart = function() { state.stacked = e.stacked; } - selection.call(chart); + chart.update(); }); //============================================================ @@ -345,7 +345,7 @@ nv.models.multiBarHorizontalChart = function() { d3.rebind(chart, multibar, 'x', 'y', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'clipEdge', 'id', 'delay', 'showValues', 'valueFormat', 'stacked', 'barColor'); chart.options = nv.utils.optionsFunc.bind(chart); - + chart.margin = function(_) { if (!arguments.length) return margin; margin.top = typeof _.top != 'undefined' ? _.top : margin.top;