ZingChart-jQuery icon indicating copy to clipboard operation
ZingChart-jQuery copied to clipboard

consider 'log' progression for scale-y

Open splendido opened this issue 9 years ago • 1 comments

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:

logaritmictrendline

As a side note, it seems progression: "log" is mapped to the Math.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 use Math.pow(10, x) in place of Math.exp to compensate the computed range result.

splendido avatar Jan 26 '16 12:01 splendido

just for completeness: this is the result obtained with the current code:

logarithmictrendline_old

splendido avatar Jan 26 '16 12:01 splendido