consider 'log' progression for scale-y #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When computing linear regressions on logarithmic scales, log function should be applied to y values and the resulting range compensated accordingly.
The scatter example shown at http://www.zingchart.com/blog/2016/01/06/scatter-plot-examples/ is clearly not well represented by the trend line.
The proposed changes were tested with this fiddle: http://jsfiddle.net/yuu9hsyn/2/ (see lines 1459-1543)
and the result shows the computed trend line is now correct:
As a side note, it seems
progression: "log"
is mapped to theMath.log
function hence computing the natural logarithm of y values: in my humble opinion,Math.log10
would be a more appropriate choice since scientific plots usually make use of the base 10 logarithm in place of the natural one.In case you'll ever decide to switch to
Math.log10
make sure to modify the proposed changes to useMath.pow(10, x)
in place ofMath.exp
to compensate the computed range result.