Skip to content

Commit

Permalink
Merge pull request #2002 from bernhard-42/master
Browse files Browse the repository at this point in the history
modify indexify to divide by v and not by v+1
  • Loading branch information
liquidpele authored Apr 7, 2017
2 parents f8b8c12 + fca4c2d commit 8ef8a45
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions src/models/cumulativeLineChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,18 +563,16 @@ nv.models.cumulativeLineChart = function() {
}
var v = indexifyYGetter(indexValue, idx);

//TODO: implement check below, and disable series if series loses 100% or more cause divide by 0 issue
if (v < -.95 && !noErrorCheck) {
//if a series loses more than 100%, calculations fail.. anything close can cause major distortion (but is mathematically correct till it hits 100)

// avoid divide by zero
if (Math.abs(v) < 0.00001 && !noErrorCheck) {
line.tempDisabled = true;
return line;
}

line.tempDisabled = false;

line.values = line.values.map(function(point, pointIndex) {
point.display = {'y': (indexifyYGetter(point, pointIndex) - v) / (1 + v) };
point.display = {'y': (indexifyYGetter(point, pointIndex) - v) / v };
return point;
});

Expand Down
2 changes: 1 addition & 1 deletion src/models/scatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ nv.models.scatter = function() {
});

// Setup Scales
var logScale = chart.yScale().name === d3.scale.log().name ? true : false;
var logScale = (typeof(chart.yScale().base) === "function"); // Only log scale has a method "base()"
// remap and flatten the data for use in calculating the scales' domains
var seriesData = (xDomain && yDomain && sizeDomain) ? [] : // if we know xDomain and yDomain and sizeDomain, no need to calculate.... if Size is constant remember to set sizeDomain to speed up performance
d3.merge(
Expand Down
2 changes: 1 addition & 1 deletion test/mocha/cumulative-line.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ describe 'NVD3', ->
sampleData1 = [
key: 'Series 1'
values: [
[-1,-1]
[0.000001, 0.000001]
[0,0]
[1,1]
[2,2]
Expand Down

0 comments on commit 8ef8a45

Please sign in to comment.