diff --git a/Makefile b/Makefile index f8d0489..31319c9 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ JS_FILES = \ src/models/lineChart.js \ src/models/linePlusBarChart.js \ src/models/lineWithFocusChart.js \ + src/models/linePlusBarWithFocusChart.js \ src/models/multiBar.js \ src/models/multiBarChart.js \ src/models/multiBarHorizontal.js \ diff --git a/examples/crossfilterWithTables.html b/examples/crossfilterWithTables.html index 013767c..95abd99 100644 --- a/examples/crossfilterWithTables.html +++ b/examples/crossfilterWithTables.html @@ -106,7 +106,7 @@ nv.addGraph(function() { key: 'stream3' } ]); - +nv.log(data); d3.select('#chart svg') .datum(data) .transition().duration(500) diff --git a/examples/linePlusBarWithFocusChart.html b/examples/linePlusBarWithFocusChart.html index b479817..cf78269 100644 --- a/examples/linePlusBarWithFocusChart.html +++ b/examples/linePlusBarWithFocusChart.html @@ -88,6 +88,7 @@ nv.addGraph(function() { .color(d3.scale.category10().range()); chart.xAxis.tickFormat(function(d) { + var dx = testdata[0].values[d] && testdata[0].values[d].x || 0; if (dx > 0) { return d3.time.format('%x')(new Date(dx)) @@ -115,7 +116,7 @@ nv.addGraph(function() { chart.bars.forceY([0]); chart.bars2.forceY([0]); //chart.lines.forceY([0]); - + nv.log(testdata); d3.select('#chart1 svg') .datum(testdata) .transition().duration(500).call(chart); diff --git a/examples/multiBarChart.html b/examples/multiBarChart.html index 2372b16..0289118 100644 --- a/examples/multiBarChart.html +++ b/examples/multiBarChart.html @@ -69,6 +69,9 @@ nv.addGraph(function() { chart = nv.models.multiBarChart() .barColor(d3.scale.category20().range()); + chart.multibar + .hideable(true); + chart.xAxis .showMaxMin(true) .tickFormat(d3.format(',f')); diff --git a/nv.d3.js b/nv.d3.js index 1905428..a83aaa8 100644 --- a/nv.d3.js +++ b/nv.d3.js @@ -1786,6 +1786,7 @@ nv.models.cumulativeLineChart = function() { , y //can be accessed via chart.yScale() , id = lines.id() , state = { index: 0, rescaleY: rescaleY } + , defaultState = null , noData = 'No Data Available.' , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') ; @@ -1866,6 +1867,17 @@ nv.models.cumulativeLineChart = function() { //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) @@ -2325,6 +2337,12 @@ nv.models.cumulativeLineChart = function() { return chart; }; + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; @@ -3956,6 +3974,7 @@ nv.models.lineChart = function() { , x , y , state = {} + , defaultState = null , noData = 'No Data Available.' , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') ; @@ -4018,6 +4037,16 @@ nv.models.lineChart = function() { //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]; + } + } //------------------------------------------------------------ // Display noData message if there's nothing to show. @@ -4280,6 +4309,12 @@ nv.models.lineChart = function() { return chart; }; + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; @@ -4321,6 +4356,8 @@ nv.models.linePlusBarChart = function() { , x , y1 , y2 + , state = {} + , defaultState = null , noData = "No Data Available." , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') ; @@ -4351,17 +4388,16 @@ nv.models.linePlusBarChart = function() { // Private Variables //------------------------------------------------------------ - var state = {}, - 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 = (e.series.bar ? y1Axis : y2Axis).tickFormat()(lines.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); + 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 = (e.series.bar ? y1Axis : y2Axis).tickFormat()(lines.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); - } - ; + nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); + } + ; //------------------------------------------------------------ @@ -4383,6 +4419,16 @@ nv.models.linePlusBarChart = function() { //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]; + } + } //------------------------------------------------------------ // Display No Data message if there's nothing to show. @@ -4493,7 +4539,7 @@ nv.models.linePlusBarChart = function() { .datum(dataBars.length ? dataBars : [{values:[]}]) var linesWrap = g.select('.nv-linesWrap') - .datum(!dataLines[0].disabled ? dataLines : [{values:[]}] ); + .datum(dataLines[0] && !dataLines[0].disabled ? dataLines : [{values:[]}] ); //.datum(!dataLines[0].disabled ? dataLines : [{values:dataLines[0].values.map(function(d) { return [d[0], null] }) }] ); d3.transition(barsWrap).call(bars); @@ -4705,6 +4751,12 @@ nv.models.linePlusBarChart = function() { return chart; }; + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; @@ -4885,7 +4937,623 @@ nv.models.lineWithFocusChart = function() { } g.select('.nv-legendWrap') - .attr('transform', 'translate(0,' + (-margin.top) +')') + .attr('transform', 'translate(0,' + (-margin.top) +')') + } + + //------------------------------------------------------------ + + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + + //------------------------------------------------------------ + // Main Chart Component(s) + + lines + .width(availableWidth) + .height(availableHeight1) + .color( + data + .map(function(d,i) { + return d.color || color(d, i); + }) + .filter(function(d,i) { + return !data[i].disabled; + }) + ); + + lines2 + .defined(lines.defined()) + .width(availableWidth) + .height(availableHeight2) + .color( + data + .map(function(d,i) { + return d.color || color(d, i); + }) + .filter(function(d,i) { + return !data[i].disabled; + }) + ); + + g.select('.nv-context') + .attr('transform', 'translate(0,' + ( availableHeight1 + margin.bottom + margin2.top) + ')') + + var contextLinesWrap = g.select('.nv-context .nv-linesWrap') + .datum(data.filter(function(d) { return !d.disabled })) + + d3.transition(contextLinesWrap).call(lines2); + + //------------------------------------------------------------ + + + /* + var focusLinesWrap = g.select('.nv-focus .nv-linesWrap') + .datum(data.filter(function(d) { return !d.disabled })) + + d3.transition(focusLinesWrap).call(lines); + */ + + + //------------------------------------------------------------ + // Setup Main (Focus) Axes + + xAxis + .scale(x) + .ticks( availableWidth / 100 ) + .tickSize(-availableHeight1, 0); + + yAxis + .scale(y) + .ticks( availableHeight1 / 36 ) + .tickSize( -availableWidth, 0); + + g.select('.nv-focus .nv-x.nv-axis') + .attr('transform', 'translate(0,' + availableHeight1 + ')'); + + //------------------------------------------------------------ + + + //------------------------------------------------------------ + // Setup Brush + + brush + .x(x2) + .on('brush', onBrush); + + if (brushExtent) brush.extent(brushExtent); + + var brushBG = g.select('.nv-brushBackground').selectAll('g') + .data([brushExtent || brush.extent()]) + + var brushBGenter = brushBG.enter() + .append('g'); + + brushBGenter.append('rect') + .attr('class', 'left') + .attr('x', 0) + .attr('y', 0) + .attr('height', availableHeight2); + + brushBGenter.append('rect') + .attr('class', 'right') + .attr('x', 0) + .attr('y', 0) + .attr('height', availableHeight2); + + gBrush = g.select('.nv-x.nv-brush') + .call(brush); + gBrush.selectAll('rect') + //.attr('y', -5) + .attr('height', availableHeight2); + gBrush.selectAll('.resize').append('path').attr('d', resizePath); + + onBrush(); + + //------------------------------------------------------------ + + + //------------------------------------------------------------ + // Setup Secondary (Context) Axes + + x2Axis + .scale(x2) + .ticks( availableWidth / 100 ) + .tickSize(-availableHeight2, 0); + + g.select('.nv-context .nv-x.nv-axis') + .attr('transform', 'translate(0,' + y2.range()[0] + ')'); + d3.transition(g.select('.nv-context .nv-x.nv-axis')) + .call(x2Axis); + + + y2Axis + .scale(y2) + .ticks( availableHeight2 / 36 ) + .tickSize( -availableWidth, 0); + + d3.transition(g.select('.nv-context .nv-y.nv-axis')) + .call(y2Axis); + + g.select('.nv-context .nv-x.nv-axis') + .attr('transform', 'translate(0,' + y2.range()[0] + ')'); + + //------------------------------------------------------------ + + + //============================================================ + // Event Handling/Dispatching (in chart's scope) + //------------------------------------------------------------ + + legend.dispatch.on('legendClick', function(d,i) { + d.disabled = !d.disabled; + + if (!data.filter(function(d) { return !d.disabled }).length) { + data.map(function(d) { + d.disabled = false; + wrap.selectAll('.nv-series').classed('disabled', false); + return d; + }); + } + + selection.transition().call(chart); + }); + + dispatch.on('tooltipShow', function(e) { + if (tooltips) showTooltip(e, that.parentNode); + }); + + //============================================================ + + + //============================================================ + // Functions + //------------------------------------------------------------ + + // Taken from crossfilter (http://square.github.com/crossfilter/) + function resizePath(d) { + var e = +(d == 'e'), + x = e ? 1 : -1, + y = availableHeight2 / 3; + return 'M' + (.5 * x) + ',' + y + + 'A6,6 0 0 ' + e + ' ' + (6.5 * x) + ',' + (y + 6) + + 'V' + (2 * y - 6) + + 'A6,6 0 0 ' + e + ' ' + (.5 * x) + ',' + (2 * y) + + 'Z' + + 'M' + (2.5 * x) + ',' + (y + 8) + + 'V' + (2 * y - 8) + + 'M' + (4.5 * x) + ',' + (y + 8) + + 'V' + (2 * y - 8); + } + + + function updateBrushBG() { + if (!brush.empty()) brush.extent(brushExtent); + brushBG + .data([brush.empty() ? x2.domain() : brushExtent]) + .each(function(d,i) { + var leftWidth = x2(d[0]) - x.range()[0], + rightWidth = x.range()[1] - x2(d[1]); + d3.select(this).select('.left') + .attr('width', leftWidth < 0 ? 0 : leftWidth); + + d3.select(this).select('.right') + .attr('x', x2(d[1])) + .attr('width', rightWidth < 0 ? 0 : rightWidth); + }); + } + + + function onBrush() { + brushExtent = brush.empty() ? null : brush.extent(); + extent = brush.empty() ? x2.domain() : brush.extent(); + + + dispatch.brush({extent: extent, brush: brush}); + + + updateBrushBG(); + + // Update Main (Focus) + var focusLinesWrap = g.select('.nv-focus .nv-linesWrap') + .datum( + data + .filter(function(d) { return !d.disabled }) + .map(function(d,i) { + return { + key: d.key, + values: d.values.filter(function(d,i) { + return lines.x()(d,i) >= extent[0] && lines.x()(d,i) <= extent[1]; + }) + } + }) + ); + d3.transition(focusLinesWrap).call(lines); + + + // Update Main (Focus) Axes + d3.transition(g.select('.nv-focus .nv-x.nv-axis')) + .call(xAxis); + d3.transition(g.select('.nv-focus .nv-y.nv-axis')) + .call(yAxis); + } + + //============================================================ + + + }); + + return chart; + } + + + //============================================================ + // 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]; + dispatch.tooltipShow(e); + }); + + lines.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + + dispatch.on('tooltipHide', function() { + if (tooltips) nv.tooltip.cleanup(); + }); + + //============================================================ + + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + // expose chart's sub-components + chart.dispatch = dispatch; + chart.legend = legend; + chart.lines = lines; + chart.lines2 = lines2; + chart.xAxis = xAxis; + chart.yAxis = yAxis; + chart.x2Axis = x2Axis; + chart.y2Axis = y2Axis; + + d3.rebind(chart, lines, 'defined', 'isArea', 'size', 'xDomain', 'yDomain', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id'); + + chart.x = function(_) { + if (!arguments.length) return lines.x; + lines.x(_); + lines2.x(_); + return chart; + }; + + chart.y = function(_) { + if (!arguments.length) return lines.y; + lines.y(_); + lines2.y(_); + 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.margin2 = function(_) { + if (!arguments.length) return margin2; + margin2 = _; + 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.height2 = function(_) { + if (!arguments.length) return height2; + height2 = _; + return chart; + }; + + chart.color = function(_) { + if (!arguments.length) return color; + color =nv.utils.getColor(_); + legend.color(color); + return chart; + }; + + chart.showLegend = function(_) { + if (!arguments.length) return showLegend; + showLegend = _; + return chart; + }; + + chart.tooltips = function(_) { + if (!arguments.length) return tooltips; + tooltips = _; + return chart; + }; + + chart.tooltipContent = function(_) { + if (!arguments.length) return tooltip; + tooltip = _; + return chart; + }; + + chart.interpolate = function(_) { + if (!arguments.length) return lines.interpolate(); + lines.interpolate(_); + lines2.interpolate(_); + return chart; + }; + + chart.noData = function(_) { + if (!arguments.length) return noData; + noData = _; + return chart; + }; + + // Chart has multiple similar Axes, to prevent code duplication, probably need to link all axis functions manually like below + chart.xTickFormat = function(_) { + if (!arguments.length) return xAxis.tickFormat(); + xAxis.tickFormat(_); + x2Axis.tickFormat(_); + return chart; + }; + + chart.yTickFormat = function(_) { + if (!arguments.length) return yAxis.tickFormat(); + yAxis.tickFormat(_); + y2Axis.tickFormat(_); + return chart; + }; + + //============================================================ + + + return chart; +} + +nv.models.linePlusBarWithFocusChart = function() { + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var lines = nv.models.line() + , lines2 = nv.models.line() + , bars = nv.models.historicalBar() + , bars2 = nv.models.historicalBar() + , xAxis = nv.models.axis() + , x2Axis = nv.models.axis() + , y1Axis = nv.models.axis() + , y2Axis = nv.models.axis() + , y3Axis = nv.models.axis() + , y4Axis = nv.models.axis() + , legend = nv.models.legend() + , brush = d3.svg.brush() + ; + + var margin = {top: 30, right: 30, bottom: 30, left: 60} + , margin2 = {top: 0, right: 30, bottom: 20, left: 60} + , width = null + , height = null + , height2 = 100 + , getX = function(d) { return d.x } + , getY = function(d) { return d.y } + , color = nv.utils.defaultColor() + , showLegend = true + , extent + , brushExtent = null + , tooltips = true + , tooltip = function(key, x, y, e, graph) { + return '

' + key + '

' + + '

' + y + ' at ' + x + '

'; + } + , x + , x2 + , y1 + , y2 + , y3 + , y4 + , noData = "No Data Available." + , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'brush') + ; + + lines + .clipEdge(true) + ; + lines2 + .interactive(false) + ; + xAxis + .orient('bottom') + .tickPadding(5) + ; + y1Axis + .orient('left') + ; + y2Axis + .orient('right') + ; + x2Axis + .orient('bottom') + .tickPadding(5) + ; + y3Axis + .orient('left') + ; + y4Axis + .orient('right') + ; + + //============================================================ + + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var showTooltip = function(e, offsetElement) { + if (extent) { + e.pointIndex += Math.ceil(extent[0]); + } + 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 = (e.series.bar ? y1Axis : y2Axis).tickFormat()(lines.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 container = d3.select(this), + that = this; + + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right, + availableHeight1 = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom - height2, + availableHeight2 = height2 - margin2.top - margin2.bottom; + + chart.update = function() { chart(selection) }; + chart.container = this; + + + //------------------------------------------------------------ + // Display No Data message if there's nothing to show. + + if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { + 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', margin.top + availableHeight1 / 2) + .text(function(d) { return d }); + + return chart; + } else { + container.selectAll('.nv-noData').remove(); + } + + //------------------------------------------------------------ + + + //------------------------------------------------------------ + // Setup Scales + + var dataBars = data.filter(function(d) { return !d.disabled && d.bar }); + var dataLines = data.filter(function(d) { return !d.bar }); // removed the !d.disabled clause here to fix Issue #240 + + x = bars.xScale(); + x2 = x2Axis.scale(); + y1 = bars.yScale(); + y2 = lines.yScale(); + y3 = bars2.yScale(); + y4 = lines2.yScale(); + + var series1 = data + .filter(function(d) { return !d.disabled && d.bar }) + .map(function(d) { + return d.values.map(function(d,i) { + return { x: getX(d,i), y: getY(d,i) } + }) + }); + + var series2 = data + .filter(function(d) { return !d.disabled && !d.bar }) + .map(function(d) { + return d.values.map(function(d,i) { + return { x: getX(d,i), y: getY(d,i) } + }) + }); + + x .range([0, availableWidth]); + + x2 .domain(d3.extent(d3.merge(series1.concat(series2)), function(d) { return d.x } )) + .range([0, availableWidth]); + + + //------------------------------------------------------------ + + + //------------------------------------------------------------ + // Setup containers and skeleton of chart + + var wrap = container.selectAll('g.nv-wrap.nv-linePlusBar').data([data]); + var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-linePlusBar').append('g'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-legendWrap'); + + var focusEnter = gEnter.append('g').attr('class', 'nv-focus'); + focusEnter.append('g').attr('class', 'nv-x nv-axis'); + focusEnter.append('g').attr('class', 'nv-y1 nv-axis'); + focusEnter.append('g').attr('class', 'nv-y2 nv-axis'); + focusEnter.append('g').attr('class', 'nv-barsWrap'); + focusEnter.append('g').attr('class', 'nv-linesWrap'); + + var contextEnter = gEnter.append('g').attr('class', 'nv-context'); + contextEnter.append('g').attr('class', 'nv-x nv-axis'); + contextEnter.append('g').attr('class', 'nv-y1 nv-axis'); + contextEnter.append('g').attr('class', 'nv-y2 nv-axis'); + contextEnter.append('g').attr('class', 'nv-barsWrap'); + contextEnter.append('g').attr('class', 'nv-linesWrap'); + contextEnter.append('g').attr('class', 'nv-brushBackground'); + contextEnter.append('g').attr('class', 'nv-x nv-brush'); + + + //------------------------------------------------------------ + + + //------------------------------------------------------------ + // Legend + + if (showLegend) { + legend.width( availableWidth / 2 ); + + g.select('.nv-legendWrap') + .datum(data.map(function(series) { + series.originalKey = series.originalKey === undefined ? series.key : series.originalKey; + series.key = series.originalKey + (series.bar ? ' (left axis)' : ' (right axis)'); + return series; + })) + .call(legend); + + if ( margin.top != legend.height()) { + margin.top = legend.height(); + availableHeight1 = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom - height2; + } + + g.select('.nv-legendWrap') + .attr('transform', 'translate(' + ( availableWidth / 2 ) + ',' + (-margin.top) +')'); } //------------------------------------------------------------ @@ -4895,71 +5563,36 @@ nv.models.lineWithFocusChart = function() { //------------------------------------------------------------ - // Main Chart Component(s) + // Context Components - lines + bars2 .width(availableWidth) - .height(availableHeight1) - .color( - data - .map(function(d,i) { - return d.color || color(d, i); - }) - .filter(function(d,i) { - return !data[i].disabled; - }) - ); + .height(availableHeight2) + .color(data.map(function(d,i) { + return d.color || color(d, i); + }).filter(function(d,i) { return !data[i].disabled && data[i].bar })); lines2 - .defined(lines.defined()) .width(availableWidth) .height(availableHeight2) - .color( - data - .map(function(d,i) { - return d.color || color(d, i); - }) - .filter(function(d,i) { - return !data[i].disabled; - }) - ); + .color(data.map(function(d,i) { + return d.color || color(d, i); + }).filter(function(d,i) { return !data[i].disabled && !data[i].bar })); + + var bars2Wrap = g.select('.nv-context .nv-barsWrap') + .datum(dataBars.length ? dataBars : [{values:[]}]); + var lines2Wrap = g.select('.nv-context .nv-linesWrap') + .datum(!dataLines[0].disabled ? dataLines : [{values:[]}]); + g.select('.nv-context') .attr('transform', 'translate(0,' + ( availableHeight1 + margin.bottom + margin2.top) + ')') - var contextLinesWrap = g.select('.nv-context .nv-linesWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - d3.transition(contextLinesWrap).call(lines2); - - //------------------------------------------------------------ - - - /* - var focusLinesWrap = g.select('.nv-focus .nv-linesWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - d3.transition(focusLinesWrap).call(lines); - */ - + d3.transition(bars2Wrap).call(bars2); + d3.transition(lines2Wrap).call(lines2); //------------------------------------------------------------ - // Setup Main (Focus) Axes - - xAxis - .scale(x) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight1, 0); - - yAxis - .scale(y) - .ticks( availableHeight1 / 36 ) - .tickSize( -availableWidth, 0); - g.select('.nv-focus .nv-x.nv-axis') - .attr('transform', 'translate(0,' + availableHeight1 + ')'); - - //------------------------------------------------------------ //------------------------------------------------------------ @@ -4989,51 +5622,60 @@ nv.models.lineWithFocusChart = function() { .attr('y', 0) .attr('height', availableHeight2); - gBrush = g.select('.nv-x.nv-brush') + var gBrush = g.select('.nv-x.nv-brush') .call(brush); gBrush.selectAll('rect') //.attr('y', -5) .attr('height', availableHeight2); gBrush.selectAll('.resize').append('path').attr('d', resizePath); - onBrush(); - //------------------------------------------------------------ - //------------------------------------------------------------ // Setup Secondary (Context) Axes x2Axis - .scale(x2) .ticks( availableWidth / 100 ) .tickSize(-availableHeight2, 0); g.select('.nv-context .nv-x.nv-axis') - .attr('transform', 'translate(0,' + y2.range()[0] + ')'); + .attr('transform', 'translate(0,' + y3.range()[0] + ')'); d3.transition(g.select('.nv-context .nv-x.nv-axis')) .call(x2Axis); - y2Axis - .scale(y2) + y3Axis + .scale(y3) .ticks( availableHeight2 / 36 ) .tickSize( -availableWidth, 0); - d3.transition(g.select('.nv-context .nv-y.nv-axis')) - .call(y2Axis); + g.select('.nv-context .nv-y1.nv-axis') + .style('opacity', dataBars.length ? 1 : 0) + .attr('transform', 'translate(0,' + x2.range()[0] + ')'); + + d3.transition(g.select('.nv-context .nv-y1.nv-axis')) + .call(y3Axis); + - g.select('.nv-context .nv-x.nv-axis') - .attr('transform', 'translate(0,' + y2.range()[0] + ')'); + y4Axis + .scale(y4) + .ticks( availableHeight2 / 36 ) + .tickSize(dataBars.length ? 0 : -availableWidth, 0); // Show the y2 rules only if y1 has none - //------------------------------------------------------------ + g.select('.nv-context .nv-y2.nv-axis') + .style('opacity', dataLines.length ? 1 : 0) + .attr('transform', 'translate(' + x2.range()[1] + ',0)'); + d3.transition(g.select('.nv-context .nv-y2.nv-axis')) + .call(y4Axis); + + //------------------------------------------------------------ //============================================================ // 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) { @@ -5044,7 +5686,7 @@ nv.models.lineWithFocusChart = function() { }); } - selection.transition().call(chart); + selection.call(chart); }); dispatch.on('tooltipShow', function(e) { @@ -5080,8 +5722,8 @@ nv.models.lineWithFocusChart = function() { brushBG .data([brush.empty() ? x2.domain() : brushExtent]) .each(function(d,i) { - var leftWidth = x2(d[0]) - x.range()[0], - rightWidth = x.range()[1] - x2(d[1]); + var leftWidth = x2(d[0]) - x2.range()[0], + rightWidth = x2.range()[1] - x2(d[1]); d3.select(this).select('.left') .attr('width', leftWidth < 0 ? 0 : leftWidth); @@ -5099,14 +5741,43 @@ nv.models.lineWithFocusChart = function() { dispatch.brush({extent: extent, brush: brush}); - updateBrushBG(); - // Update Main (Focus) + + //------------------------------------------------------------ + // Prepare Main (Focus) Bars and Lines + + bars + .width(availableWidth) + .height(availableHeight1) + .color(data.map(function(d,i) { + return d.color || color(d, i); + }).filter(function(d,i) { return !data[i].disabled && data[i].bar })); + + + lines + .width(availableWidth) + .height(availableHeight1) + .color(data.map(function(d,i) { + return d.color || color(d, i); + }).filter(function(d,i) { return !data[i].disabled && !data[i].bar })); + + var focusBarsWrap = g.select('.nv-focus .nv-barsWrap') + .datum(!dataBars.length ? [{values:[]}] : + dataBars + .map(function(d,i) { + return { + key: d.key, + values: d.values.filter(function(d,i) { + return bars.x()(d,i) >= extent[0] && bars.x()(d,i) <= extent[1]; + }) + } + }) + ); + var focusLinesWrap = g.select('.nv-focus .nv-linesWrap') - .datum( - data - .filter(function(d) { return !d.disabled }) + .datum(dataLines[0].disabled ? [{values:[]}] : + dataLines .map(function(d,i) { return { key: d.key, @@ -5115,19 +5786,75 @@ nv.models.lineWithFocusChart = function() { }) } }) - ); + ); + + //------------------------------------------------------------ + + + //------------------------------------------------------------ + // Update Main (Focus) X Axis + + if (dataBars.length) { + x = bars.xScale(); + } else { + x = lines.xScale(); + } + + xAxis + .scale(x) + .ticks( availableWidth / 100 ) + .tickSize(-availableHeight1, 0); + + xAxis.domain([Math.ceil(extent[0]), Math.floor(extent[1])]); + + d3.transition(g.select('.nv-x.nv-axis')) + .call(xAxis); + //------------------------------------------------------------ + + + //------------------------------------------------------------ + // Update Main (Focus) Bars and Lines + + d3.transition(focusBarsWrap).call(bars); d3.transition(focusLinesWrap).call(lines); + + //------------------------------------------------------------ + + + //------------------------------------------------------------ + // Setup and Update Main (Focus) Y Axes + + g.select('.nv-focus .nv-x.nv-axis') + .attr('transform', 'translate(0,' + y1.range()[0] + ')'); - // Update Main (Focus) Axes - d3.transition(g.select('.nv-focus .nv-x.nv-axis')) - .call(xAxis); - d3.transition(g.select('.nv-focus .nv-y.nv-axis')) - .call(yAxis); + y1Axis + .scale(y1) + .ticks( availableHeight1 / 36 ) + .tickSize(-availableWidth, 0); + + g.select('.nv-focus .nv-y1.nv-axis') + .style('opacity', dataBars.length ? 1 : 0); + + + y2Axis + .scale(y2) + .ticks( availableHeight1 / 36 ) + .tickSize(dataBars.length ? 0 : -availableWidth, 0); // Show the y2 rules only if y1 has none + + g.select('.nv-focus .nv-y2.nv-axis') + .style('opacity', dataLines.length ? 1 : 0) + .attr('transform', 'translate(' + x.range()[1] + ',0)'); + + d3.transition(g.select('.nv-focus .nv-y1.nv-axis')) + .call(y1Axis); + d3.transition(g.select('.nv-focus .nv-y2.nv-axis')) + .call(y2Axis); } //============================================================ + onBrush(); }); @@ -5148,6 +5875,15 @@ nv.models.lineWithFocusChart = function() { dispatch.tooltipHide(e); }); + bars.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + bars.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + dispatch.on('tooltipHide', function() { if (tooltips) nv.tooltip.cleanup(); }); @@ -5164,24 +5900,32 @@ nv.models.lineWithFocusChart = function() { chart.legend = legend; chart.lines = lines; chart.lines2 = lines2; + chart.bars = bars; + chart.bars2 = bars2; chart.xAxis = xAxis; - chart.yAxis = yAxis; chart.x2Axis = x2Axis; + chart.y1Axis = y1Axis; chart.y2Axis = y2Axis; + chart.y3Axis = y3Axis; + chart.y4Axis = y4Axis; - d3.rebind(chart, lines, 'defined', 'isArea', 'size', 'xDomain', 'yDomain', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id'); + d3.rebind(chart, lines, 'defined', 'size', 'clipVoronoi', 'interpolate'); + //TODO: consider rebinding x, y and some other stuff, and simply do soemthign lile bars.x(lines.x()), etc. + //d3.rebind(chart, lines, 'x', 'y', 'size', 'xDomain', 'yDomain', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id'); chart.x = function(_) { - if (!arguments.length) return lines.x; + if (!arguments.length) return getX; + getX = _; lines.x(_); - lines2.x(_); + bars.x(_); return chart; }; chart.y = function(_) { - if (!arguments.length) return lines.y; + if (!arguments.length) return getY; + getY = _; lines.y(_); - lines2.y(_); + bars.y(_); return chart; }; @@ -5194,12 +5938,6 @@ nv.models.lineWithFocusChart = function() { return chart; }; - chart.margin2 = function(_) { - if (!arguments.length) return margin2; - margin2 = _; - return chart; - }; - chart.width = function(_) { if (!arguments.length) return width; width = _; @@ -5212,15 +5950,9 @@ nv.models.lineWithFocusChart = function() { return chart; }; - chart.height2 = function(_) { - if (!arguments.length) return height2; - height2 = _; - return chart; - }; - chart.color = function(_) { if (!arguments.length) return color; - color =nv.utils.getColor(_); + color = nv.utils.getColor(_); legend.color(color); return chart; }; @@ -5243,33 +5975,18 @@ nv.models.lineWithFocusChart = function() { return chart; }; - chart.interpolate = function(_) { - if (!arguments.length) return lines.interpolate(); - lines.interpolate(_); - lines2.interpolate(_); - return chart; - }; - chart.noData = function(_) { if (!arguments.length) return noData; noData = _; return chart; }; - // Chart has multiple similar Axes, to prevent code duplication, probably need to link all axis functions manually like below - chart.xTickFormat = function(_) { - if (!arguments.length) return xAxis.tickFormat(); - xAxis.tickFormat(_); - x2Axis.tickFormat(_); + chart.brushExtent = function(_) { + if (!arguments.length) return brushExtent; + brushExtent = _; return chart; }; - chart.yTickFormat = function(_) { - if (!arguments.length) return yAxis.tickFormat(); - yAxis.tickFormat(_); - y2Axis.tickFormat(_); - return chart; - }; //============================================================ @@ -5295,6 +6012,7 @@ nv.models.multiBar = function() { , clipEdge = true , stacked = false , color = nv.utils.defaultColor() + , hideable = false , barColor = null // adding the ability to set the color for each rather than the whole group , disabled // used in conjunction with barColor to communicate from multiBarHorizontalChart what series are disabled , delay = 1200 @@ -5322,12 +6040,22 @@ nv.models.multiBar = function() { availableHeight = height - margin.top - margin.bottom, container = d3.select(this); + if(hideable && data.length) hideable = [{ + values: data[0].values.map(function(d) { + return { + x: d.x, + y: 0, + series: d.series, + size: 0.01 + };} + )}]; + if (stacked) data = d3.layout.stack() .offset('zero') .values(function(d){ return d.values }) .y(getY) - (data); + (!data.length && hideable ? hideable : data); //add series index to each data point for reference @@ -5448,7 +6176,7 @@ nv.models.multiBar = function() { var bars = groups.selectAll('rect.nv-bar') - .data(function(d) { return d.values }); + .data(function(d) { return (hideable && !data.length) ? hideable.values : d.values }); bars.exit().remove(); @@ -5681,6 +6409,12 @@ nv.models.multiBar = function() { return chart; }; + chart.hideable = function(_) { + if (!arguments.length) return hideable; + hideable = _; + return chart; + }; + chart.delay = function(_) { if (!arguments.length) return delay; delay = _; @@ -5722,6 +6456,7 @@ nv.models.multiBarChart = function() { , x //can be accessed via chart.xScale() , y //can be accessed via chart.yScale() , state = { stacked: false } + , defaultState = null , noData = "No Data Available." , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , controlWidth = function() { return showControls ? 180 : 0 } @@ -5778,7 +6513,16 @@ nv.models.multiBarChart = function() { //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]; + } + } //------------------------------------------------------------ // Display noData message if there's nothing to show. @@ -6130,6 +6874,12 @@ nv.models.multiBarChart = function() { return chart; }; + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; @@ -6590,6 +7340,7 @@ nv.models.multiBarHorizontalChart = function() { , x //can be accessed via chart.xScale() , y //can be accessed via chart.yScale() , state = { stacked: stacked } + , defaultState = null , noData = 'No Data Available.' , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , controlWidth = function() { return showControls ? 180 : 0 } @@ -6646,6 +7397,16 @@ nv.models.multiBarHorizontalChart = function() { //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]; + } + } //------------------------------------------------------------ // Display No Data message if there's nothing to show. @@ -6969,6 +7730,12 @@ nv.models.multiBarHorizontalChart = function() { return chart; }; + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; @@ -8194,6 +8961,7 @@ nv.models.pieChart = function() { '

' + y + '

' } , state = {} + , defaultState = null , noData = "No Data Available." , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') ; @@ -8234,6 +9002,17 @@ nv.models.pieChart = function() { //set state.disabled state.disabled = data[0].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]; + } + } + //------------------------------------------------------------ // Display No Data message if there's nothing to show. @@ -8446,6 +9225,12 @@ nv.models.pieChart = function() { return chart; }; + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; @@ -9117,6 +9902,8 @@ nv.models.scatterChart = function() { , tooltipY = function(key, x, y) { return '' + y + '' } //, tooltip = function(key, x, y) { return '

' + key + '

' } , tooltip = null + , state = {} + , defaultState = null , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , noData = "No Data Available." ; @@ -9147,8 +9934,7 @@ nv.models.scatterChart = function() { // Private Variables //------------------------------------------------------------ - var state = {}, - x0, y0; + var x0, y0; var showTooltip = function(e, offsetElement) { //TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?) @@ -9193,6 +9979,16 @@ nv.models.scatterChart = function() { //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]; + } + } //------------------------------------------------------------ // Display noData message if there's nothing to show. @@ -9233,10 +10029,10 @@ nv.models.scatterChart = function() { var wrap = container.selectAll('g.nv-wrap.nv-scatterChart').data([data]); var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-scatterChart nv-chart-' + scatter.id()); var gEnter = wrapEnter.append('g'); - var g = wrap.select('g') + var g = wrap.select('g'); // background for pointer events - gEnter.append('rect').attr('class', 'nvd3 nv-background') + gEnter.append('rect').attr('class', 'nvd3 nv-background'); gEnter.append('g').attr('class', 'nv-x nv-axis'); gEnter.append('g').attr('class', 'nv-y nv-axis'); @@ -9649,6 +10445,12 @@ nv.models.scatterChart = function() { return chart; }; + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; @@ -9694,6 +10496,8 @@ nv.models.scatterPlusLineChart = function() { , tooltip = function(key, x, y, date) { return '

' + key + '

' + '

' + date + '

' } //, tooltip = null + , state = {} + , defaultState = null , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , noData = "No Data Available." ; @@ -9724,8 +10528,7 @@ nv.models.scatterPlusLineChart = function() { // Private Variables //------------------------------------------------------------ - var state = {}, - x0, y0; + var x0, y0; var showTooltip = function(e, offsetElement) { //TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?) @@ -9770,6 +10573,16 @@ nv.models.scatterPlusLineChart = function() { //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]; + } + } //------------------------------------------------------------ // Display noData message if there's nothing to show. @@ -10229,6 +11042,12 @@ nv.models.scatterPlusLineChart = function() { return chart; }; + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; @@ -11075,6 +11894,7 @@ nv.models.stackedAreaChart = function() { , y //can be accessed via chart.yScale() , yAxisTickFormat = d3.format(',.2f') , state = { style: stacked.style() } + , defaultState = null , noData = 'No Data Available.' , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , controlWidth = 250 @@ -11130,6 +11950,16 @@ nv.models.stackedAreaChart = function() { //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]; + } + } //------------------------------------------------------------ // Display No Data message if there's nothing to show. @@ -11489,6 +12319,12 @@ nv.models.stackedAreaChart = function() { return chart; }; + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; @@ -11496,6 +12332,7 @@ nv.models.stackedAreaChart = function() { }; yAxis.setTickFormat = yAxis.tickFormat; + yAxis.tickFormat = function(_) { if (!arguments.length) return yAxisTickFormat; yAxisTickFormat = _; diff --git a/nv.d3.min.js b/nv.d3.min.js index b894364..e69de29 100644 --- a/nv.d3.min.js +++ b/nv.d3.min.js @@ -1,5 +0,0 @@ -(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(o=document.body.scrollWidth?h:h-16,c=window.innerHeight>=document.body.scrollHeight?c:c-16;var g=function(e){var t=m;do isNaN(e.offsetTop)||(t+=e.offsetTop);while(e=e.offsetParent);return t},y=function(e){var t=v;do isNaN(e.offsetLeft)||(t+=e.offsetLeft);while(e=e.offsetParent);return t};switch(r){case"e":v=t[0]-l-i,m=t[1]-f/2;var b=y(u),w=g(u);bd?t[0]+i:d-b+v),wp+h&&(m=p+h-w+m-f);break;case"w":v=t[0]+i,m=t[1]-f/2,b+l>c&&(v=t[0]-l-i),wp+h&&(m=p-f-5);break;case"n":v=t[0]-l/2-5,m=t[1]+i;var b=y(u),w=g(u);bc&&(v=v-l/2+5),w+f>p+h&&(m=p+h-w+m-f);break;case"s":v=t[0]-l/2,m=t[1]-f-i;var b=y(u),w=g(u);bc&&(v=v-l/2+5),p>w&&(m=p)}return u.style.left=v+"px",u.style.top=m+"px",u.style.opacity=1,u.style.position="absolute",u.style.pointerEvents="none",u},t.cleanup=function(){var e=document.getElementsByClassName("nvtooltip"),t=[];while(e.length)t.push(e[0]),e[0].style.transitionDelay="0 !important",e[0].style.opacity=0,e[0].className="nvtooltip-pending-removal";setTimeout(function(){while(t.length){var e=t.pop();e.parentNode.removeChild(e)}},500)}}(),e.utils.windowSize=function(){var e={width:640,height:480};return document.body&&document.body.offsetWidth&&(e.width=document.body.offsetWidth,e.height=document.body.offsetHeight),document.compatMode=="CSS1Compat"&&document.documentElement&&document.documentElement.offsetWidth&&(e.width=document.documentElement.offsetWidth,e.height=document.documentElement.offsetHeight),window.innerWidth&&window.innerHeight&&(e.width=window.innerWidth,e.height=window.innerHeight),e},e.utils.windowResize=function(e){var t=window.onresize;window.onresize=function(n){typeof t=="function"&&t(n),e(n)}},e.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.models.axis=function(){function d(r){return r.each(function(r){var d=d3.select(this),v=d.selectAll("g.nv-wrap.nv-axis").data([r]),m=v.enter().append("g").attr("class","nvd3 nv-wrap nv-axis"),g=m.append("g"),y=v.select("g");h!==null?e.ticks(h):(e.orient()=="top"||e.orient()=="bottom")&&e.ticks(Math.abs(i.range()[1]-i.range()[0])/100),d3.transition(y).call(e),p=p||e.scale();var b=e.tickFormat();b==null&&(b=p.tickFormat());var w=y.selectAll("text.nv-axislabel").data([s||null]);w.exit().remove();switch(e.orient()){case"top":w.enter().append("text").attr("class","nv-axislabel");var E=i.range().length==2?i.range()[1]:i.range()[i.range().length-1]+(i.range()[1]-i.range()[0]);w.attr("text-anchor","middle").attr("y",0).attr("x",E/2);if(o){var S=v.selectAll("g.nv-axisMaxMin").data(i.domain());S.enter().append("g").attr("class","nv-axisMaxMin").append("text"),S.exit().remove(),S.attr("transform",function(e,t){return"translate("+i(e)+",0)"}).select("text").attr("dy","0em").attr("y",-e.tickPadding()).attr("text-anchor","middle").text(function(e,t){var n=b(e);return(""+n).match("NaN")?"":n}),d3.transition(S).attr("transform",function(e,t){return"translate("+i.range()[t]+",0)"})}break;case"bottom":var x=36,T=30,N=y.selectAll("g").select("text");if(a%360){N.each(function(e,t){var n=this.getBBox().width;n>T&&(T=n)});var C=Math.abs(Math.sin(a*Math.PI/180)),x=(C?C*T:T)+30;N.attr("transform",function(e,t,n){return"rotate("+a+" 0,0)"}).attr("text-anchor",a%360>0?"start":"end")}w.enter().append("text").attr("class","nv-axislabel");var E=i.range().length==2?i.range()[1]:i.range()[i.range().length-1]+(i.range()[1]-i.range()[0]);w.attr("text-anchor","middle").attr("y",x).attr("x",E/2);if(o){var S=v.selectAll("g.nv-axisMaxMin").data([i.domain()[0],i.domain()[i.domain().length-1]]);S.enter().append("g").attr("class","nv-axisMaxMin").append("text"),S.exit().remove(),S.attr("transform",function(e,t){return"translate("+(i(e)+(c?i.rangeBand()/2:0))+",0)"}).select("text").attr("dy",".71em").attr("y",e.tickPadding()).attr("transform",function(e,t,n){return"rotate("+a+" 0,0)"}).attr("text-anchor",a?a%360>0?"start":"end":"middle").text(function(e,t){var n=b(e);return(""+n).match("NaN")?"":n}),d3.transition(S).attr("transform",function(e,t){return"translate("+(i(e)+(c?i.rangeBand()/2:0))+",0)"})}l&&N.attr("transform",function(e,t){return"translate(0,"+(t%2==0?"0":"12")+")"});break;case"right":w.enter().append("text").attr("class","nv-axislabel"),w.attr("text-anchor",f?"middle":"begin").attr("transform",f?"rotate(90)":"").attr("y",f?-Math.max(t.right,n)+12:-10).attr("x",f?i.range()[0]/2:e.tickPadding());if(o){var S=v.selectAll("g.nv-axisMaxMin").data(i.domain());S.enter().append("g").attr("class","nv-axisMaxMin").append("text").style("opacity",0),S.exit().remove(),S.attr("transform",function(e,t){return"translate(0,"+i(e)+")"}).select("text").attr("dy",".32em").attr("y",0).attr("x",e.tickPadding()).attr("text-anchor","start").text(function(e,t){var n=b(e);return(""+n).match("NaN")?"":n}),d3.transition(S).attr("transform",function(e,t){return"translate(0,"+i.range()[t]+")"}).select("text").style("opacity",1)}break;case"left":w.enter().append("text").attr("class","nv-axislabel"),w.attr("text-anchor",f?"middle":"end").attr("transform",f?"rotate(-90)":"").attr("y",f?-Math.max(t.left,n)+12:-10).attr("x",f?-i.range()[0]/2:-e.tickPadding());if(o){var S=v.selectAll("g.nv-axisMaxMin").data(i.domain());S.enter().append("g").attr("class","nv-axisMaxMin").append("text").style("opacity",0),S.exit().remove(),S.attr("transform",function(e,t){return"translate(0,"+p(e)+")"}).select("text").attr("dy",".32em").attr("y",0).attr("x",-e.tickPadding()).attr("text-anchor","end").text(function(e,t){var n=b(e);return(""+n).match("NaN")?"":n}),d3.transition(S).attr("transform",function(e,t){return"translate(0,"+i.range()[t]+")"}).select("text").style("opacity",1)}}w.text(function(e){return e}),o&&(e.orient()==="left"||e.orient()==="right")&&(y.selectAll("g").each(function(e,t){d3.select(this).select("text").attr("opacity",1);if(i(e)i.range()[0]-10)(e>1e-10||e<-1e-10)&&d3.select(this).attr("opacity",0),d3.select(this).select("text").attr("opacity",0)}),i.domain()[0]==i.domain()[1]&&i.domain()[0]==0&&v.selectAll("g.nv-axisMaxMin").style("opacity",function(e,t){return t?0:1}));if(o&&(e.orient()==="top"||e.orient()==="bottom")){var k=[];v.selectAll("g.nv-axisMaxMin").each(function(e,t){try{t?k.push(i(e)-this.getBBox().width-4):k.push(i(e)+this.getBBox().width+4)}catch(n){t?k.push(i(e)-4):k.push(i(e)+4)}}),y.selectAll("g").each(function(e,t){if(i(e)k[1])e>1e-10||e<-1e-10?d3.select(this).remove():d3.select(this).select("text").remove()})}u&&y.selectAll("line.tick").filter(function(e){return!parseFloat(Math.round(e*1e5)/1e6)}).classed("zero",!0),p=i.copy()}),d}var e=d3.svg.axis(),t={top:0,right:0,bottom:0,left:0},n=75,r=60,i=d3.scale.linear(),s=null,o=!0,u=!0,a=0,f=!0,l=!1,c=!1,h=null;e.scale(i).orient("bottom").tickFormat(function(e){return e});var p;return d.axis=e,d3.rebind(d,e,"orient","tickValues","tickSubdivide","tickSize","tickPadding","tickFormat"),d3.rebind(d,i,"domain","range","rangeBand","rangeBands"),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.ticks=function(e){return arguments.length?(h=e,d):h},d.height=function(e){return arguments.length?(r=e,d):r},d.axisLabel=function(e){return arguments.length?(s=e,d):s},d.showMaxMin=function(e){return arguments.length?(o=e,d):o},d.highlightZero=function(e){return arguments.length?(u=e,d):u},d.scale=function(t){return arguments.length?(i=t,e.scale(i),c=typeof i.rangeBands=="function",d3.rebind(d,i,"domain","range","rangeBand","rangeBands"),d):i},d.rotateYLabel=function(e){return arguments.length?(f=e,d):f},d.rotateLabels=function(e){return arguments.length?(a=e,d):a},d.staggerLabels=function(e){return arguments.length?(l=e,d):l},d},e.models.historicalBar=function(){function g(e){return e.each(function(e){var g=n-t.left-t.right,b=r-t.top-t.bottom,w=d3.select(this);s.domain(d||d3.extent(e[0].values.map(u).concat(f))),c?s.range([g*.5/e[0].values.length,g*(e[0].values.length-.5)/e[0].values.length]):s.range([0,g]),o.domain(v||d3.extent(e[0].values.map(a).concat(l))).range([b,0]);if(s.domain()[0]===s.domain()[1]||o.domain()[0]===o.domain()[1])singlePoint=!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 E=w.selectAll("g.nv-wrap.nv-bar").data([e[0].values]),S=E.enter().append("g").attr("class","nvd3 nv-wrap nv-bar"),T=S.append("defs"),N=S.append("g"),C=E.select("g");N.append("g").attr("class","nv-bars"),E.attr("transform","translate("+t.left+","+t.top+")"),w.on("click",function(e,t){m.chartClick({data:e,index:t,pos:d3.event,id:i})}),T.append("clipPath").attr("id","nv-chart-clip-path-"+i).append("rect"),E.select("#nv-chart-clip-path-"+i+" rect").attr("width",g).attr("height",b),C.attr("clip-path",h?"url(#nv-chart-clip-path-"+i+")":"");var k=E.select(".nv-bars").selectAll(".nv-bar").data(function(e){return e});k.exit().remove();var L=k.enter().append("rect").attr("x",0).attr("y",function(e,t){return o(Math.max(0,a(e,t)))}).attr("height",function(e,t){return Math.abs(o(a(e,t))-o(0))}).on("mouseover",function(t,n){d3.select(this).classed("hover",!0),m.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),m.elementMouseout({point:t,series:e[0],pointIndex:n,seriesIndex:0,e:d3.event})}).on("click",function(e,t){m.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){m.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()});k.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}).attr("transform",function(t,n){return"translate("+(s(u(t,n))-g/e[0].values.length*.45)+",0)"}).attr("width",g/e[0].values.length*.9),d3.transition(k).attr("y",function(e,t){return a(e,t)<0?o(0):o(0)-o(a(e,t))<1?o(0)-1:o(a(e,t))}).attr("height",function(e,t){return Math.max(Math.abs(o(a(e,t))-o(0)),1)})}),g}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=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return g.dispatch=m,g.x=function(e){return arguments.length?(u=e,g):u},g.y=function(e){return arguments.length?(a=e,g):a},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.xScale=function(e){return arguments.length?(s=e,g):s},g.yScale=function(e){return arguments.length?(o=e,g):o},g.xDomain=function(e){return arguments.length?(d=e,g):d},g.yDomain=function(e){return arguments.length?(v=e,g):v},g.forceX=function(e){return arguments.length?(f=e,g):f},g.forceY=function(e){return arguments.length?(l=e,g):l},g.padData=function(e){return arguments.length?(c=e,g):c},g.clipEdge=function(e){return arguments.length?(h=e,g):h},g.color=function(t){return arguments.length?(p=e.utils.getColor(t),g):p},g.id=function(e){return arguments.length?(i=e,g):i},g},e.models.bullet=function(){function p(e){return e.each(function(e,n){var l=a-t.left-t.right,p=f-t.top-t.bottom,d=d3.select(this),v=i.call(this,e,n).slice().sort(d3.descending),m=s.call(this,e,n).slice().sort(d3.descending),g=o.call(this,e,n).slice().sort(d3.descending),y=d3.scale.linear().domain(d3.extent(d3.merge([u,v]))).range(r?[l,0]:[0,l]),b=this.__chart__||d3.scale.linear().domain([0,Infinity]).range(y.range());this.__chart__=y;var w=d3.min(v),E=d3.max(v),S=v[1],x=d.selectAll("g.nv-wrap.nv-bullet").data([e]),T=x.enter().append("g").attr("class","nvd3 nv-wrap nv-bullet"),N=T.append("g"),C=x.select("g");N.append("rect").attr("class","nv-range nv-rangeMax"),N.append("rect").attr("class","nv-range nv-rangeAvg"),N.append("rect").attr("class","nv-range nv-rangeMin"),N.append("rect").attr("class","nv-measure"),N.append("path").attr("class","nv-markerTriangle"),x.attr("transform","translate("+t.left+","+t.top+")");var k=function(e){return Math.abs(b(e)-b(0))},L=function(e){return Math.abs(y(e)-y(0))},A=function(e){return e<0?b(e):b(0)},O=function(e){return e<0?y(e):y(0)};C.select("rect.nv-rangeMax").attr("height",p).attr("width",L(E>0?E:w)).attr("x",O(E>0?E:w)).datum(E>0?E:w),C.select("rect.nv-rangeAvg").attr("height",p).attr("width",L(S)).attr("x",O(S)).datum(S),C.select("rect.nv-rangeMin").attr("height",p).attr("width",L(E)).attr("x",O(E)).attr("width",L(E>0?w:E)).attr("x",O(E>0?w:E)).datum(E>0?w:E),C.select("rect.nv-measure").style("fill",c).attr("height",p/3).attr("y",p/3).attr("width",g<0?y(0)-y(g[0]):y(g[0])-y(0)).attr("x",O(g)).on("mouseover",function(){h.elementMouseover({value:g[0],label:"Current",pos:[y(g[0]),p/2]})}).on("mouseout",function(){h.elementMouseout({value:g[0],label:"Current"})});var M=p/6;m[0]?C.selectAll("path.nv-markerTriangle").attr("transform",function(e){return"translate("+y(m[0])+","+p/2+")"}).attr("d","M0,"+M+"L"+M+","+ -M+" "+ -M+","+ -M+"Z").on("mouseover",function(){h.elementMouseover({value:m[0],label:"Previous",pos:[y(m[0]),p/2]})}).on("mouseout",function(){h.elementMouseout({value:m[0],label:"Previous"})}):C.selectAll("path.nv-markerTriangle").remove(),x.selectAll(".nv-range").on("mouseover",function(e,t){var n=t?t==1?"Mean":"Minimum":"Maximum";h.elementMouseover({value:e,label:n,pos:[y(e),p/2]})}).on("mouseout",function(e,t){var n=t?t==1?"Mean":"Minimum":"Maximum";h.elementMouseout({value:e,label:n})})}),p}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=[0],a=380,f=30,l=null,c=e.utils.getColor(["#1f77b4"]),h=d3.dispatch("elementMouseover","elementMouseout");return p.dispatch=h,p.orient=function(e){return arguments.length?(n=e,r=n=="right"||n=="bottom",p):n},p.ranges=function(e){return arguments.length?(i=e,p):i},p.markers=function(e){return arguments.length?(s=e,p):s},p.measures=function(e){return arguments.length?(o=e,p):o},p.forceX=function(e){return arguments.length?(u=e,p):u},p.width=function(e){return arguments.length?(a=e,p):a},p.height=function(e){return arguments.length?(f=e,p):f},p.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,p):t},p.tickFormat=function(e){return arguments.length?(l=e,p):l},p.color=function(t){return arguments.length?(c=e.utils.getColor(t),p):c},p},e.models.bulletChart=function(){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=data[0].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.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(){function T(e){return e.each(function(d){function M(e,t){d3.select(T.container).style("cursor","ew-resize")}function _(e,t){S.x=d3.event.x,S.i=Math.round(E.invert(S.x)),W()}function D(e,t){d3.select(T.container).style("cursor","auto"),y.index=S.i,w.stateChange(y)}function W(){z.data([S]),T.update()}var C=d3.select(this).classed("nv-chart-"+g,!0),k=this,L=(a||parseInt(C.style("width"))||960)-o.left-o.right,A=(f||parseInt(C.style("height"))||400)-o.top-o.bottom;T.update=function(){T(e)},T.container=this,y.disabled=d.map(function(e){return!!e.disabled});var O=d3.behavior.drag().on("dragstart",M).on("drag",_).on("dragend",D);if(!d||!d.length||!d.filter(function(e){return e.values.length}).length){var P=C.selectAll(".nv-noData").data([b]);return P.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),P.attr("x",o.left+L/2).attr("y",o.top+A/2).text(function(e){return e}),T}C.selectAll(".nv-noData").remove(),v=t.xScale(),m=t.yScale();if(!p){var H=d.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])]}),B=[d3.min(H,function(e){return e[0]}),d3.max(H,function(e){return e[1]})];t.yDomain(B)}else t.yDomain(null);E.domain([0,d[0].values.length-1]).range([0,L]).clamp(!0);var d=N(S.i,d),j=C.selectAll("g.nv-wrap.nv-cumulativeLine").data([d]),F=j.enter().append("g").attr("class","nvd3 nv-wrap nv-cumulativeLine").append("g"),I=j.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-background"),F.append("g").attr("class","nv-linesWrap"),F.append("g").attr("class","nv-legendWrap"),F.append("g").attr("class","nv-controlsWrap"),l&&(i.width(L),I.select(".nv-legendWrap").datum(d).call(i),o.top!=i.height()&&(o.top=i.height(),A=(f||parseInt(C.style("height"))||400)-o.top-o.bottom),I.select(".nv-legendWrap").attr("transform","translate(0,"+ -o.top+")"));if(h){var q=[{key:"Re-scale y-axis",disabled:!p}];s.width(140).color(["#444","#444","#444"]),I.select(".nv-controlsWrap").datum(q).attr("transform","translate(0,"+ -o.top+")").call(s)}j.attr("transform","translate("+o.left+","+o.top+")");var R=d.filter(function(e){return e.tempDisabled});j.select(".tempDisabled").remove(),R.length&&j.append("text").attr("class","tempDisabled").attr("x",L/2).attr("y","-.71em").style("text-anchor","end").text(R.map(function(e){return e.key}).join(", ")+" values cannot be calculated for this time period."),F.select(".nv-background").append("rect"),I.select(".nv-background rect").attr("width",L).attr("height",A),t.y(function(e){return e.display.y}).width(L).height(A).color(d.map(function(e,t){return e.color||u(e,t)}).filter(function(e,t){return!d[t].disabled&&!d[t].tempDisabled}));var U=I.select(".nv-linesWrap").datum(d.filter(function(e){return!e.disabled&&!e.tempDisabled}));U.call(t);var z=U.selectAll(".nv-indexLine").data([S]);z.enter().append("rect").attr("class","nv-indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).call(O),z.attr("transform",function(e){return"translate("+E(e.i)+",0)"}).attr("height",A),n.scale(v).ticks(Math.min(d[0].values.length,L/70)).tickSize(-A,0),I.select(".nv-x.nv-axis").attr("transform","translate(0,"+m.range()[0]+")"),d3.transition(I.select(".nv-x.nv-axis")).call(n),r.scale(m).ticks(A/36).tickSize(-L,0),d3.transition(I.select(".nv-y.nv-axis")).call(r),I.select(".nv-background rect").on("click",function(){S.x=d3.mouse(this)[0],S.i=Math.round(E.invert(S.x)),y.index=S.i,w.stateChange(y),W()}),t.dispatch.on("elementClick",function(e){S.i=e.pointIndex,S.x=E(S.i),y.index=S.i,w.stateChange(y),W()}),s.dispatch.on("legendClick",function(t,n){t.disabled=!t.disabled,p=!t.disabled,y.rescaleY=p,w.stateChange(y),e.call(T)}),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,j.selectAll(".nv-series").classed("disabled",!1),e}),y.disabled=d.map(function(e){return!!e.disabled}),w.stateChange(y),e.call(T)}),w.on("tooltipShow",function(e){c&&x(e,k.parentNode)}),w.on("changeState",function(t){typeof t.disabled!="undefined"&&(d.forEach(function(e,n){e.disabled=t.disabled[n]}),y.disabled=t.disabled),typeof t.index!="undefined"&&(S.i=t.index,S.x=E(S.i),y.index=t.index,z.data([S])),typeof t.rescaleY!="undefined"&&(p=t.rescaleY),e.call(T)})}),T}function N(e,n){return n.map(function(n,r){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={top:30,right:30,bottom:50,left:60},u=e.utils.defaultColor(),a=null,f=null,l=!0,c=!0,h=!0,p=!0,d=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},v,m,g=t.id(),y={index:0,rescaleY:p},b="No Data Available.",w=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState");n.orient("bottom").tickPadding(7),r.orient("left");var E=d3.scale.linear(),S={i:0,x:0},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,null,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(){c&&e.tooltip.cleanup()}),T.dispatch=w,T.lines=t,T.legend=i,T.xAxis=n,T.yAxis=r,d3.rebind(T,t,"defined","isArea","x","y","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),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?(a=e,T):a},T.height=function(e){return arguments.length?(f=e,T):f},T.color=function(t){return arguments.length?(u=e.utils.getColor(t),i.color(u),T):u},T.rescaleY=function(e){return arguments.length?(p=e,p):p},T.showControls=function(e){return arguments.length?(h=e,T):h},T.showLegend=function(e){return arguments.length?(l=e,T):l},T.tooltips=function(e){return arguments.length?(c=e,T):c},T.tooltipContent=function(e){return arguments.length?(d=e,T):d},T.state=function(e){return arguments.length?(y=e,T):y},T.noData=function(e){return arguments.length?(b=e,T):b},T},e.models.discreteBar=function(){function b(e){return e.each(function(e){var i=n-t.left-t.right,b=r-t.top-t.bottom,w=d3.select(this);e=e.map(function(e,t){return e.values=e.values.map(function(e){return e.series=t,e}),e});var E=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(E).map(function(e){return e.x})).rangeBands([0,i],.1),o.domain(d||d3.extent(d3.merge(E).map(function(e){return e.y}).concat(f))),c?o.range([b-(o.domain()[0]<0?12:0),o.domain()[1]>0?12:0]):o.range([b,0]),g=g||s,y=y||o.copy().range([o(0),o(0)]);var S=w.selectAll("g.nv-wrap.nv-discretebar").data([e]),T=S.enter().append("g").attr("class","nvd3 nv-wrap nv-discretebar"),N=T.append("g"),C=S.select("g");N.append("g").attr("class","nv-groups"),S.attr("transform","translate("+t.left+","+t.top+")");var k=S.select(".nv-groups").selectAll(".nv-group").data(function(e){return e},function(e){return e.key});k.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(k.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),k.attr("class",function(e,t){return"nv-group nv-series-"+t}).classed("hover",function(e){return e.hover}),d3.transition(k).style("stroke-opacity",1).style("fill-opacity",.75);var L=k.selectAll("g.nv-bar").data(function(e){return e.values});L.exit().remove();var A=L.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),v.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),v.elementMouseout({value:a(t,n),point:t,series:e[t.series],pointIndex:n,seriesIndex:t.series,e:d3.event})}).on("click",function(t,n){v.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){v.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()});A.append("rect").attr("height",0).attr("width",s.rangeBand()*.9/e.length),c?(A.append("text").attr("text-anchor","middle"),L.select("text").attr("x",s.rangeBand()*.9/2).attr("y",function(e,t){return a(e,t)<0?o(a(e,t))-o(0)+12:-4}).text(function(e,t){return h(a(e,t))})):L.selectAll("text").remove(),L.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",m).attr("width",s.rangeBand()*.9/e.length),d3.transition(L).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(0))||1)}),g=s.copy(),y=o.copy()}),b}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=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout"),m="discreteBar",g,y;return b.dispatch=v,b.x=function(e){return arguments.length?(u=e,b):u},b.y=function(e) -{return arguments.length?(a=e,b):a},b.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,b):t},b.width=function(e){return arguments.length?(n=e,b):n},b.height=function(e){return arguments.length?(r=e,b):r},b.xScale=function(e){return arguments.length?(s=e,b):s},b.yScale=function(e){return arguments.length?(o=e,b):o},b.xDomain=function(e){return arguments.length?(p=e,b):p},b.yDomain=function(e){return arguments.length?(d=e,b):d},b.forceY=function(e){return arguments.length?(f=e,b):f},b.color=function(t){return arguments.length?(l=e.utils.getColor(t),b):l},b.id=function(e){return arguments.length?(i=e,b):i},b.showValues=function(e){return arguments.length?(c=e,b):c},b.valueFormat=function(e){return arguments.length?(h=e,b):h},b.rectClass=function(e){return arguments.length?(m=e,b):m},b},e.models.discreteBarChart=function(){function m(e){return e.each(function(u){var l=d3.select(this),g=this,b=(s||parseInt(l.style("width"))||960)-i.left-i.right,w=(o||parseInt(l.style("height"))||400)-i.top-i.bottom;m.update=function(){d.beforeUpdate(),e.transition().call(m)},m.container=this;if(!u||!u.length||!u.filter(function(e){return e.values.length}).length){var E=l.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+b/2).attr("y",i.top+w/2).text(function(e){return e}),m}l.selectAll(".nv-noData").remove(),c=t.xScale(),h=t.yScale();var S=l.selectAll("g.nv-wrap.nv-discreteBarWithAxes").data([u]),T=S.enter().append("g").attr("class","nvd3 nv-wrap nv-discreteBarWithAxes").append("g"),N=T.append("defs"),C=S.select("g");T.append("g").attr("class","nv-x nv-axis"),T.append("g").attr("class","nv-y nv-axis"),T.append("g").attr("class","nv-barsWrap"),C.attr("transform","translate("+i.left+","+i.top+")"),t.width(b).height(w);var k=C.select(".nv-barsWrap").datum(u.filter(function(e){return!e.disabled}));d3.transition(k).call(t),N.append("clipPath").attr("id","nv-x-label-clip-"+t.id()).append("rect"),C.select("#nv-x-label-clip-"+t.id()+" rect").attr("width",c.rangeBand()*(a?2:1)).attr("height",16).attr("x",-c.rangeBand()/(a?1:2)),n.scale(c).ticks(b/100).tickSize(-w,0),C.select(".nv-x.nv-axis").attr("transform","translate(0,"+(h.range()[0]+(t.showValues()&&h.domain()[0]<0?16:0))+")"),C.select(".nv-x.nv-axis").transition().duration(0).call(n);var L=C.select(".nv-x.nv-axis").selectAll("g");a&&L.selectAll("text").attr("transform",function(e,t,n){return"translate(0,"+(n%2==0?"5":"17")+")"}),r.scale(h).ticks(w/36).tickSize(-b,0),d3.transition(C.select(".nv-y.nv-axis")).call(r),d.on("tooltipShow",function(e){f&&v(e,g.parentNode)})}),m}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=!1,f=!0,l=function(e,t,n,r,i){return"

"+t+"

"+"

"+n+"

"},c,h,p="No Data Available.",d=d3.dispatch("tooltipShow","tooltipHide","beforeUpdate");n.orient("bottom").highlightZero(!1).showMaxMin(!1).tickFormat(function(e){return e}),r.orient("left").tickFormat(d3.format(",.1f"));var v=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)),c=l(i.series.key,a,f,i,m);e.tooltip.show([o,u],c,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],d.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){d.tooltipHide(e)}),d.on("tooltipHide",function(){f&&e.tooltip.cleanup()}),m.dispatch=d,m.discretebar=t,m.xAxis=n,m.yAxis=r,d3.rebind(m,t,"x","y","xDomain","yDomain","forceX","forceY","id","showValues","valueFormat"),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.width=function(e){return arguments.length?(s=e,m):s},m.height=function(e){return arguments.length?(o=e,m):o},m.color=function(n){return arguments.length?(u=e.utils.getColor(n),t.color(u),m):u},m.staggerLabels=function(e){return arguments.length?(a=e,m):a},m.tooltips=function(e){return arguments.length?(f=e,m):f},m.tooltipContent=function(e){return arguments.length?(l=e,m):l},m.noData=function(e){return arguments.length?(p=e,m):p},m},e.models.distribution=function(){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))}),d3.transition(m.exit().selectAll("line.nv-dist"+i)).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),d3.transition(g).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.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.indentedTree=function(){function v(e){return e.each(function(t){function C(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)&&C(e,0,!0)}),!0;if(!A(e))return!0;e.values?(e._values=e.values,e.values=null):(e.values=e._values,e._values=null),v.update()}function k(e){return e._values&&e._values.length?h:e.values&&e.values.length?p:""}function L(e){return e._values&&e._values.length}function A(e){var t=e.values||e._values;return t&&t.length}var n=0,i=1,s=d3.layout.tree().children(function(e){return e.values}).size([r,f]);v.update=function(){e.transition().call(v)},v.container=this,t[0]||(t[0]={key:a});var m=s.nodes(t[0]),g=d3.select(this).selectAll("div").data([[m]]),y=g.enter().append("div").attr("class","nvd3 nv-wrap nv-indentedtree"),b=y.append("table"),w=g.select("table").attr("width","100%").attr("class",c);if(o){var E=b.append("thead"),S=E.append("tr");l.forEach(function(e){S.append("th").attr("width",e.width?e.width:"10%").style("text-align",e.type=="numeric"?"right":"left").append("span").text(e.label)})}var x=w.selectAll("tbody").data(function(e){return e});x.enter().append("tbody"),i=d3.max(m,function(e){return e.depth}),s.size([r,i*f]);var T=x.selectAll("tr").data(function(e){return e.filter(function(e){return u&&!e.children?u(e):!0})},function(e){return e.id||e.id==++n});T.exit().remove(),T.select("img.nv-treeicon").attr("src",k).classed("folded",L);var N=T.enter().append("tr");l.forEach(function(e,t){var n=N.append("td").style("padding-left",function(e){return(t?0:e.depth*f+12+(k(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",L).attr("src",k).style("width","14px").style("height","14px").style("padding","0 1px").style("display",function(e){return k(e)?"inline-block":"none"}).on("click",C),n.append("span").attr("class",d3.functor(e.classes)).text(function(t){return e.format?e.format(t):t[e.key]||"-"}),e.showCount&&(n.append("span").attr("class","nv-childrenCount"),T.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)+")":""})),e.click&&n.select("span").on("click",e.click)}),T.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]})})}),v}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");return v.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,v):t},v.width=function(e){return arguments.length?(n=e,v):n},v.height=function(e){return arguments.length?(r=e,v):r},v.color=function(t){return arguments.length?(i=e.utils.getColor(t),scatter.color(i),v):i},v.id=function(e){return arguments.length?(s=e,v):s},v.header=function(e){return arguments.length?(o=e,v):o},v.noData=function(e){return arguments.length?(a=e,v):a},v.filterZero=function(e){return arguments.length?(u=e,v):u},v.columns=function(e){return arguments.length?(l=e,v):l},v.tableClass=function(e){return arguments.length?(c=e,v):c},v.iconOpen=function(e){return arguments.length?(h=e,v):h},v.iconClose=function(e){return arguments.length?(p=e,v):p},v},e.models.legend=function(){function a(e){return e.each(function(e){var a=n-t.left-t.right,f=d3.select(this),l=f.selectAll("g.nv-legend").data([e]),c=l.enter().append("g").attr("class","nvd3 nv-legend").append("g"),h=l.select("g");l.attr("transform","translate("+t.left+","+t.top+")");var p=h.selectAll(".nv-series").data(function(e){return e}),d=p.enter().append("g").attr("class","nv-series").on("mouseover",function(e,t){u.legendMouseover(e,t)}).on("mouseout",function(e,t){u.legendMouseout(e,t)}).on("click",function(e,t){u.legendClick(e,t)}).on("dblclick",function(e,t){u.legendDblclick(e,t)});d.append("circle").style("stroke-width",2).attr("r",5),d.append("text").attr("text-anchor","start").attr("dy",".32em").attr("dx","8"),p.classed("disabled",function(e){return e.disabled}),p.exit().remove(),p.select("circle").style("fill",function(e,t){return e.color||s(e,t)}).style("stroke",function(e,t){return e.color||s(e,t)}),p.select("text").text(i);if(o){var v=[];p.each(function(e,t){v.push(d3.select(this).select("text").node().getComputedTextLength()+28)});var m=0,g=0,y=[];while(ga&&m>1){y=[],m--;for(k=0;k(y[k%m]||0)&&(y[k%m]=v[k]);g=y.reduce(function(e,t,n,r){return e+t})}var b=[];for(var w=0,E=0;wT&&(T=x),"translate("+N+","+S+")"}),h.attr("transform","translate("+(n-t.right-T)+","+t.top+")"),r=t.top+t.bottom+S+15}}),a}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=d3.dispatch("legendClick","legendDblclick","legendMouseover","legendMouseout");return a.dispatch=u,a.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,a):t},a.width=function(e){return arguments.length?(n=e,a):n},a.height=function(e){return arguments.length?(r=e,a):r},a.key=function(e){return arguments.length?(i=e,a):i},a.color=function(t){return arguments.length?(s=e.utils.getColor(t),a):s},a.align=function(e){return arguments.length?(o=e,a):o},a},e.models.line=function(){function m(e){return e.each(function(e){var m=r-n.left-n.right,g=i-n.top-n.bottom,b=d3.select(this);c=t.xScale(),h=t.yScale(),d=d||c,v=v||h;var w=b.selectAll("g.nv-wrap.nv-line").data([e]),E=w.enter().append("g").attr("class","nvd3 nv-wrap nv-line"),S=E.append("defs"),T=E.append("g"),N=w.select("g");T.append("g").attr("class","nv-groups"),T.append("g").attr("class","nv-scatterWrap"),w.attr("transform","translate("+n.left+","+n.top+")"),t.width(m).height(g);var C=w.select(".nv-scatterWrap");d3.transition(C).call(t),S.append("clipPath").attr("id","nv-edge-clip-"+t.id()).append("rect"),w.select("#nv-edge-clip-"+t.id()+" rect").attr("width",m).attr("height",g),N.attr("clip-path",l?"url(#nv-edge-clip-"+t.id()+")":""),C.attr("clip-path",l?"url(#nv-edge-clip-"+t.id()+")":"");var k=w.select(".nv-groups").selectAll(".nv-group").data(function(e){return e},function(e){return e.key});k.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(k.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),k.attr("class",function(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)}),d3.transition(k).style("stroke-opacity",1).style("fill-opacity",.5);var L=k.selectAll("path.nv-area").data(function(e){return f(e)?[e]:[]});L.enter().append("path").attr("class","nv-area").attr("d",function(e){return d3.svg.area().interpolate(p).defined(a).x(function(e,t){return d(o(e,t))}).y0(function(e,t){return v(u(e,t))}).y1(function(e,t){return v(h.domain()[0]<=0?h.domain()[1]>=0?0:h.domain()[1]:h.domain()[0])}).apply(this,[e.values])}),d3.transition(k.exit().selectAll("path.nv-area")).attr("d",function(e){return d3.svg.area().interpolate(p).defined(a).x(function(e,t){return d(o(e,t))}).y0(function(e,t){return v(u(e,t))}).y1(function(e,t){return v(h.domain()[0]<=0?h.domain()[1]>=0?0:h.domain()[1]:h.domain()[0])}).apply(this,[e.values])}),d3.transition(L).attr("d",function(e){return d3.svg.area().interpolate(p).defined(a).x(function(e,t){return d(o(e,t))}).y0(function(e,t){return v(u(e,t))}).y1(function(e,t){return v(h.domain()[0]<=0?h.domain()[1]>=0?0:h.domain()[1]:h.domain()[0])}).apply(this,[e.values])});var A=k.selectAll("path.nv-line").data(function(e){return[e.values]});A.enter().append("path").attr("class","nv-line").attr("d",d3.svg.line().interpolate(p).defined(a).x(function(e,t){return d(o(e,t))}).y(function(e,t){return v(u(e,t))})),d3.transition(k.exit().selectAll("path.nv-line")).attr("d",d3.svg.line().interpolate(p).defined(a).x(function(e,t){return c(o(e,t))}).y(function(e,t){return h(u(e,t))})),d3.transition(A).attr("d",d3.svg.line().interpolate(p).defined(a).x(function(e,t){return c(o(e,t))}).y(function(e,t){return h(u(e,t))})),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","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius","padData"),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(){function y(e){return e.each(function(c){var b=d3.select(this),w=this,E=(u||parseInt(b.style("width"))||960)-s.left-s.right,S=(a||parseInt(b.style("height"))||400)-s.top-s.bottom;y.update=function(){y(e)},y.container=this,d.disabled=c.map(function(e){return!!e.disabled});if(!c||!c.length||!c.filter(function(e){return e.values.length}).length){var T=b.selectAll(".nv-noData").data([v]);return T.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),T.attr("x",s.left+E/2).attr("y",s.top+S/2).text(function(e){return e}),y}b.selectAll(".nv-noData").remove(),h=t.xScale(),p=t.yScale();var N=b.selectAll("g.nv-wrap.nv-lineChart").data([c]),C=N.enter().append("g").attr("class","nvd3 nv-wrap nv-lineChart").append("g"),k=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-linesWrap"),C.append("g").attr("class","nv-legendWrap"),f&&(i.width(E),k.select(".nv-legendWrap").datum(c).call(i),s.top!=i.height()&&(s.top=i.height(),S=(a||parseInt(b.style("height"))||400)-s.top-s.bottom),N.select(".nv-legendWrap").attr("transform","translate(0,"+ -s.top+")")),N.attr("transform","translate("+s.left+","+s.top+")"),t.width(E).height(S).color(c.map(function(e,t){return e.color||o(e,t)}).filter(function(e,t){return!c[t].disabled}));var L=k.select(".nv-linesWrap").datum(c.filter(function(e){return!e.disabled}));d3.transition(L).call(t),n.scale(h).ticks(E/100).tickSize(-S,0),k.select(".nv-x.nv-axis").attr("transform","translate(0,"+p.range()[0]+")"),d3.transition(k.select(".nv-x.nv-axis")).call(n),r.scale(p).ticks(S/36).tickSize(-E,0),d3.transition(k.select(".nv-y.nv-axis")).call(r),i.dispatch.on("legendClick",function(t,n){t.disabled=!t.disabled,c.filter(function(e){return!e.disabled}).length||c.map(function(e){return e.disabled=!1,N.selectAll(".nv-series").classed("disabled",!1),e}),d.disabled=c.map(function(e){return!!e.disabled}),m.stateChange(d),e.transition().call(y)}),m.on("tooltipShow",function(e){l&&g(e,w.parentNode)}),m.on("changeState",function(t){typeof t.disabled!="undefined"&&(c.forEach(function(e,n){e.disabled=t.disabled[n]}),d.disabled=t.disabled),e.call(y)})}),y}var t=e.models.line(),n=e.models.axis(),r=e.models.axis(),i=e.models.legend(),s={top:30,right:20,bottom:50,left:60},o=e.utils.defaultColor(),u=null,a=null,f=!0,l=!0,c=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},h,p,d={},v="No Data Available.",m=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState");n.orient("bottom").tickPadding(7),r.orient("left");var g=function(i,s){if(s){var o=d3.select(s).select("svg"),u=o.attr("viewBox");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),h=n.tickFormat()(t.x()(i.point,i.pointIndex)),p=r.tickFormat()(t.y()(i.point,i.pointIndex)),d=c(i.series.key,h,p,i,y);e.tooltip.show([f,l],d,null,null,s)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+s.left,e.pos[1]+s.top],m.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){m.tooltipHide(e)}),m.on("tooltipHide",function(){l&&e.tooltip.cleanup()}),y.dispatch=m,y.lines=t,y.legend=i,y.xAxis=n,y.yAxis=r,d3.rebind(y,t,"defined","isArea","x","y","size","xScale","yScale","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id","interpolate"),y.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,y):s},y.width=function(e){return arguments.length?(u=e,y):u},y.height=function(e){return arguments.length?(a=e,y):a},y.color=function(t){return arguments.length?(o=e.utils.getColor(t),i.color(o),y):o},y.showLegend=function(e){return arguments.length?(f=e,y):f},y.tooltips=function(e){return arguments.length?(l=e,y):l},y.tooltipContent=function(e){return arguments.length?(c=e,y):c},y.state=function(e){return arguments.length?(d=e,y):d},y.noData=function(e){return arguments.length?(v=e,y):v},y},e.models.linePlusBarChart=function(){function x(e){return e.each(function(l){var c=d3.select(this),v=this,T=(a||parseInt(c.style("width"))||960)-u.left-u.right,N=(f||parseInt(c.style("height"))||400)-u.top-u.bottom;x.update=function(){x(e)},x.container=this,E.disabled=l.map(function(e){return!!e.disabled});if(!l||!l.length||!l.filter(function(e){return e.values.length}).length){var C=c.selectAll(".nv-noData").data([b]);return C.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),C.attr("x",u.left+T/2).attr("y",u.top+N/2).text(function(e){return e}),x}c.selectAll(".nv-noData").remove();var k=l.filter(function(e){return!e.disabled&&e.bar}),L=l.filter(function(e){return!e.bar});m=L.filter(function(e){return!e.disabled}).length&&L.filter(function(e){return!e.disabled})[0].values.length?t.xScale():n.xScale(),g=n.yScale(),y=t.yScale();var A=d3.select(this).selectAll("g.nv-wrap.nv-linePlusBar").data([l]),O=A.enter().append("g").attr("class","nvd3 nv-wrap nv-linePlusBar").append("g"),M=A.select("g");O.append("g").attr("class","nv-x nv-axis"),O.append("g").attr("class","nv-y1 nv-axis"),O.append("g").attr("class","nv-y2 nv-axis"),O.append("g").attr("class","nv-barsWrap"),O.append("g").attr("class","nv-linesWrap"),O.append("g").attr("class","nv-legendWrap"),p&&(o.width(T/2),M.select(".nv-legendWrap").datum(l.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(c.style("height"))||400)-u.top-u.bottom),M.select(".nv-legendWrap").attr("transform","translate("+T/2+","+ -u.top+")")),A.attr("transform","translate("+u.left+","+u.top+")"),t.width(T).height(N).color(l.map(function(e,t){return e.color||h(e,t)}).filter(function(e,t){return!l[t].disabled&&!l[t].bar})),n.width(T).height(N).color(l.map(function(e,t){return e.color||h(e,t)}).filter(function(e,t){return!l[t].disabled&&l[t].bar}));var _=M.select(".nv-barsWrap").datum(k.length?k:[{values:[]}]),D=M.select(".nv-linesWrap").datum(L[0].disabled?[{values:[]}]:L);d3.transition(_).call(n),d3.transition(D).call(t),r.scale(m).ticks(T/100).tickSize(-N,0),M.select(".nv-x.nv-axis").attr("transform","translate(0,"+g.range()[0]+")"),d3.transition(M.select(".nv-x.nv-axis")).call(r),i.scale(g).ticks(N/36).tickSize(-T,0),d3.transition(M.select(".nv-y1.nv-axis")).style("opacity",k.length?1:0).call(i),s.scale(y).ticks(N/36).tickSize(k.length?0:-T,0),M.select(".nv-y2.nv-axis").style("opacity",L.length?1:0).attr("transform","translate("+T+",0)"),d3.transition(M.select(".nv-y2.nv-axis")).call(s),o.dispatch.on("legendClick",function(t,n){t.disabled=!t.disabled,l.filter(function(e){return!e.disabled}).length||l.map(function(e){return e.disabled=!1,A.selectAll(".nv-series").classed("disabled",!1),e}),E.disabled=l.map(function(e){return!!e.disabled}),w.stateChange(E),e.transition().call(x)}),w.on("tooltipShow",function(e){d&&S(e,v.parentNode)}),w.on("changeState",function(t){typeof t.disabled!="undefined"&&(l.forEach(function(e,n){e.disabled=t.disabled[n]}),E.disabled=t.disabled),e.call(x)})}),x}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="No Data Available.",w=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 E={},S=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,x);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],w.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){w.tooltipHide(e)}),n.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+u.left,e.pos[1]+u.top],w.tooltipShow(e)}),n.dispatch.on("elementMouseout.tooltip",function(e){w.tooltipHide(e)}),w.on("tooltipHide",function(){d&&e.tooltip.cleanup()}),x.dispatch=w,x.legend=o,x.lines=t,x.bars=n,x.xAxis=r,x.y1Axis=i,x.y2Axis=s,d3.rebind(x,t,"defined","size","clipVoronoi","interpolate"),x.x=function(e){return arguments.length?(l=e,t.x(e),n.x(e),x):l},x.y=function(e){return arguments.length?(c=e,t.y(e),n.y(e),x):c},x.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,x):u},x.width=function(e){return arguments.length?(a=e,x):a},x.height=function(e){return arguments.length?(f=e,x):f},x.color=function(t){return arguments.length?(h=e.utils.getColor(t),o.color(h),x):h},x.showLegend=function(e){return arguments.length?(p=e,x):p},x.tooltips=function(e){return arguments.length?(d=e,x):d},x.tooltipContent=function(e){return arguments.length?(v=e,x):v},x.state=function(e){return arguments.length?(E=e,x):E},x.noData=function(e){return arguments.length?(b=e,x):b},x},e.models.lineWithFocusChart=function(){function C(e){return e.each(function(S){function R(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 U(){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 z(){w=a.empty()?null:a.extent(),extent=a.empty()?g.domain():a.extent(),T.brush({extent:extent,brush:a}),U();var e=H.select(".nv-focus .nv-linesWrap").datum(S.filter(function(e){return!e.disabled}).map(function(e,n){return{key:e.key,values:e.values.filter(function(e,n){return t.x()(e,n)>=extent[0]&&t.x()(e,n)<=extent[1]})}}));d3.transition(e).call(t),d3.transition(H.select(".nv-focus .nv-x.nv-axis")).call(r),d3.transition(H.select(".nv-focus .nv-y.nv-axis")).call(i)}var k=d3.select(this),L=this,A=(h||parseInt(k.style("width"))||960)-f.left-f.right,O=(p||parseInt(k.style("height"))||400)-f.top-f.bottom-d,M=d-l.top-l.bottom;C.update=function(){C(e)},C.container=this;if(!S||!S.length||!S.filter(function(e){return e.values.length}).length){var _=k.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}),C}k.selectAll(".nv-noData").remove(),v=t.xScale(),m=t.yScale(),g=n.xScale(),y=n.yScale();var D=k.selectAll("g.nv-wrap.nv-lineWithFocusChart").data([S]),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(S).call(u),f.top!=u.height()&&(f.top=u.height(),O=(p||parseInt(k.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(S.map(function(e,t){return e.color||c(e,t)}).filter(function(e,t){return!S[t].disabled})),n.defined(t.defined()).width(A).height(M).color(S.map(function(e,t){return e.color||c(e,t)}).filter(function(e,t){return!S[t].disabled})),H.select(".nv-context").attr("transform","translate(0,"+(O+f.bottom+l.top)+")");var F=H.select(".nv-context .nv-linesWrap").datum(S.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",z),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),gBrush=H.select(".nv-x.nv-brush").call(a),gBrush.selectAll("rect").attr("height",M),gBrush.selectAll(".resize").append("path").attr("d",R),z(),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("legendClick",function(t,n){t.disabled=!t.disabled,S.filter(function(e){return!e.disabled}).length||S.map(function(e){return e.disabled=!1,D.selectAll(".nv-series").classed("disabled",!1),e}),e.transition().call(C)}),T.on("tooltipShow",function(e){E&&N(e,L.parentNode)})}),C}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");t.clipEdge(!0),n.interactive(!1),r.orient("bottom").tickPadding(5),i.orient("left"),s.orient("bottom").tickPadding(5),o.orient("left");var N=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,C);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()}),C.dispatch=T,C.legend=u,C.lines=t,C.lines2=n,C.xAxis=r,C.yAxis=i,C.x2Axis=s,C.y2Axis=o,d3.rebind(C,t,"defined","isArea","size","xDomain","yDomain","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),C.x=function(e){return arguments.length?(t.x(e),n.x(e),C):t.x},C.y=function(e){return arguments.length?(t.y(e),n.y(e),C):t.y},C.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,C):f},C.margin2=function(e){return arguments.length?(l=e,C):l},C.width=function(e){return arguments.length?(h=e,C):h},C.height=function(e){return arguments.length?(p=e,C):p},C.height2=function(e){return arguments.length?(d=e,C):d},C.color=function(t){return arguments.length?(c=e.utils.getColor(t),u.color(c),C):c},C.showLegend=function(e){return arguments.length?(b=e,C):b},C.tooltips=function(e){return arguments.length?(E=e,C):E},C.tooltipContent=function(e){return arguments.length?(S=e,C):S},C.interpolate=function(e){return arguments.length?(t.interpolate(e),n.interpolate(e),C):t.interpolate()},C.noData=function(e){return arguments.length?(x=e,C):x},C.xTickFormat=function(e){return arguments.length?(r.tickFormat(e),s.tickFormat(e),C):r.tickFormat()},C.yTickFormat=function(e){return arguments.length?(i.tickFormat(e),o.tickFormat(e),C):i.tickFormat()},C},e.models.multiBar=function(){function E(e){return e.each(function(e){var E=n-t.left-t.right,S=r-t.top-t.bottom,T=d3.select(this);c&&(e=d3.layout.stack().offset("zero").values(function(e){return e.values}).y(a)(e)),e=e.map(function(e,t){return e.values=e.values.map(function(e){return e.series=t,e}),e}),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 N=m&&g?[]: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(d3.merge(N).map(function(e){return e.x})).rangeBands([0,E],.1),s.domain(g||d3.extent(d3.merge(N).map(function(e){return c?e.y>0?e.y1:e.y1+e.y:e.y}).concat(f))).range([S,0]);if(i.domain()[0]===i.domain()[1]||s.domain()[0]===s.domain()[1])singlePoint=!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])),b=b||i,w=w||s;var C=T.selectAll("g.nv-wrap.nv-multibar").data([e]),k=C.enter().append("g").attr("class","nvd3 nv-wrap nv-multibar"),L=k.append("defs"),A=k.append("g"),O=C.select("g");A.append("g").attr("class","nv-groups"),C.attr("transform","translate("+t.left+","+t.top+")"),L.append("clipPath").attr("id","nv-edge-clip-"+o).append("rect"),C.select("#nv-edge-clip-"+o+" rect").attr("width",E).attr("height",S),O.attr("clip-path",l?"url(#nv-edge-clip-"+o+")":"");var M=C.select(".nv-groups").selectAll(".nv-group").data(function(e){return e},function(e){return e.key});M.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(M.exit()).selectAll("rect.nv-bar").delay(function(t,n){return n*v/e[0].values.length}).attr("y",function(e){return c?w(e.y0):w(0)}).attr("height",0).remove(),M.attr("class",function(e,t){return"nv-group nv-series-"+t}).classed("hover",function(e){return e.hover}).style("fill",function(e,t){return h(e,t)}).style("stroke",function(e,t){return h(e,t)}),d3.transition(M).style("stroke-opacity",1).style("fill-opacity",.75);var _=M.selectAll("rect.nv-bar").data(function(e){return e.values});_.exit().remove();var D=_.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 w(c?e.y0:0)}).attr("height",0).attr("width",i.rangeBand()/(c?1:e.length));_.style("fill",function(e,t,n){return h(e,n,t)}).style("stroke",function(e,t,n){return h(e,n,t)}).on("mouseover",function(t,n){d3.select(this).classed("hover",!0),y.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),y.elementMouseout({value:a(t,n),point:t,series:e[t.series],pointIndex:n,seriesIndex:t.series,e:d3.event})}).on("click",function(t,n){y.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){y.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()}),_.attr("class",function(e,t){return a(e,t)<0?"nv-bar negative":"nv-bar positive"}).attr("transform",function(e,t){return"translate("+i(u(e,t))+",0)"}),p&&(d||(d=e.map(function(){return!0})),_.style("fill",function(e,t,n){return d3.rgb(p(e,t)).darker(d.map(function(e,t){return t}).filter(function(e,t){return!d[t]})[n]).toString()}).style("stroke",function(e,t,n){return d3.rgb(p(e,t)).darker(d.map(function(e,t){return t}).filter(function(e,t){return!d[t]})[n]).toString()})),c?d3.transition(_).delay(function(t,n){return n*v/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)}).each("end",function(){d3.transition(d3.select(this)).attr("x",function(t,n){return c?0:t.series*i.rangeBand()/e.length}).attr("width",i.rangeBand()/(c?1:e.length))}):d3.transition(_).delay(function(t,n){return n*v/e[0].values.length}).attr("x",function(t,n){return t.series*i.rangeBand()/e.length}).attr("width",i.rangeBand()/e.length).each("end",function(){d3.transition(d3.select(this)).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})}),b=i.copy(),w=s.copy()}),E}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=e.utils.defaultColor(),p=null,d,v=1200,m,g,y=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout"),b,w;return E.dispatch=y,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?(i=e,E):i},E.yScale=function(e){return arguments.length?(s=e,E):s},E.xDomain=function(e){return arguments.length?(m=e,E):m},E.yDomain=function(e){return arguments.length?(g=e,E):g},E.forceY=function(e){return arguments.length?(f=e,E):f},E.stacked=function(e){return arguments.length?(c=e,E):c},E.clipEdge=function(e){return arguments.length?(l=e,E):l},E.color=function(t){return arguments.length?(h=e.utils.getColor(t),E):h},E.barColor=function(t){return arguments.length?(p=e.utils.getColor(t),E):p},E.disabled=function(e){return arguments.length?(d=e,E):d},E.id=function(e){return arguments.length?(o=e,E):o},E.delay=function(e){return arguments.length?(v=e,E):v},E},e.models.multiBarChart=function(){function x(e){return e.each(function(v){var T=d3.select(this),N=this,C=(u||parseInt(T.style("width"))||960)-o.left-o.right,k=(a||parseInt(T.style("height"))||400)-o.top-o.bottom;x.update=function(){e.transition().call(x)},x.container=this,y.disabled=v.map(function(e){return!!e.disabled});if(!v||!v.length||!v.filter(function(e){return e.values.length}).length){var L=T.selectAll(".nv-noData").data([b]);return L.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),L.attr("x",o.left+C/2).attr("y",o.top+k/2).text(function(e){return e}),x}T.selectAll(".nv-noData").remove(),m=t.xScale(),g=t.yScale();var A=T.selectAll("g.nv-wrap.nv-multiBarWithLegend").data([v]),O=A.enter().append("g").attr("class","nvd3 nv-wrap nv-multiBarWithLegend").append("g"),M=A.select("g");O.append("g").attr("class","nv-x nv-axis"),O.append("g").attr("class","nv-y nv-axis"),O.append("g").attr("class","nv-barsWrap"),O.append("g").attr("class","nv-legendWrap"),O.append("g").attr("class","nv-controlsWrap"),c&&(i.width(C-E()),t.barColor()&&v.forEach(function(e,t){e.color=d3.rgb("#ccc").darker(t*1.5).toString()}),M.select(".nv-legendWrap").datum(v).call(i),o.top!=i.height()&&(o.top=i.height(),k=(a||parseInt(T.style("height"))||400)-o.top-o.bottom),M.select(".nv-legendWrap").attr("transform","translate("+E()+","+ -o.top+")"));if(l){var _=[{key:"Grouped",disabled:t.stacked()},{key:"Stacked",disabled:!t.stacked()}];s.width(E()).color(["#444","#444","#444"]),M.select(".nv-controlsWrap").datum(_).attr("transform","translate(0,"+ -o.top+")").call(s)}A.attr("transform","translate("+o.left+","+o.top+")"),t.disabled(v.map(function(e){return e.disabled})).width(C).height(k).color(v.map(function(e,t){return e.color||f(e,t)}).filter(function(e,t){return!v[t].disabled}));var D=M.select(".nv-barsWrap").datum(v.filter(function(e){return!e.disabled}));d3.transition(D).call(t),n.scale(m).ticks(C/100).tickSize(-k,0),M.select(".nv-x.nv-axis").attr("transform","translate(0,"+g.range()[0]+")"),d3.transition(M.select(".nv-x.nv-axis")).call(n);var P=M.select(".nv-x.nv-axis > g").selectAll("g");P.selectAll("line, text").style("opacity",1),h&&P.filter(function(e,t){return t%Math.ceil(v[0].values.length/(C/100))!==0}).selectAll("text, line").style("opacity",0),p&&P.selectAll("text").attr("transform","rotate("+p+" 0,0)").attr("text-anchor",p>0?"start":"end"),M.select(".nv-x.nv-axis").selectAll("g.nv-axisMaxMin text").style("opacity",1),r.scale(g).ticks(k/36).tickSize(-C,0),d3.transition(M.select(".nv-y.nv-axis")).call(r),i.dispatch.on("legendClick",function(t,n){t.disabled=!t.disabled,v.filter(function(e){return!e.disabled}).length||v.map(function(e){return e.disabled=!1,A.selectAll(".nv-series").classed("disabled",!1),e}),y.disabled=v.map(function(e){return!!e.disabled}),w.stateChange(y),e.transition().call(x)}),s.dispatch.on("legendClick",function(n,r){if(!n.disabled)return;_=_.map(function(e){return e.disabled=!0,e}),n.disabled=!1;switch(n.key){case"Grouped":t.stacked(!1);break;case"Stacked":t.stacked(!0)}y.stacked=t.stacked(),w.stateChange(y),e.transition().call(x)}),w.on("tooltipShow",function(e){d&&S(e,N.parentNode)}),w.on("changeState",function(n){typeof n.disabled!="undefined"&&(v.forEach(function(e,t){e.disabled=n.disabled[t]}),y.disabled=n.disabled),typeof n.stacked!="undefined"&&(t.stacked(n.stacked),y.stacked=n.stacked),e.call(x)})}),x}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:30,left:60},u=null,a=null,f=e.utils.defaultColor(),l=!0,c=!0,h=!0,p=0,d=!0,v=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" on "+t+"

"},m,g,y={stacked:!1},b="No Data Available.",w=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),E=function(){return l?180:0};t.stacked(!1),n.orient("bottom").tickPadding(7).highlightZero(!1).showMaxMin(!1).tickFormat(function(e){return e}),r.orient("left").tickFormat(d3.format(",.1f"));var S=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=v(i.series.key,a,f,i,x);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],w.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){w.tooltipHide(e)}),w.on("tooltipHide",function(){d&&e.tooltip.cleanup()}),x.dispatch=w,x.multibar=t,x.legend=i,x.xAxis=n,x.yAxis=r,d3.rebind(x,t,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id","stacked","delay","barColor"),x.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,x):o},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?(f=e.utils.getColor(t),i.color(f),x):f},x.showControls=function(e){return arguments.length?(l=e,x):l},x.showLegend=function(e){return arguments.length?(c=e,x):c},x.reduceXTicks=function(e){return arguments.length?(h=e,x):h},x.rotateLabels=function(e){return arguments.length?(p=e,x):p},x.tooltip=function(e){return arguments.length?(v=e,x):v},x.tooltips=function(e){return arguments.length?(d=e,x):d},x.tooltipContent=function(e){return arguments.length?(v=e,x):v},x.state=function(e){return arguments.length?(y=e,x):y},x.noData=function(e){return arguments.length?(b=e,x):b},x},e.models.multiBarHorizontal=function(){function x(e){return e.each(function(e){var i=n-t.left-t.right,g=r-t.top-t.bottom,x=d3.select(this);p&&(e=d3.layout.stack().offset("zero").values(function(e){return e.values}).y(a)(e)),e=e.map(function(e,t){return e.values=e.values.map(function(e){return e.series=t,e}),e}),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 T=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(T).map(function(e){return e.x})).rangeBands([0,g],.1),o.domain(b||d3.extent(d3.merge(T).map(function(e){return p?e.y>0?e.y1+e.y:e.y1:e.y}).concat(f))),d&&!p?o.range([o.domain()[0]<0?v:0,i-(o.domain()[1]>0?v:0)]):o.range([0,i]),E=E||s,S=S||d3.scale.linear().domain(o.domain()).range([o(0),o(0)]);var N=d3.select(this).selectAll("g.nv-wrap.nv-multibarHorizontal").data([e]),C=N.enter().append("g").attr("class","nvd3 nv-wrap nv-multibarHorizontal"),k=C.append("defs"),L=C.append("g"),A=N.select("g");L.append("g").attr("class","nv-groups"),N.attr("transform","translate("+t.left+","+t.top+")");var O=N.select(".nv-groups").selectAll(".nv-group").data(function(e){return e},function(e){return e.key});O.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition(O.exit()).style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),O.attr("class",function(e,t){return"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)}),d3.transition(O).style("stroke-opacity",1).style("fill-opacity",.75);var M=O.selectAll("g.nv-bar").data(function(e){return e.values});M.exit().remove();var _=M.enter().append("g").attr("transform",function(t,n,r){return"translate("+S(p?t.y0:0)+","+(p?0:r*s.rangeBand()/e.length+s(u(t,n)))+")"});_.append("rect").attr("width",0).attr("height",s.rangeBand()/(p?1:e.length)),M.on("mouseover",function(t,n){d3.select(this).classed("hover",!0),w.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),w.elementMouseout({value:a(t,n),point:t,series:e[t.series],pointIndex:n,seriesIndex:t.series,e:d3.event})}).on("click",function(t,n){w.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){w.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()}),_.append("text"),d&&!p?(M.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))}),d3.transition(M).select("text").attr("x",function(e,t){return a(e,t)<0?-4:o(a(e,t))-o(0)+4})):M.selectAll("text").text(""),M.attr("class",function(e,t){return a(e,t)<0?"nv-bar negative":"nv-bar positive"}),c&&(h||(h=e.map(function(){return!0})),M.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?d3.transition(M).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()):d3.transition(M).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)}),E=s.copy(),S=o.copy()}),x}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=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout"),E,S;return x.dispatch=w,x.x=function(e){return arguments.length?(u=e,x):u},x.y=function(e){return arguments.length?(a=e,x):a},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.forceY=function(e){return arguments.length?(f=e,x):f},x.stacked=function(e){return arguments.length?(p=e,x):p},x.color=function(t){return arguments.length?(l=e.utils.getColor(t),x):l},x.barColor=function(t){return arguments.length?(c=e.utils.getColor(t),x):c},x.disabled=function(e){return arguments.length?(h=e,x):h},x.id=function(e){return arguments.length?(i=e,x):i},x.delay=function(e){return arguments.length?(g=e,x):g},x.showValues=function(e){return arguments.length?(d=e,x):d},x.valueFormat=function(e){return arguments.length?(m=e,x):m},x.valuePadding=function(e){return arguments.length?(v=e,x):v},x},e.models.multiBarHorizontalChart=function(){function S(e){return e.each(function(h){var d=d3.select(this),T=this,N=(u||parseInt(d.style("width"))||960)-o.left-o.right,C=(a||parseInt(d.style("height"))||400)-o.top-o.bottom;S.update=function(){e.transition().call(S)},S.container=this,g.disabled=h.map(function(e){return!!e.disabled});if(!h||!h.length||!h.filter(function(e){return e.values.length}).length){var k=d.selectAll(".nv-noData").data([y]);return k.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),k.attr("x",o.left+N/2).attr("y",o.top+C/2).text(function(e){return e}),S}d.selectAll(".nv-noData").remove(),v=t.xScale(),m=t.yScale();var L=d.selectAll("g.nv-wrap.nv-multiBarHorizontalChart").data([h]),A=L.enter().append("g").attr("class","nvd3 nv-wrap nv-multiBarHorizontalChart").append("g"),O=L.select("g");A.append("g").attr("class","nv-x nv-axis"),A.append("g").attr("class","nv-y nv-axis"),A.append("g").attr("class","nv-barsWrap"),A.append("g").attr("class","nv-legendWrap"),A.append("g").attr("class","nv-controlsWrap"),c&&(i.width(N-w()),t.barColor()&&h.forEach(function(e,t){e.color=d3.rgb("#ccc").darker(t*1.5).toString()}),O.select(".nv-legendWrap").datum(h).call(i),o.top!=i.height()&&(o.top=i.height(),C=(a||parseInt(d.style("height"))||400)-o.top-o.bottom),O.select(".nv-legendWrap").attr("transform","translate("+w()+","+ -o.top+")"));if(l){var M=[{key:"Grouped",disabled:t.stacked()},{key:"Stacked",disabled:!t.stacked()}];s.width(w()).color(["#444","#444","#444"]),O.select(".nv-controlsWrap").datum(M).attr("transform","translate(0,"+ -o.top+")").call(s)}L.attr("transform","translate("+o.left+","+o.top+")"),t.disabled(h.map(function(e){return e.disabled})).width(N).height(C).color(h.map(function(e,t){return e.color||f(e,t)}).filter(function(e,t){return!h[t].disabled}));var _=O.select(".nv-barsWrap").datum(h.filter(function(e){return!e.disabled}));d3.transition(_).call(t),n.scale(v).ticks(C/24).tickSize(-N,0),d3.transition(O.select(".nv-x.nv-axis")).call(n);var D=O.select(".nv-x.nv-axis").selectAll("g");D.selectAll("line, text").style("opacity",1),r.scale(m).ticks(N/100).tickSize(-C,0),O.select(".nv-y.nv-axis").attr("transform","translate(0,"+C+")"),d3.transition(O.select(".nv-y.nv-axis")).call(r),i.dispatch.on("legendClick",function(t,n){t.disabled=!t.disabled,h.filter(function(e){return!e.disabled}).length||h.map(function(e){return e.disabled=!1,L.selectAll(".nv-series").classed("disabled",!1),e}),g.disabled=h.map(function(e){return!!e.disabled}),b.stateChange(g),e.transition().call(S)}),s.dispatch.on("legendClick",function(n,r){if(!n.disabled)return;M=M.map(function(e){return e.disabled=!0,e}),n.disabled=!1;switch(n.key){case"Grouped":t.stacked(!1);break;case"Stacked":t.stacked(!0)}g.stacked=t.stacked(),b.stateChange(g),e.transition().call(S)}),b.on("tooltipShow",function(e){p&&E(e,T.parentNode)}),b.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(S)})}),S}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="No Data Available.",b=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),w=function(){return l?180:0};t.stacked(h),n.orient("left").tickPadding(5).highlightZero(!1).showMaxMin(!1).tickFormat(function(e){return e}),r.orient("bottom").tickFormat(d3.format(",.1f"));var E=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,S);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],b.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){b.tooltipHide(e)}),b.on("tooltipHide",function(){p&&e.tooltip.cleanup()}),S.dispatch=b,S.multibar=t,S.legend=i,S.xAxis=n,S.yAxis=r,d3.rebind(S,t,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id","delay","showValues","valueFormat","stacked","barColor"),S.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,S):o},S.width=function(e){return arguments.length?(u=e,S):u},S.height=function(e){return arguments.length?(a=e,S):a},S.color=function(t){return arguments.length?(f=e.utils.getColor(t),i.color(f),S):f},S.showControls=function(e){return arguments.length?(l=e,S):l},S.showLegend=function(e){return arguments.length?(c=e,S):c},S.tooltip=function(e){return arguments.length?(d=e,S):d},S.tooltips=function(e){return arguments.length?(p=e,S):p},S.tooltipContent=function(e){return arguments.length?(d=e,S):d},S.state=function(e){return arguments.length?(g=e,S):g},S.noData=function(e){return arguments.length?(y=e,S):y},S},e.models.multiChart=function(){function T(e){return e.each(function(u){var f=d3.select(this),N=this,C=(r||parseInt(f.style("width"))||960)-t.left-t.right,k=(i||parseInt(f.style("height"))||400)-t.top-t.bottom,L=u.filter(function(e){return!e.disabled&&e.type=="line"&&e.yAxis==1}),A=u.filter(function(e){return!e.disabled&&e.type=="line"&&e.yAxis==2}),O=u.filter(function(e){return!e.disabled&&e.type=="bar"&&e.yAxis==1}),M=u.filter(function(e){return!e.disabled&&e.type=="bar"&&e.yAxis==2}),_=u.filter(function(e){return!e.disabled&&e.type=="area"&&e.yAxis==1}),D=u.filter(function(e){return!e.disabled&&e.type=="area"&&e.yAxis==2}),P=u.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}})}),H=u.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(P.concat(H)),function(e){return e.x})).range([0,C]);var B=f.selectAll("g.wrap.multiChart").data([u]),j=B.enter().append("g").attr("class","wrap nvd3 multiChart").append("g");j.append("g").attr("class","x axis"),j.append("g").attr("class","y1 axis"),j.append("g").attr("class","y2 axis"),j.append("g").attr("class","lines1Wrap"),j.append("g").attr("class","lines2Wrap"),j.append("g").attr("class","bars1Wrap"),j.append("g").attr("class","bars2Wrap"),j.append("g").attr("class","stack1Wrap"),j.append("g").attr("class","stack2Wrap"),j.append("g").attr("class","legendWrap");var F=B.select("g");s&&(E.width(C/2),F.select(".legendWrap").datum(u.map(function(e){return e.originalKey=e.originalKey===undefined?e.key:e.originalKey,e.key=e.originalKey+(e.yAxis==1?"":" (right axis)"),e})).call(E),t.top!=E.height()&&(t.top=E.height(),k=(i||parseInt(f.style("height"))||400)-t.top-t.bottom),F.select(".legendWrap").attr("transform","translate("+C/2+","+ -t.top+")")),h.width(C).height(k).interpolate("monotone").color(u.map(function(e,t){return e.color||n[t%n.length]}).filter(function(e,t){return!u[t].disabled&&u[t].yAxis==1&&u[t].type=="line"})),p.width(C).height(k).interpolate("monotone").color(u.map(function(e,t){return e.color||n[t%n.length]}).filter(function(e,t){return!u[t].disabled&&u[t].yAxis==2&&u[t].type=="line"})),d.width(C).height(k).color(u.map(function(e,t){return e.color||n[t%n.length]}).filter(function(e,t){return!u[t].disabled&&u[t].yAxis==1&&u[t].type=="bar"})),v.width(C).height(k).color(u.map(function(e,t){return e.color||n[t%n.length]}).filter(function(e,t){return!u[t].disabled&&u[t].yAxis==2&&u[t].type=="bar"})),m.width(C).height(k).color(u.map(function(e,t){return e.color||n[t%n.length]}).filter(function(e,t){return!u[t].disabled&&u[t].yAxis==1&&u[t].type=="area"})),g.width(C).height(k).color(u.map(function(e,t){return e.color||n[t%n.length]}).filter(function(e,t){return!u[t].disabled&&u[t].yAxis==2&&u[t].type=="area"})),F.attr("transform","translate("+t.left+","+t.top+")");var I=F.select(".lines1Wrap").datum(L),q=F.select(".bars1Wrap").datum(O),R=F.select(".stack1Wrap").datum(_),U=F.select(".lines2Wrap").datum(A),z=F.select(".bars2Wrap").datum(M),W=F.select(".stack2Wrap").datum(D),X=_.length?_.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}]):[],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}]):[];l.domain(d3.extent(d3.merge(P).concat(X),function(e){return e.y})).range([0,k]),c.domain(d3.extent(d3.merge(H).concat(V),function(e){return e.y})).range([0,k]),h.yDomain(l.domain()),d.yDomain(l.domain()),m.yDomain(l.domain()),p.yDomain(c.domain()),v.yDomain(c.domain()),g.yDomain(c.domain()),_.length&&d3.transition(R).call(m),D.length&&d3.transition(W).call(g),O.length&&d3.transition(q).call(d),M.length&&d3.transition(z).call(v),L.length&&d3.transition(I).call(h),A.length&&d3.transition(U).call(p),y.ticks(C/100).tickSize(-k,0),F.select(".x.axis").attr("transform","translate(0,"+k+")"),d3.transition(F.select(".x.axis")).call(y),b.ticks(k/36).tickSize(-C,0),d3.transition(F.select(".y1.axis")).call(b),w.ticks(k/36).tickSize(-C,0),d3.transition(F.select(".y2.axis")).call(w),F.select(".y2.axis").style("opacity",H.length?1:0).attr("transform","translate("+a.range()[1]+",0)"),E.dispatch.on("legendClick",function(t,n){t.disabled=!t.disabled,u.filter(function(e){return!e.disabled}).length||u.map(function(e){return e.disabled=!1,B.selectAll(".series").classed("disabled",!1),e}),e.transition().call(T)}),S.on("tooltipShow",function(e){o&&x(e,N.parentNode)})}),T.update=function(){T(e)},T.container=this,T}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,a=d3.scale.linear(),l=d3.scale.linear(),c=d3.scale.linear(),h=e.models.line().yScale(l),p=e.models.line().yScale(c),d=e.models.multiBar().stacked(!1).yScale(l),v=e.models.multiBar().stacked(!1).yScale(c),m=e.models.stackedArea().yScale(l),g=e.models.stackedArea().yScale(c),y=e.models.axis().scale(a).orient("bottom").tickPadding(5),b=e.models.axis().scale(l).orient("left"),w=e.models.axis().scale(c).orient("right"),E=e.models.legend().height(30),S=d3.dispatch("tooltipShow","tooltipHide"),x=function(t,n){var r=t.pos[0]+(n.offsetLeft||0),i=t.pos[1]+(n.offsetTop||0),s=y.tickFormat()(h.x()(t.point,t.pointIndex)),o=(t.series.yAxis==2?w:b).tickFormat()(h.y()(t.point,t.pointIndex)),a=u(t.series.key,s,o,t,T);e.tooltip.show([r,i],a,undefined,undefined,n.offsetParent)};return h.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],S.tooltipShow(e)}),h.dispatch.on("elementMouseout.tooltip",function(e){S.tooltipHide(e)}),p.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],S.tooltipShow(e)}),p.dispatch.on("elementMouseout.tooltip",function(e){S.tooltipHide(e)}),d.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],S.tooltipShow(e)}),d.dispatch.on("elementMouseout.tooltip",function(e){S.tooltipHide(e)}),v.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],S.tooltipShow(e)}),v.dispatch.on("elementMouseout.tooltip",function(e){S.tooltipHide(e)}),m.dispatch.on("tooltipShow",function(e){if(!Math.round(m.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],S.tooltipShow(e)}),m.dispatch.on("tooltipHide",function(e){S.tooltipHide(e)}),g.dispatch.on("tooltipShow",function(e){if(!Math.round(g.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],S.tooltipShow(e)}),g.dispatch.on("tooltipHide",function(e){S.tooltipHide(e)}),h.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],S.tooltipShow(e)}),h.dispatch.on("elementMouseout.tooltip",function(e){S.tooltipHide(e)}),p.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],S.tooltipShow(e)}),p.dispatch.on("elementMouseout.tooltip",function(e){S.tooltipHide(e)}),S.on("tooltipHide",function(){o&&e.tooltip.cleanup()}),T.dispatch=S,T.lines1=h,T.lines2=p,T.bars1=d,T.bars2=v,T.stack1=m,T.stack2=g,T.xAxis=y,T.yAxis1=b,T.yAxis2=w,T.x=function(e){return arguments.length?(getX=e,h.x(e),d.x(e),T):getX},T.y=function(e){return arguments.length?(getY=e,h.y(e),d.y(e),T):getY},T.margin=function(e){return arguments.length?(t=e,T):t},T.width=function(e){return arguments.length?(r=e,T):r},T.height=function(e){return arguments.length?(i=e,T):i},T.color=function(e){return arguments.length?(n=e,E.color(e),T):n},T.showLegend=function(e){return arguments.length?(s=e,T):s},T.tooltips=function(e){return arguments.length?(o=e,T):o},T.tooltipContent=function(e){return arguments.length?(u=e,T):u},T},e.models.ohlcBar=function(){function E(e){return e.each(function(e){var g=n-t.left-t.right,E=r-t.top-t.bottom,S=d3.select(this);s.domain(y||d3.extent(e[0].values.map(u).concat(p))),v?s.range([g*.5/e[0].values.length,g*(e[0].values.length-.5)/e[0].values.length]):s.range([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,0]);if(s.domain()[0]===s.domain()[1]||o.domain()[0]===o.domain()[1])singlePoint=!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 T=d3.select(this).selectAll("g.nv-wrap.nv-ohlcBar").data([e[0].values]),N=T.enter().append("g").attr("class","nvd3 nv-wrap nv-ohlcBar"),C=N.append("defs"),k=N.append("g"),L=T.select("g");k.append("g").attr("class","nv-ticks"),T.attr("transform","translate("+t.left+","+t.top+")"),S.on("click",function(e,t){w.chartClick({data:e,index:t,pos:d3.event,id:i})}),C.append("clipPath").attr("id","nv-chart-clip-path-"+i).append("rect"),T.select("#nv-chart-clip-path-"+i+" rect").attr("width",g).attr("height",E),L.attr("clip-path",m?"url(#nv-chart-clip-path-"+i+")":"");var A=T.select(".nv-ticks").selectAll(".nv-tick").data(function(e){return e});A.exit().remove();var O=A.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),w.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),w.elementMouseout({point:t,series:e[0],pointIndex:n,seriesIndex:0,e:d3.event})}).on("click",function(e,t){w.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){w.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()});A.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(A).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"})}),E}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=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return E.dispatch=w,E.x=function(e){return arguments.length?(u=e,E):u},E.y=function(e){return arguments.length?(a=e,E):a},E.open=function(e){return arguments.length?(f=e,E):f},E.close=function(e){return arguments.length?(l=e,E):l},E.high=function(e){return arguments.length?(c=e,E):c},E.low=function(e){return arguments.length?(h=e,E):h},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?(y=e,E):y},E.yDomain=function(e){return arguments.length?(b=e,E):b},E.forceX=function(e){return arguments.length?(p=e,E):p},E.forceY=function(e){return arguments.length?(d=e,E):d},E.padData=function(e){return arguments.length?(v=e,E):v},E.clipEdge=function(e){return arguments.length?(m=e,E):m},E.color=function(t){return arguments.length?(g=e.utils.getColor(t),E):g},E.id=function(e){return arguments.length?(i=e,E):i},E},e.models.pie=function(){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){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 u=n-t.left-t.right,l=r-t.top-t.bottom,E=Math.min(u,l)/2,S=E-E/5,x=d3.select(this),T=x.selectAll(".nv-wrap.nv-pie").data([i(e[0])]),N=T.enter().append("g").attr("class","nvd3 nv-wrap nv-pie nv-chart-"+a),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("+u/2+","+l/2+")"),x.on("click",function(e,t){w.chartClick({data:e,index:t,pos:d3.event,id:a})});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:o(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:s(e.data),value:o(e.data),point:e.data,pointIndex:t,pos:[d3.event.pageX,d3.event.pageY],id:a})}).on("mouseout",function(e,t){d3.select(this).classed("hover",!1),w.elementMouseout({label:s(e.data),value:o(e.data),point:e.data,index:t,id:a})}).on("click",function(e,t){w.elementClick({label:s(e.data),value:o(e.data),point:e.data,index:t,pos:d3.event,id:a}),d3.event.stopPropagation()}).on("dblclick",function(e,t){w.elementDblClick({label:s(e.data),value:o(e.data),point:e.data,index:t,pos:d3.event,id:a}),d3.event.stopPropagation()});O.attr("fill",function(e,t){return f(e,t)}).attr("stroke",function(e,t){return f(e,t)});var _=M.append("path").each(function(e){this._current=e});d3.transition(O.select("path")).attr("d",L).attrTween("d",H);if(c){var D=d3.svg.arc().innerRadius(0);h&&(D=L),p&&(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?s(e.data):""});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.values},s=function(e){return e.x},o=function(e){return e.y},u=function(e){return e.description},a=Math.floor(Math.random()*1e4),f=e.utils.defaultColor(),l=d3.format(",.2f"),c=!0,h=!0,p=!1,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.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(e){return arguments.length?(i=e,E):i},E.x=function(e){return arguments.length?(s=e,E):s},E.y=function(e){return arguments.length?(o=d3.functor(e),E):o},E.description=function(e){return arguments.length?(u=e,E):u},E.showLabels=function(e){return arguments.length?(c=e,E):c},E.labelSunbeamLayout=function(e){return arguments.length?(m=e,E):m},E.donutLabelsOutside=function(e){return arguments.length?(p=e,E):p},E.pieLabelsOutside=function(e){return arguments.length?(h=e,E):h},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?(a=e,E):a},E.color=function(t){return arguments.length?(f=e.utils.getColor(t),E):f},E.valueFormat=function(e){return arguments.length?(l=e,E):l},E.labelThreshold=function(e){return arguments.length?(d=e,E):d},E},e.models.pieChart=function(){function d(e){return e.each(function(u){var a=d3.select(this),f=this,p=(i||parseInt(a.style("width"))||960)-r.left-r.right,v=(s||parseInt(a.style("height"))||400)-r.top-r.bottom;d.update=function(){d(e)},d.container=this,l.disabled=u[0].map(function(e){return!!e.disabled});if(!u[0]||!u[0].length){var m=a.selectAll(".nv-noData").data([c]);return m.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),m.attr("x",r.left+p/2).attr("y",r.top+v/2).text(function(e){return e}),d}a.selectAll(".nv-noData").remove();var g=a.selectAll("g.nv-wrap.nv-pieChart").data([u]),y=g.enter().append("g").attr("class","nvd3 nv-wrap nv-pieChart").append("g"),b=g.select("g");y.append("g").attr("class","nv-pieWrap"),y.append("g").attr("class","nv-legendWrap"),o&&(n.width(p).key(t.x()),g.select(".nv-legendWrap").datum(t.values()(u[0])).call(n),r.top!=n.height()&&(r.top=n.height(),v=(s||parseInt(a.style("height"))||400)-r.top-r.bottom),g.select(".nv-legendWrap").attr("transform","translate(0,"+ -r.top+")")),g.attr("transform","translate("+r.left+","+r.top+")"),t.width(p).height(v);var w=b.select(".nv-pieWrap").datum(u);d3.transition(w).call(t),n.dispatch.on("legendClick",function(n,r,i){n.disabled=!n.disabled,t.values()(u[0]).filter(function(e){return!e.disabled}).length||t.values()(u[0]).map(function(e){return e.disabled=!1,g.selectAll(".nv-series").classed("disabled",!1),e}),l.disabled=u[0].map(function(e){return!!e.disabled}),h.stateChange(l),e.transition().call(d)}),t.dispatch.on("elementMouseout.tooltip",function(e){h.tooltipHide(e)}),h.on("changeState",function(t){typeof t.disabled!="undefined"&&(u[0].forEach(function(e,n){e.disabled=t.disabled[n]}),l.disabled=t.disabled),e.call(d)})}),d}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="No Data Available.",h=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),p=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,d);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],h.tooltipShow(e)}),h.on("tooltipShow",function(e){a&&p(e)}),h.on("tooltipHide",function(){a&&e.tooltip.cleanup()}),d.legend=n,d.dispatch=h,d.pie=t,d3.rebind(d,t,"valueFormat","values","x","y","description","id","showLabels","donutLabelsOutside","pieLabelsOutside","donut","donutRatio","labelThreshold"),d.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,d):r},d.width=function(e){return arguments.length?(i=e,d):i},d.height=function(e){return arguments.length?(s=e,d):s},d.color=function(r){return arguments.length?(u=e.utils.getColor(r),n.color(u),t.color(u),d):u},d.showLegend=function(e){return arguments.length?(o=e,d):o},d.tooltips=function(e){return arguments.length?(a=e,d):a},d.tooltipContent=function(e){return arguments.length?(f=e,d):f},d.state=function(e){return arguments.length?(l=e,d):l},d.noData=function(e){return arguments.length?(c=e,d):c},d},e.models.scatter=function(){function B(e){return e.each(function(e){function V(){if(!g)return!1;var i,a=d3.merge(e.map(function(e,t){return e.values.map(function(e,n){return[o(f(e,n))*(Math.random()/1e12+1),u(l(e,n))*(Math.random()/1e12+1),t,n,e]}).filter(function(e,t){return y(e[4],t)})}));if(O===!0){if(S){var c=q.select("defs").selectAll(".nv-point-clips").data([s]).enter();c.append("clipPath").attr("class","nv-point-clips").attr("id","nv-points-clip-"+s);var h=q.select("#nv-points-clip-"+s).selectAll("circle").data(a);h.enter().append("circle").attr("r",x),h.exit().remove(),h.attr("cx",function(e){return e[0]}).attr("cy",function(e){return e[1]}),q.select(".nv-point-paths").attr("clip-path","url(#nv-points-clip-"+s+")")}a.push([o.range()[0]-20,u.range()[0]-20,null,null]),a.push([o.range()[1]+20,u.range()[1]+20,null,null]),a.push([o.range()[0]-20,u.range()[0]+20,null,null]),a.push([o.range()[1]+20,u.range()[1]-20,null,null]);var p=d3.geom.polygon([[-10,-10],[-10,r+10],[n+10,r+10],[n+10,-10]]),d=d3.geom.voronoi(a).map(function(e,t){return{data:p.clip(e),series:a[t][2],point:a[t][3]}}),v=q.select(".nv-point-paths").selectAll("path").data(d);v.enter().append("path").attr("class",function(e,t){return"nv-path-"+t}),v.exit().remove(),v.attr("d",function(e){return"M"+e.data.join("L")+"Z"}),v.on("click",function(n){if(H)return 0;var r=e[n.series],i=r.values[n.point];A.elementClick({point:i,series:r,pos:[o(f(i,n.point))+t.left,u(l(i,n.point))+t.top],seriesIndex:n.series,pointIndex:n.point})}).on("mouseover",function(n){if(H)return 0;var r=e[n.series],i=r.values[n.point];A.elementMouseover({point:i,series:r,pos:[o(f(i,n.point))+t.left,u(l(i,n.point))+t.top],seriesIndex:n.series,pointIndex:n.point})}).on("mouseout",function(t,n){if(H)return 0;var r=e[t.series],i=r.values[t.point];A.elementMouseout({point:i,series:r,seriesIndex:t.series,pointIndex:t.point})})}else q.select(".nv-groups").selectAll(".nv-group").selectAll(".nv-point").on("click",function(n,r){if(H||!e[n.series])return 0;var i=e[n.series],s=i.values[r];A.elementClick({point:s,series:i,pos:[o(f(s,r))+t.left,u(l(s,r))+t.top],seriesIndex:n.series,pointIndex:r})}).on("mouseover",function(n,r){if(H||!e[n.series])return 0;var i=e[n.series],s=i.values[r];A.elementMouseover({point:s,series:i,pos:[o(f(s,r))+t.left,u(l(s,r))+t.top],seriesIndex:n.series,pointIndex:r})}).on("mouseout",function(t,n){if(H||!e[t.series])return 0;var r=e[t.series],i=r.values[n];A.elementMouseout({point:i,series:r,seriesIndex:t.series,pointIndex:n})});H=!1}var B=n-t.left-t.right,j=r-t.top-t.bottom,F=d3.select(this);e=e.map(function(e,t){return e.values=e.values.map(function(e){return e.series=t,e}),e});var I=T&&N&&C?[]:d3.merge(e.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(T||d3.extent(I.map(function(e){return e.x}).concat(d))),b&&e[0]?o.range([(B*w+B)/(2*e[0].values.length),B-B*(1+w)/(2*e[0].values.length)]):o.range([0,B]),u.domain(N||d3.extent(I.map(function(e){return e.y}).concat(v))).range([j,0]),a.domain(C||d3.extent(I.map(function(e){return e.size}).concat(m))).range(k||[16,256]);if(o.domain()[0]===o.domain()[1]||u.domain()[0]===u.domain()[1])L=!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])),M=M||o,_=_||u,D=D||a;var q=F.selectAll("g.nv-wrap.nv-scatter").data([e]),R=q.enter().append("g").attr("class","nvd3 nv-wrap nv-scatter nv-chart-"+s+(L?" nv-single-point":"")),U=R.append("defs"),W=R.append("g"),X=q.select("g");W.append("g").attr("class","nv-groups"),W.append("g").attr("class","nv-point-paths"),q.attr("transform","translate("+t.left+","+t.top+")"),U.append("clipPath").attr("id","nv-edge-clip-"+s).append("rect"),q.select("#nv-edge-clip-"+s+" rect").attr("width",B).attr("height",j),X.attr("clip-path",E?"url(#nv-edge-clip-"+s+")":""),H=!0;var $=q.select(".nv-groups").selectAll(".nv-group").data(function(e){return e},function(e){return e.key});$.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),d3.transition($.exit()).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}),d3.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 J=$.selectAll("circle.nv-point").data(function(e){return e.values});J.enter().append("circle").attr("cx",function(e,t){return M(f(e,t))}).attr("cy",function(e,t){return _(l(e,t))}).attr("r",function(e,t){return Math.sqrt(a(c(e,t))/Math.PI)}),J.exit().remove(),d3.transition($.exit().selectAll("path.nv-point")).attr("cx",function(e,t){return o(f(e,t))}).attr("cy",function(e,t){return u(l(e,t))}).remove(),J.attr("class",function(e,t){return"nv-point nv-point-"+t}),d3.transition(J).attr("cx",function(e,t){return o(f(e,t))}).attr("cy",function(e,t){return u(l(e,t))}).attr("r",function(e,t){return Math.sqrt(a(c(e,t))/Math.PI)})}else{var J=$.selectAll("path.nv-point").data(function(e){return e.values});J.enter().append("path").attr("transform",function(e,t){return"translate("+M(f(e,t))+","+_(l(e,t))+")"}).attr("d",d3.svg.symbol().type(h).size(function(e,t){return a(c(e,t))})),J.exit().remove(),d3.transition($.exit().selectAll("path.nv-point")).attr("transform",function(e,t){return"translate("+o(f(e,t))+","+u(l(e,t))+")"}).remove(),J.attr("class",function(e,t){return"nv-point nv-point-"+t}),d3.transition(J).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(P),P=setTimeout(V,300),M=o.copy(),_=u.copy(),D=a.copy()}),B}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=function(e){return!e.notActive},b=!1,w=.1,E=!1,S=!0,x=function(){return 25},T=null,N=null,C=null,k=null,L=!1,A=d3.dispatch("elementClick","elementMouseover","elementMouseout"),O=!0,M,_,D,P,H=!1;return A.on("elementMouseover.point",function(e){g&&d3.select(".nv-chart-"+s+" .nv-series-"+e.seriesIndex+" .nv-point-"+e.pointIndex).classed("hover",!0)}),A.on("elementMouseout.point",function(e){g&&d3.select(".nv-chart-"+s+" .nv-series-"+e.seriesIndex+" .nv-point-"+e.pointIndex).classed("hover",!1)}),B.dispatch=A,B.x=function(e){return arguments.length?(f=d3.functor(e),B):f},B.y=function(e){return arguments.length?(l=d3.functor(e),B):l},B.size=function(e){return arguments.length?(c=d3.functor(e),B):c},B.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,B):t},B.width=function(e){return arguments.length?(n=e,B):n},B.height=function(e){return arguments.length?(r=e,B):r},B.xScale=function(e){return arguments.length?(o=e,B):o},B.yScale=function(e){return arguments.length?(u=e,B):u},B.zScale=function(e){return arguments.length?(a=e,B):a},B.xDomain=function(e){return arguments.length?(T=e,B):T},B.yDomain=function(e){return arguments.length?(N=e,B):N},B.sizeDomain=function(e){return arguments.length?(C=e,B):C},B.sizeRange=function(e){return arguments.length?(k=e,B):k},B.forceX=function(e){return arguments.length?(d=e,B):d},B.forceY=function(e){return arguments.length?(v=e,B):v},B.forceSize=function(e){return arguments.length?(m=e,B):m},B.interactive=function(e){return arguments.length?(g=e,B):g},B.pointActive=function(e){return arguments.length?(y=e,B):y},B.padData=function(e){return arguments.length?(b=e,B):b},B.padDataOuter=function(e){return arguments.length?(w=e,B):w},B.clipEdge=function(e){return arguments.length?(E=e,B):E},B.clipVoronoi=function(e){return arguments.length?(S=e,B):S},B.useVoronoi=function(e){return arguments.length?(O=e,O===!1&&(S=!1),B):O},B.clipRadius=function(e){return arguments.length?(x=e,B):x},B.color=function(t){return arguments.length?(i=e.utils.getColor(t),B):i},B.shape=function(e){return arguments.length?(h=e,B):h},B.onlyCircles=function(e){return arguments.length?(p=e,B):p},B.id=function(e){return arguments.length?(s=e,B):s},B.singlePoint=function(e){return arguments.length?(L=e,B):L},B},e.models.scatterChart=function(){function D(e){return e.each(function(x){function z(){if(E)return q.select(".nv-point-paths").style("pointer-events","all"),!1;q.select(".nv-point-paths").style("pointer-events","none");var e=d3.mouse(this);h.distortion(w).focus(e[0]),p.distortion(w).focus(e[1]),q.select(".nv-scatterWrap").call(t),q.select(".nv-x.nv-axis").call(n),q.select(".nv-y.nv-axis").call(r),q.select(".nv-distributionX").datum(x.filter(function(e){return!e.disabled})).call(o),q.select(".nv-distributionY").datum(x.filter(function(e){return!e.disabled})).call(u)}var T=d3.select(this),N=this,P=(f||parseInt(T.style("width"))||960)-a.left-a.right,H=(l||parseInt(T.style("height"))||400)-a.top-a.bottom;D.update=function(){D(e)},D.container=this,L.disabled=x.map(function(e){return!!e.disabled});if(!x||!x.length||!x.filter(function(e){return e.values.length}).length){var B=T.selectAll(".nv-noData").data([k]);return B.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),B.attr("x",a.left+P/2).attr("y",a.top+H/2).text(function(e){return e}),D}T.selectAll(".nv-noData").remove(),A=A||h,O=O||p;var j=T.selectAll("g.nv-wrap.nv-scatterChart").data([x]),F=j.enter().append("g").attr("class","nvd3 nv-wrap nv-scatterChart nv-chart-"+t.id()),I=F.append("g"),q=j.select("g");I.append("rect").attr("class","nvd3 nv-background"),I.append("g").attr("class","nv-x nv-axis"),I.append("g").attr("class","nv-y nv-axis"),I.append("g").attr("class","nv-scatterWrap"),I.append("g").attr("class","nv-distWrap"),I.append("g").attr("class","nv-legendWrap"),I.append("g").attr("class","nv-controlsWrap"),y&&(i.width(P/2),j.select(".nv-legendWrap").datum(x).call(i),a.top!=i.height()&&(a.top=i.height(),H=(l||parseInt(T.style("height"))||400)-a.top-a.bottom),j.select(".nv-legendWrap").attr("transform","translate("+P/2+","+ -a.top+")")),b&&(s.width(180).color(["#444"]),q.select(".nv-controlsWrap").datum(_).attr("transform","translate(0,"+ -a.top+")").call(s)),j.attr("transform","translate("+a.left+","+a.top+")"),t.width(P).height(H).color(x.map(function(e,t){return e.color||c(e,t)}).filter(function(e,t){return!x[t].disabled})),j.select(".nv-scatterWrap").datum(x.filter(function(e){return!e.disabled})).call(t);if(d){var R=h.domain()[1]-h.domain()[0];h.domain([h.domain()[0]-d*R,h.domain()[1]+d*R])}if(v){var U=p.domain()[1]-p.domain()[0];p.domain([p.domain()[0]-v*U,p.domain()[1]+v*U])}n.scale(h).ticks(n.ticks()&&n.ticks().length?n.ticks():P/100).tickSize(-H,0),q.select(".nv-x.nv-axis").attr("transform","translate(0,"+p.range()[0]+")").call(n),r.scale(p).ticks(r.ticks()&&r.ticks().length?r.ticks():H/36).tickSize(-P,0),q.select(".nv-y.nv-axis").call(r),m&&(o.getData(t.x()).scale(h).width(P).color(x.map(function(e,t){return e.color||c(e,t)}).filter(function(e,t){return!x[t].disabled})),I.select(".nv-distWrap").append("g").attr("class","nv-distributionX"),q.select(".nv-distributionX").attr("transform","translate(0,"+p.range()[0]+")").datum(x.filter(function(e){return!e.disabled})).call(o)),g&&(u.getData(t.y()).scale(p).width(H).color(x.map(function(e,t){return e.color||c(e,t)}).filter(function(e,t){return!x[t].disabled})),I.select(".nv-distWrap").append("g").attr("class","nv-distributionY"),q.select(".nv-distributionY").attr("transform","translate(-"+u.size()+",0)").datum(x.filter(function(e){return!e.disabled})).call(u)),d3.fisheye&&(q.select(".nv-background").attr("width",P).attr("height",H),q.select(".nv-background").on("mousemove",z),q.select(".nv-background").on("click",function(){E=!E}),t.dispatch.on("elementClick.freezeFisheye",function(){E=!E})),s.dispatch.on("legendClick",function(i,s){i.disabled=!i.disabled,w=i.disabled?0:2.5,q.select(".nv-background").style("pointer-events",i.disabled?"none":"all"),q.select(".nv-point-paths").style("pointer-events",i.disabled?"all":"none"),i.disabled?(h.distortion(w).focus(0),p.distortion(w).focus(0),q.select(".nv-scatterWrap").call(t),q.select(".nv-x.nv-axis").call(n),q.select(".nv-y.nv-axis").call(r)):E=!1,D(e)}),i.dispatch.on("legendClick",function(t,n,r){t.disabled=!t.disabled,x.filter(function(e){return!e.disabled}).length||x.map(function(e){return e.disabled=!1,j.selectAll(".nv-series").classed("disabled",!1),e}),L.disabled=x.map(function(e){return!!e.disabled}),C.stateChange(L),D(e)}),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]-H),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],C.tooltipShow(e)}),C.on("tooltipShow",function(e){S&&M(e,N.parentNode)}),C.on("changeState",function(t){typeof t.disabled!="undefined"&&(x.forEach(function(e,n){e.disabled=t.disabled[n]}),L.disabled=t.disabled),e.call(D)}),A=h.copy(),O=p.copy()}),D}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=!!d3.fisheye,w=0,E=!1,S=!0,x=function(e,t,n){return""+t+""},T=function(e,t,n){return""+n+""},N=null,C=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),k="No Data Available.";t.xScale(h).yScale(p),n.orient("bottom").tickPadding(10),r.orient("left").tickPadding(10),o.axis("x"),u.axis("y");var L={},A,O,M=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));x!=null&&e.tooltip.show([f,l],x(i.series.key,v,m,i,D),"n",1,s,"x-nvtooltip"),T!=null&&e.tooltip.show([c,d],T(i.series.key,v,m,i,D),"e",1,s,"y-nvtooltip"),N!=null&&e.tooltip.show([o,u],N(i.series.key,v,m,i,D),i.value<0?"n":"s",null,s)},_=[{key:"Magnify",disabled:!0}];return t.dispatch.on("elementMouseout.tooltip",function(e){C.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())}),C.on("tooltipHide",function(){S&&e.tooltip.cleanup()}),D.dispatch=C,D.scatter=t,D.legend=i,D.controls=s,D.xAxis=n,D.yAxis=r,D.distX=o,D.distY=u,d3.rebind(D,t,"id","interactive","pointActive","x","y","shape","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","sizeRange","forceX","forceY","forceSize","clipVoronoi","clipRadius","useVoronoi"),D.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,D):a},D.width=function(e){return arguments.length?(f=e,D):f},D.height=function(e){return arguments.length?(l=e,D):l},D.color=function(t){return arguments.length?(c=e.utils.getColor(t),i.color(c),o.color(c),u.color(c),D):c},D.showDistX=function(e){return arguments.length?(m=e,D):m},D.showDistY=function(e){return arguments.length?(g=e,D):g},D.showControls=function(e){return arguments.length?(b=e,D):b},D.showLegend=function(e){return arguments.length?(y=e,D):y},D.fisheye=function(e){return arguments.length?(w=e,D):w},D.xPadding=function(e){return arguments.length?(d=e,D):d},D.yPadding=function(e){return arguments.length?(v=e,D):v},D.tooltips=function(e){return arguments.length?(S=e,D):S},D.tooltipContent=function(e){return arguments.length?(N=e,D):N},D.tooltipXContent=function(e){return arguments.length?(x=e,D):x},D.tooltipYContent=function(e){return arguments.length?(T=e,D):T},D.state=function(e){return arguments.length?(L=e,D):L},D.noData=function(e){return arguments.length?(k=e,D):k},D},e.models.scatterPlusLineChart=function(){function M(e){return e.each(function(E){function R(){if(b)return F.select(".nv-point-paths").style("pointer-events","all"),!1;F.select(".nv-point-paths").style("pointer-events","none");var e=d3.mouse(this);h.distortion(y).focus(e[0]),p.distortion(y).focus(e[1]),F.select(".nv-scatterWrap").datum(E.filter(function(e){return!e.disabled})).call(t),F.select(".nv-x.nv-axis").call(n),F.select(".nv-y.nv-axis").call(r),F.select(".nv-distributionX").datum(E.filter(function(e){return!e.disabled})).call(o),F.select(".nv-distributionY").datum(E.filter(function(e){return!e.disabled})).call(u)}var S=d3.select(this),x=this,_=(f||parseInt(S.style("width"))||960)-a.left-a.right,D=(l||parseInt(S.style("height"))||400)-a.top-a.bottom;M.update=function(){M(e)},M.container=this,C.disabled=E.map(function(e){return!!e.disabled});if(!E||!E.length||!E.filter(function(e){return e.values.length}).length){var P=S.selectAll(".nv-noData").data([N]);return P.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),P.attr("x",a.left+_/2).attr("y",a.top+D/2).text(function(e){return e}),M}S.selectAll(".nv-noData").remove(),h=t.xScale(),p=t.yScale(),k=k||h,L=L||p;var H=S.selectAll("g.nv-wrap.nv-scatterChart").data([E]),B=H.enter().append("g").attr("class","nvd3 nv-wrap nv-scatterChart nv-chart-"+t.id()),j=B.append("g"),F=H.select("g");j.append("rect").attr("class","nvd3 nv-background"),j.append("g").attr("class","nv-x nv-axis"),j.append("g").attr("class","nv-y nv-axis"),j.append("g").attr("class","nv-scatterWrap"),j.append("g").attr("class","nv-regressionLinesWrap"),j.append("g").attr("class","nv-distWrap"),j.append("g").attr("class","nv-legendWrap"),j.append("g").attr("class","nv-controlsWrap"),H.attr("transform","translate("+a.left+","+a.top+")"),m&&(i.width(_/2),H.select(".nv-legendWrap").datum(E).call(i),a.top!=i.height()&&(a.top=i.height(),D=(l||parseInt(S.style("height"))||400)-a.top-a.bottom),H.select(".nv-legendWrap").attr("transform","translate("+_/2+","+ -a.top+")")),g&&(s.width(180).color(["#444"]),F.select(".nv-controlsWrap").datum(O).attr("transform","translate(0,"+ -a.top+")").call(s)),t.width(_).height(D).color(E.map(function(e,t){return e.color||c(e,t)}).filter(function(e,t){return!E[t].disabled})),H.select(".nv-scatterWrap").datum(E.filter(function(e){return!e.disabled})).call(t),H.select(".nv-regressionLinesWrap").attr("clip-path","url(#nv-edge-clip-"+t.id()+")");var I=H.select(".nv-regressionLinesWrap").selectAll(".nv-regLines").data(function(e){return e}),q=I.enter().append("g").attr("class","nv-regLines").append("line").attr("class","nv-regLine").style("stroke-opacity",0);I.selectAll(".nv-regLines line").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}),n.scale(h).ticks(n.ticks()?n.ticks():_/100).tickSize(-D,0),F.select(".nv-x.nv-axis").attr("transform","translate(0,"+p.range()[0]+")").call(n),r.scale(p).ticks(r.ticks()?r.ticks():D/36).tickSize(-_,0),F.select(".nv-y.nv-axis").call(r),d&&(o.getData(t.x()).scale(h).width(_).color(E.map(function(e,t){return e.color||c(e,t)}).filter(function(e,t){return!E[t].disabled})),j.select(".nv-distWrap").append("g").attr("class","nv-distributionX"),F.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(D).color(E.map(function(e,t){return e.color||c(e,t)}).filter(function(e,t){return!E[t].disabled})),j.select(".nv-distWrap").append("g").attr("class","nv-distributionY"),F.select(".nv-distributionY").attr("transform","translate(-"+u.size()+",0)").datum(E.filter(function(e){return!e.disabled})).call(u)),d3.fisheye&&(F.select(".nv-background").attr("width",_).attr("height",D),F.select(".nv-background").on("mousemove",R),F.select(".nv-background").on("click",function(){b=!b}),t.dispatch.on("elementClick.freezeFisheye",function(){b=!b})),s.dispatch.on("legendClick",function(i,s){i.disabled=!i.disabled,y=i.disabled?0:2.5,F.select(".nv-background").style("pointer-events",i.disabled?"none":"all"),F.select(".nv-point-paths").style("pointer-events",i.disabled?"all":"none"),i.disabled?(h.distortion(y).focus(0),p.distortion(y).focus(0),F.select(".nv-scatterWrap").call(t),F.select(".nv-x.nv-axis").call(n),F.select(".nv-y.nv-axis").call(r)):b=!1,M(e)}),i.dispatch.on("legendClick",function(t,n,r){t.disabled=!t.disabled,E.filter(function(e){return!e.disabled}).length||E.map(function(e){return e.disabled=!1,H.selectAll(".nv-series").classed("disabled",!1),e}),C.disabled=E.map(function(e){return!!e.disabled}),T.stateChange(C),M(e)}),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]-D),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],T.tooltipShow(e)}),T.on("tooltipShow",function(e){w&&A(e,x.parentNode)}),T.on("changeState",function(t){typeof t.disabled!="undefined"&&(E.forEach(function(e,n){e.disabled=t.disabled[n]}),C.disabled=t.disabled),e.call(M)}),k=h.copy(),L=p.copy()}),M}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=!!d3.fisheye,y=0,b=!1,w=!0,E=function(e,t,n){return""+t+""},S=function(e,t,n){return""+n+""},x=function(e,t,n,r){return"

"+e+"

"+"

"+r+"

"},T=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),N="No Data Available.";t.xScale(h).yScale(p),n.orient("bottom").tickPadding(10),r.orient("left").tickPadding(10),o.axis("x"),u.axis("y");var C={},k,L,A=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));E!=null&&e.tooltip.show([f,l],E(i.series.key,v,m,i,M),"n",1,s,"x-nvtooltip"),S!=null&&e.tooltip.show([c,d],S(i.series.key,v,m,i,M),"e",1,s,"y-nvtooltip"),x!=null&&e.tooltip.show([o,u],x(i.series.key,v,m,i.point.tooltip,i,M),i.value<0?"n":"s",null,s)},O=[{key:"Magnify",disabled:!0}];return t.dispatch.on("elementMouseout.tooltip",function(e){T.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())}),T.on("tooltipHide",function(){w&&e.tooltip.cleanup()}),M.dispatch=T,M.scatter=t,M.legend=i,M.controls=s,M.xAxis=n,M.yAxis=r,M.distX=o,M.distY=u,d3.rebind(M,t,"id","interactive","pointActive","x","y","shape","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","sizeRange","forceX","forceY","forceSize","clipVoronoi","clipRadius","useVoronoi"),M.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,M):a},M.width=function(e){return arguments.length?(f=e,M):f},M.height=function(e){return arguments.length?(l=e,M):l},M.color=function(t){return arguments.length?(c=e.utils.getColor(t),i.color(c),o.color(c),u.color(c),M):c},M.showDistX=function(e){return arguments.length?(d=e,M):d},M.showDistY=function(e){return arguments.length?(v=e,M):v},M.showControls=function(e){return arguments.length?(g=e,M):g},M.showLegend=function(e){return arguments.length?(m=e,M):m},M.fisheye=function(e){return arguments.length?(y=e,M):y},M.tooltips=function(e){return arguments.length?(w=e,M):w},M.tooltipContent=function(e){return arguments.length?(x=e,M):x},M.tooltipXContent=function(e){return arguments.length?(E=e,M):E},M.tooltipYContent=function(e){return arguments.length?(S=e,M):S},M.state=function(e){return arguments.length?(C=e,M):C},M.noData=function(e){return arguments.length?(N=e,M):N},M},e.models.sparkline=function(){function h(e){return e.each(function(e){var i=n-t.left-t.right,h=r-t.top-t.bottom,p=d3.select(this);s.domain(l||d3.extent(e,u)).range([0,i]),o.domain(c||d3.extent(e,a)).range([h,0]);var d=p.selectAll("g.nv-wrap.nv-sparkline").data([e]),v=d.enter().append("g").attr("class","nvd3 nv-wrap nv-sparkline"),m=v.append("g"),g=d.select("g");d.attr("transform","translate("+t.left+","+t.top+")");var b=d.selectAll("path").data(function(e){return[e]});b.enter().append("path"),b.exit().remove(),b.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 w=d.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})});w.enter().append("circle"),w.exit().remove(),w.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"})}),h}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;return h.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,h):t},h.width=function(e){return arguments.length?(n=e,h):n},h.height=function(e){return arguments.length?(r=e,h):r},h.x=function(e){return arguments.length?(u=d3.functor(e),h):u},h.y=function(e){return arguments.length?(a=d3.functor(e),h):a},h.xScale=function(e){return arguments.length?(s=e,h):s},h.yScale=function(e){return arguments.length?(o=e,h):o},h.xDomain=function(e){return arguments.length?(l=e,h):l},h.yDomain=function(e){return arguments.length?(c=e,h):c},h.animate=function(e){return arguments.length?(i=e,h):i},h.color=function(t){return arguments.length?(f=e.utils.getColor(t),h):f},h},e.models.sparklinePlus=function(){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;s"+e+""+"

"+n+" on "+t+"

"},d,v,m=d3.format(",.2f"),g={style:t.style()},y="No Data Available.",b=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),w=250;n.orient("bottom").tickPadding(7),r.orient("left"),t.scatter.pointActive(function(e){return!!Math.round(t.y()(e)*100)});var E=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,S);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]+o.left,e.pos[1]+o.top],b.tooltipShow(e)}),t.dispatch.on("tooltipHide",function(e){b.tooltipHide(e)}),b.on("tooltipHide",function(){h&&e.tooltip.cleanup()}),S.dispatch=b,S.stacked=t,S.legend=i,S.controls=s,S.xAxis=n,S.yAxis=r,d3.rebind(S,t,"x","y","size","xScale","yScale","xDomain","yDomain","sizeDomain","interactive","offset","order","style","clipEdge","forceX","forceY","forceSize","interpolate"),S.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,S):o},S.width=function(e){return arguments.length?(u=e,S):getWidth},S.height=function(e){return arguments.length?(a=e,S):getHeight},S.color=function(n){return arguments.length?(f=e.utils.getColor(n),i.color(f),t.color(f),S):f},S.showControls=function(e){return arguments.length?(l=e,S):l},S.showLegend=function(e){return arguments.length?(c=e,S):c},S.tooltip=function(e){return arguments.length?(p=e,S):p},S.tooltips=function(e){return arguments.length?(h=e,S):h},S.tooltipContent=function(e){return arguments.length?(p=e,S):p},S.state=function(e){return arguments.length?(g=e,S):g},S.noData=function(e){return arguments.length?(y=e,S):y},r.setTickFormat=r.tickFormat,r.tickFormat=function(e){return arguments.length?(m=e,r):m},S}})(); \ No newline at end of file diff --git a/src/models/cumulativeLineChart.js b/src/models/cumulativeLineChart.js index 2f311d3..85e2d37 100644 --- a/src/models/cumulativeLineChart.js +++ b/src/models/cumulativeLineChart.js @@ -28,6 +28,7 @@ nv.models.cumulativeLineChart = function() { , y //can be accessed via chart.yScale() , id = lines.id() , state = { index: 0, rescaleY: rescaleY } + , defaultState = null , noData = 'No Data Available.' , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') ; @@ -108,6 +109,17 @@ nv.models.cumulativeLineChart = function() { //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) @@ -567,6 +579,12 @@ nv.models.cumulativeLineChart = function() { return chart; }; + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; diff --git a/src/models/lineChart.js b/src/models/lineChart.js index 8e8c319..f72012c 100644 --- a/src/models/lineChart.js +++ b/src/models/lineChart.js @@ -25,6 +25,7 @@ nv.models.lineChart = function() { , x , y , state = {} + , defaultState = null , noData = 'No Data Available.' , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') ; @@ -87,6 +88,16 @@ nv.models.lineChart = function() { //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]; + } + } //------------------------------------------------------------ // Display noData message if there's nothing to show. @@ -349,6 +360,12 @@ nv.models.lineChart = function() { return chart; }; + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; diff --git a/src/models/linePlusBarChart.js b/src/models/linePlusBarChart.js index 5a90ae0..91f1db7 100644 --- a/src/models/linePlusBarChart.js +++ b/src/models/linePlusBarChart.js @@ -28,6 +28,8 @@ nv.models.linePlusBarChart = function() { , x , y1 , y2 + , state = {} + , defaultState = null , noData = "No Data Available." , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') ; @@ -58,17 +60,16 @@ nv.models.linePlusBarChart = function() { // Private Variables //------------------------------------------------------------ - var state = {}, - 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 = (e.series.bar ? y1Axis : y2Axis).tickFormat()(lines.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); + 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 = (e.series.bar ? y1Axis : y2Axis).tickFormat()(lines.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); - } - ; + nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); + } + ; //------------------------------------------------------------ @@ -90,6 +91,16 @@ nv.models.linePlusBarChart = function() { //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]; + } + } //------------------------------------------------------------ // Display No Data message if there's nothing to show. @@ -200,7 +211,7 @@ nv.models.linePlusBarChart = function() { .datum(dataBars.length ? dataBars : [{values:[]}]) var linesWrap = g.select('.nv-linesWrap') - .datum(!dataLines[0].disabled ? dataLines : [{values:[]}] ); + .datum(dataLines[0] && !dataLines[0].disabled ? dataLines : [{values:[]}] ); //.datum(!dataLines[0].disabled ? dataLines : [{values:dataLines[0].values.map(function(d) { return [d[0], null] }) }] ); d3.transition(barsWrap).call(bars); @@ -412,6 +423,12 @@ nv.models.linePlusBarChart = function() { return chart; }; + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; diff --git a/src/models/linePlusBarWithFocusChart.js b/src/models/linePlusBarWithFocusChart.js index 277f86f..0199bfb 100644 --- a/src/models/linePlusBarWithFocusChart.js +++ b/src/models/linePlusBarWithFocusChart.js @@ -424,6 +424,7 @@ nv.models.linePlusBarWithFocusChart = function() { return d.color || color(d, i); }).filter(function(d,i) { return !data[i].disabled && data[i].bar })); + lines .width(availableWidth) .height(availableHeight1) @@ -650,6 +651,13 @@ nv.models.linePlusBarWithFocusChart = function() { return chart; }; + chart.brushExtent = function(_) { + if (!arguments.length) return brushExtent; + brushExtent = _; + return chart; + }; + + //============================================================ diff --git a/src/models/multiBar.js b/src/models/multiBar.js index 7267af8..fac6703 100644 --- a/src/models/multiBar.js +++ b/src/models/multiBar.js @@ -17,6 +17,7 @@ nv.models.multiBar = function() { , clipEdge = true , stacked = false , color = nv.utils.defaultColor() + , hideable = false , barColor = null // adding the ability to set the color for each rather than the whole group , disabled // used in conjunction with barColor to communicate from multiBarHorizontalChart what series are disabled , delay = 1200 @@ -44,12 +45,22 @@ nv.models.multiBar = function() { availableHeight = height - margin.top - margin.bottom, container = d3.select(this); + if(hideable && data.length) hideable = [{ + values: data[0].values.map(function(d) { + return { + x: d.x, + y: 0, + series: d.series, + size: 0.01 + };} + )}]; + if (stacked) data = d3.layout.stack() .offset('zero') .values(function(d){ return d.values }) .y(getY) - (data); + (!data.length && hideable ? hideable : data); //add series index to each data point for reference @@ -170,7 +181,7 @@ nv.models.multiBar = function() { var bars = groups.selectAll('rect.nv-bar') - .data(function(d) { return d.values }); + .data(function(d) { return (hideable && !data.length) ? hideable.values : d.values }); bars.exit().remove(); @@ -403,6 +414,12 @@ nv.models.multiBar = function() { return chart; }; + chart.hideable = function(_) { + if (!arguments.length) return hideable; + hideable = _; + return chart; + }; + chart.delay = function(_) { if (!arguments.length) return delay; delay = _; diff --git a/src/models/multiBarChart.js b/src/models/multiBarChart.js index 12d25f0..66cc5d2 100644 --- a/src/models/multiBarChart.js +++ b/src/models/multiBarChart.js @@ -28,6 +28,7 @@ nv.models.multiBarChart = function() { , x //can be accessed via chart.xScale() , y //can be accessed via chart.yScale() , state = { stacked: false } + , defaultState = null , noData = "No Data Available." , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , controlWidth = function() { return showControls ? 180 : 0 } @@ -84,7 +85,16 @@ nv.models.multiBarChart = function() { //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]; + } + } //------------------------------------------------------------ // Display noData message if there's nothing to show. @@ -436,6 +446,12 @@ nv.models.multiBarChart = function() { return chart; }; + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; diff --git a/src/models/multiBarHorizontalChart.js b/src/models/multiBarHorizontalChart.js index 4637767..1d9ff3f 100644 --- a/src/models/multiBarHorizontalChart.js +++ b/src/models/multiBarHorizontalChart.js @@ -27,6 +27,7 @@ nv.models.multiBarHorizontalChart = function() { , x //can be accessed via chart.xScale() , y //can be accessed via chart.yScale() , state = { stacked: stacked } + , defaultState = null , noData = 'No Data Available.' , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , controlWidth = function() { return showControls ? 180 : 0 } @@ -83,6 +84,16 @@ nv.models.multiBarHorizontalChart = function() { //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]; + } + } //------------------------------------------------------------ // Display No Data message if there's nothing to show. @@ -406,6 +417,12 @@ nv.models.multiBarHorizontalChart = function() { return chart; }; + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; diff --git a/src/models/pieChart.js b/src/models/pieChart.js index b87652c..c93498d 100644 --- a/src/models/pieChart.js +++ b/src/models/pieChart.js @@ -19,6 +19,7 @@ nv.models.pieChart = function() { '

' + y + '

' } , state = {} + , defaultState = null , noData = "No Data Available." , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') ; @@ -59,6 +60,17 @@ nv.models.pieChart = function() { //set state.disabled state.disabled = data[0].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]; + } + } + //------------------------------------------------------------ // Display No Data message if there's nothing to show. @@ -271,6 +283,12 @@ nv.models.pieChart = function() { return chart; }; + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; diff --git a/src/models/scatterChart.js b/src/models/scatterChart.js index 825450b..b41e5c2 100644 --- a/src/models/scatterChart.js +++ b/src/models/scatterChart.js @@ -33,6 +33,8 @@ nv.models.scatterChart = function() { , tooltipY = function(key, x, y) { return '' + y + '' } //, tooltip = function(key, x, y) { return '

' + key + '

' } , tooltip = null + , state = {} + , defaultState = null , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , noData = "No Data Available." ; @@ -63,8 +65,7 @@ nv.models.scatterChart = function() { // Private Variables //------------------------------------------------------------ - var state = {}, - x0, y0; + var x0, y0; var showTooltip = function(e, offsetElement) { //TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?) @@ -109,6 +110,16 @@ nv.models.scatterChart = function() { //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]; + } + } //------------------------------------------------------------ // Display noData message if there's nothing to show. @@ -149,10 +160,10 @@ nv.models.scatterChart = function() { var wrap = container.selectAll('g.nv-wrap.nv-scatterChart').data([data]); var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-scatterChart nv-chart-' + scatter.id()); var gEnter = wrapEnter.append('g'); - var g = wrap.select('g') + var g = wrap.select('g'); // background for pointer events - gEnter.append('rect').attr('class', 'nvd3 nv-background') + gEnter.append('rect').attr('class', 'nvd3 nv-background'); gEnter.append('g').attr('class', 'nv-x nv-axis'); gEnter.append('g').attr('class', 'nv-y nv-axis'); @@ -565,6 +576,12 @@ nv.models.scatterChart = function() { return chart; }; + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; diff --git a/src/models/scatterPlusLineChart.js b/src/models/scatterPlusLineChart.js index c8a8b20..93a7911 100644 --- a/src/models/scatterPlusLineChart.js +++ b/src/models/scatterPlusLineChart.js @@ -32,6 +32,8 @@ nv.models.scatterPlusLineChart = function() { , tooltip = function(key, x, y, date) { return '

' + key + '

' + '

' + date + '

' } //, tooltip = null + , state = {} + , defaultState = null , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , noData = "No Data Available." ; @@ -62,8 +64,7 @@ nv.models.scatterPlusLineChart = function() { // Private Variables //------------------------------------------------------------ - var state = {}, - x0, y0; + var x0, y0; var showTooltip = function(e, offsetElement) { //TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?) @@ -108,6 +109,16 @@ nv.models.scatterPlusLineChart = function() { //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]; + } + } //------------------------------------------------------------ // Display noData message if there's nothing to show. @@ -567,6 +578,12 @@ nv.models.scatterPlusLineChart = function() { return chart; }; + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; diff --git a/src/models/stackedAreaChart.js b/src/models/stackedAreaChart.js index c386cd8..91cfff7 100644 --- a/src/models/stackedAreaChart.js +++ b/src/models/stackedAreaChart.js @@ -27,6 +27,7 @@ nv.models.stackedAreaChart = function() { , y //can be accessed via chart.yScale() , yAxisTickFormat = d3.format(',.2f') , state = { style: stacked.style() } + , defaultState = null , noData = 'No Data Available.' , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') , controlWidth = 250 @@ -82,6 +83,16 @@ nv.models.stackedAreaChart = function() { //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]; + } + } //------------------------------------------------------------ // Display No Data message if there's nothing to show. @@ -441,6 +452,12 @@ nv.models.stackedAreaChart = function() { return chart; }; + chart.defaultState = function(_) { + if (!arguments.length) return defaultState; + defaultState = _; + return chart; + }; + chart.noData = function(_) { if (!arguments.length) return noData; noData = _; @@ -448,6 +465,7 @@ nv.models.stackedAreaChart = function() { }; yAxis.setTickFormat = yAxis.tickFormat; + yAxis.tickFormat = function(_) { if (!arguments.length) return yAxisTickFormat; yAxisTickFormat = _;