diff --git a/nv.d3.js b/nv.d3.js index ccd1241..29a8211 100644 --- a/nv.d3.js +++ b/nv.d3.js @@ -604,7 +604,8 @@ nv.models.line = function() { var vertices = d3.merge(data.map(function(line, lineIndex) { return line.values.map(function(point, pointIndex) { - return [x(getX(point)), y(getY(point)), lineIndex, pointIndex]; //inject series and point index for reference into voronoi + //return [x(getX(point)), y(getY(point)), lineIndex, pointIndex]; //inject series and point index for reference into voronoi + return [x(getX(point)) * (Math.random() / 1e12 + 1) , y(getY(point)) * (Math.random() / 1e12 + 1), lineIndex, pointIndex]; //temp hack to add noise untill I think of a better way so there are no duplicates }) }) ); @@ -835,12 +836,13 @@ nv.models.lineWithFocus = function() { .on('brush', onBrush); - var wrap, gEnter, g, focus, focusLines, contextWrap, focusWrap, contextLines; //brought all variables to this scope for use within function... is this a bad idea? + var wrap, gEnter, g, focus, focusLines, contextWrap, focusWrap, contextLines; //brought all variables to this scope for use within brush function... is this a bad idea? + var seriesData; //Temporarily bringing this data to this scope.... may be bad idea (same with above).. may need to rethink brushing function chart(selection) { selection.each(function(data) { - var seriesData = data.filter(function(d) { return !d.disabled }) + seriesData = data.filter(function(d) { return !d.disabled }) .map(function(d) { return d.values }); x2 .domain(d3.extent(d3.merge(seriesData), getX )) @@ -1039,13 +1041,26 @@ nv.models.lineWithFocus = function() { // ********** FUNCTIONS ********** function onBrush() { + var yDomain = brush.empty() ? y2.domain() : d3.extent(d3.merge(seriesData).filter(function(d) { + return getX(d) >= brush.extent()[0] && getX(d) <= brush.extent()[1]; + }), getY); + + if (typeof yDomain[0] == 'undefined') yDomain = y2.domain(); + + x.domain(brush.empty() ? x2.domain() : brush.extent()); + y.domain(yDomain); + //y.domain(brush.empty() ? y2.domain() : d3.extent(d3.merge(seriesData).filter(function(d) { + //return getX(d) >= brush.extent()[0] && getX(d) <= brush.extent()[1]; + //}), getY) || y2.domain() ); focus.xDomain(x.domain()); + focus.yDomain(y.domain()); focusLines.call(focus) wrap.select('.x.axis').call(xAxis); + wrap.select('.y.axis').call(yAxis); } diff --git a/nv.d3.min.js b/nv.d3.min.js index 7c6d7d7..28747bb 100644 --- a/nv.d3.min.js +++ b/nv.d3.min.js @@ -1,3 +1,3 @@ /***** * A no frills tooltip implementation. - *****/(function(a){var b=window.nvtooltip={};b.show=function(b,c,d,e){var f=a('