summaryrefslogtreecommitdiff
path: root/chart2/source/inc
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2013-05-27 08:02:37 +0200
committerTomaž Vajngerl <quikee@gmail.com>2013-07-03 21:46:39 +0200
commite6a0cc2d6cb37bf4e04861173c7e55b307513778 (patch)
tree3569da62ea24a3fd4dce7216751692b1a5e79306 /chart2/source/inc
parentc63b74d22d360893bb9e1200f59099ffb7943705 (diff)
fdo#35712 polynomial and moving average regression lines
- added polynomial and moving average to the dialog - implemented moving average and polynomal RegressionCurveCalculator - added icon for polynomial regression curve - prepare icon for moving average regression curve - degree parameter for polynomial regression curve - period parameter for moving average regression curve - limit the curve to max and min x value - added extrapolation Change-Id: I4ebb8dc23a3aff285b999e115fdda20ab11910a5
Diffstat (limited to 'chart2/source/inc')
-rw-r--r--chart2/source/inc/MovingAverageRegressionCurveCalculator.hxx68
-rw-r--r--chart2/source/inc/PolynomialRegressionCurveCalculator.hxx69
-rw-r--r--chart2/source/inc/RegressionCurveCalculator.hxx9
-rw-r--r--chart2/source/inc/RegressionCurveHelper.hxx2
-rw-r--r--chart2/source/inc/Strings.hrc2
-rw-r--r--chart2/source/inc/chartview/ChartSfxItemIds.hxx18
6 files changed, 162 insertions, 6 deletions
diff --git a/chart2/source/inc/MovingAverageRegressionCurveCalculator.hxx b/chart2/source/inc/MovingAverageRegressionCurveCalculator.hxx
new file mode 100644
index 000000000000..54c5d644148f
--- /dev/null
+++ b/chart2/source/inc/MovingAverageRegressionCurveCalculator.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef CHART2_MOVINGAVERAGEREGRESSIONCURVECALCULATOR_HXX
+#define CHART2_MOVINGAVERAGEREGRESSIONCURVECALCULATOR_HXX
+
+#include "RegressionCurveCalculator.hxx"
+#include <vector>
+
+namespace chart
+{
+
+class MovingAverageRegressionCurveCalculator : public RegressionCurveCalculator
+{
+public:
+ MovingAverageRegressionCurveCalculator();
+ virtual ~MovingAverageRegressionCurveCalculator();
+
+protected:
+ virtual OUString ImplGetRepresentation(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xNumFormatter,
+ ::sal_Int32 nNumberFormatKey ) const;
+
+private:
+ // ____ XRegressionCurveCalculator ____
+ virtual void SAL_CALL recalculateRegression(
+ const ::com::sun::star::uno::Sequence< double >& aXValues,
+ const ::com::sun::star::uno::Sequence< double >& aYValues )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual double SAL_CALL getCurveValue( double x )
+ throw (::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > SAL_CALL getCurveValues(
+ double min,
+ double max,
+ ::sal_Int32 nPointCount,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling >& xScalingX,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling >& xScalingY,
+ ::sal_Bool bMaySkipPointsInCalculation )
+ throw (::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException);
+
+ std::vector<double> aYList;
+ std::vector<double> aXList;
+};
+
+} // namespace chart
+
+#endif // CHART2_POLYNOMALREGRESSIONCURVECALCULATOR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/inc/PolynomialRegressionCurveCalculator.hxx b/chart2/source/inc/PolynomialRegressionCurveCalculator.hxx
new file mode 100644
index 000000000000..b3b38a9d7eb7
--- /dev/null
+++ b/chart2/source/inc/PolynomialRegressionCurveCalculator.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef CHART2_POLYNOMALREGRESSIONCURVECALCULATOR_HXX
+#define CHART2_POLYNOMALREGRESSIONCURVECALCULATOR_HXX
+
+#include "RegressionCurveCalculator.hxx"
+#include <vector>
+
+namespace chart
+{
+
+class PolynomialRegressionCurveCalculator : public RegressionCurveCalculator
+{
+public:
+ PolynomialRegressionCurveCalculator();
+ virtual ~PolynomialRegressionCurveCalculator();
+
+protected:
+ virtual OUString ImplGetRepresentation(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xNumFormatter,
+ ::sal_Int32 nNumberFormatKey ) const;
+
+private:
+ // ____ XRegressionCurveCalculator ____
+ virtual void SAL_CALL recalculateRegression(
+ const ::com::sun::star::uno::Sequence< double >& aXValues,
+ const ::com::sun::star::uno::Sequence< double >& aYValues )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual double SAL_CALL getCurveValue( double x )
+ throw (::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > SAL_CALL getCurveValues(
+ double min,
+ double max,
+ ::sal_Int32 nPointCount,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling >& xScalingX,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling >& xScalingY,
+ ::sal_Bool bMaySkipPointsInCalculation )
+ throw (::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException);
+
+ double m_fSlope;
+ double m_fIntercept;
+ std::vector<double> mResult;
+};
+
+} // namespace chart
+
+#endif // CHART2_POLYNOMALREGRESSIONCURVECALCULATOR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/inc/RegressionCurveCalculator.hxx b/chart2/source/inc/RegressionCurveCalculator.hxx
index 27af18bd5830..0829543dfb5d 100644
--- a/chart2/source/inc/RegressionCurveCalculator.hxx
+++ b/chart2/source/inc/RegressionCurveCalculator.hxx
@@ -51,7 +51,16 @@ protected:
double m_fCorrelationCoeffitient;
+ sal_Int32 mDegree;
+ double mIntercept;
+ sal_Int32 mPeriod;
+
// ____ XRegressionCurveCalculator ____
+ virtual void SAL_CALL setRegressionProperties(
+ sal_Int32 aDegree,
+ double aIntercept,
+ sal_Int32 aPeriod);
+
virtual void SAL_CALL recalculateRegression(
const ::com::sun::star::uno::Sequence< double >& aXValues,
const ::com::sun::star::uno::Sequence< double >& aYValues )
diff --git a/chart2/source/inc/RegressionCurveHelper.hxx b/chart2/source/inc/RegressionCurveHelper.hxx
index 743f0bd990d2..6adb73640443 100644
--- a/chart2/source/inc/RegressionCurveHelper.hxx
+++ b/chart2/source/inc/RegressionCurveHelper.hxx
@@ -92,6 +92,8 @@ public:
REGRESSION_TYPE_LOG,
REGRESSION_TYPE_EXP,
REGRESSION_TYPE_POWER,
+ REGRESSION_TYPE_POLYNOMIAL,
+ REGRESSION_TYPE_MOVING_AVERAGE,
REGRESSION_TYPE_MEAN_VALUE,
REGRESSION_TYPE_UNKNOWN
};
diff --git a/chart2/source/inc/Strings.hrc b/chart2/source/inc/Strings.hrc
index aecf40112265..8ce4c2968f2e 100644
--- a/chart2/source/inc/Strings.hrc
+++ b/chart2/source/inc/Strings.hrc
@@ -97,6 +97,8 @@
#define STR_REGRESSION_EXP (RID_APP_START + 137)
#define STR_REGRESSION_POWER (RID_APP_START + 138)
#define STR_REGRESSION_MEAN (RID_APP_START + 180)
+#define STR_REGRESSION_POLYNOMIAL (RID_APP_START + 300)
+#define STR_REGRESSION_MOVING_AVERAGE (RID_APP_START + 301)
//-----------------------------------------------------------------------------
//for scale tab page
diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx
index 8c6c6e12b6d2..62b1204f5a58 100644
--- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx
+++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx
@@ -162,12 +162,18 @@
#define SCHATTR_AXIS_FOR_ALL_SERIES (SCHATTR_MISC_START)
#define SCHATTR_MISC_END SCHATTR_AXIS_FOR_ALL_SERIES
-// regression curve equation
-#define SCHATTR_REGRESSION_START (SCHATTR_MISC_END + 1)
-#define SCHATTR_REGRESSION_TYPE SCHATTR_REGRESSION_START
-#define SCHATTR_REGRESSION_SHOW_EQUATION (SCHATTR_REGRESSION_START + 1)
-#define SCHATTR_REGRESSION_SHOW_COEFF (SCHATTR_REGRESSION_START + 2)
-#define SCHATTR_REGRESSION_END SCHATTR_REGRESSION_SHOW_COEFF
+// regression curve
+#define SCHATTR_REGRESSION_START (SCHATTR_MISC_END + 1)
+#define SCHATTR_REGRESSION_TYPE SCHATTR_REGRESSION_START
+#define SCHATTR_REGRESSION_SHOW_EQUATION (SCHATTR_REGRESSION_START + 1)
+#define SCHATTR_REGRESSION_SHOW_COEFF (SCHATTR_REGRESSION_START + 2)
+#define SCHATTR_REGRESSION_DEGREE (SCHATTR_REGRESSION_START + 3)
+#define SCHATTR_REGRESSION_PERIOD (SCHATTR_REGRESSION_START + 4)
+#define SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD (SCHATTR_REGRESSION_START + 5)
+#define SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD (SCHATTR_REGRESSION_START + 6)
+#define SCHATTR_REGRESSION_SET_INTERCEPT (SCHATTR_REGRESSION_START + 7)
+#define SCHATTR_REGRESSION_INTERCEPT_VALUE (SCHATTR_REGRESSION_START + 8)
+#define SCHATTR_REGRESSION_END SCHATTR_REGRESSION_INTERCEPT_VALUE
#define SCHATTR_END SCHATTR_REGRESSION_END