chart2/source/tools/PolynomialRegressionCurveCalculator.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
New commits: commit 432ca6166976bd093d1c3921aa72d9b72865eeeb Author: Laurent Balland-Poirier <laurent.balland-poir...@laposte.net> Date: Wed Sep 30 16:57:41 2015 +0200 Improve polynomial trend line equation Skip coefficient if its value is 1 (or near 1) Change-Id: I39a5630cc76250ded1ab22709522344d42fcc0e9 Reviewed-on: https://gerrit.libreoffice.org/19037 Reviewed-by: Noel Grandin <noelgran...@gmail.com> Tested-by: Noel Grandin <noelgran...@gmail.com> diff --git a/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx b/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx index 176e98b..1d26611 100644 --- a/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx +++ b/chart2/source/tools/PolynomialRegressionCurveCalculator.cxx @@ -238,6 +238,7 @@ OUString PolynomialRegressionCurveCalculator::ImplGetRepresentation( OUStringBuffer aBuf( "f(x) = "); sal_Int32 aLastIndex = mCoefficients.size() - 1; + bool bFindValue = false; for (sal_Int32 i = aLastIndex; i >= 0; i--) { double aValue = mCoefficients[i]; @@ -248,14 +249,17 @@ OUString PolynomialRegressionCurveCalculator::ImplGetRepresentation( else if (aValue < 0.0) { aBuf.append( " - " ); + aValue = - aValue; } else { - if (i != aLastIndex) + if ( bFindValue ) aBuf.append( " + " ); } + bFindValue = true; - aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, std::abs( aValue ) ) ); + if ( i == 0 || !rtl::math::approxEqual( aValue , 1.0 ) ) + aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, aValue ) ); if(i > 0) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits