[Libreoffice-commits] core.git: chart2/source

Laurent Balland-Poirier laurent.balland-poirier at laposte.net
Wed Oct 7 03:48:25 PDT 2015


 chart2/source/tools/PolynomialRegressionCurveCalculator.cxx |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit 432ca6166976bd093d1c3921aa72d9b72865eeeb
Author: Laurent Balland-Poirier <laurent.balland-poirier at 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 <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at 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)
         {


More information about the Libreoffice-commits mailing list