Skip to content

Commit

Permalink
Fixed: Scatter plot trend not showing...
Browse files Browse the repository at this point in the history
...when slope or intercept is 0
  • Loading branch information
Cristian Traistaru committed Oct 20, 2015
1 parent ab3d86b commit 00bfd0d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugins/plugin_nvd3scatter.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
var regressionResult = ss.linearRegression( this.data[ index ].values.map( function( v ) { return [ v.x , v.y ]; } ) );
this.data[ index ].slope = regressionResult.m;
this.data[ index ].intercept = regressionResult.b;

// HACK: Avoid weak falsy tests performed by the library
if( this.data[ index ].slope === 0 ) this.data[ index ].slope += 0.00000001;
if( this.data[ index ].intercept === 0 ) this.data[ index ].intercept += 0.00000001;
}

this.chart.update();
Expand Down

0 comments on commit 00bfd0d

Please sign in to comment.