summaryrefslogtreecommitdiff
path: root/chart2/source
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2021-02-11 07:53:15 +0100
committerSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2021-02-22 07:36:21 +0100
commit4141533a3fb984fbaefe87b15fceeda7f2082061 (patch)
tree46b7dc9e659033666cdef2275ec283dd2de8fd96 /chart2/source
parentc40ce0c542b46d45a00561a926953df2fe9a9762 (diff)
[API CHANGE] tdf#133423 Implement chart:regression-moving-type
Change-Id: Icb967367fbf12e5a1566b7f18ebe5e3d8a3534f0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110748 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Diffstat (limited to 'chart2/source')
-rw-r--r--chart2/source/controller/dialogs/ObjectNameProvider.cxx5
-rw-r--r--chart2/source/controller/dialogs/res_Trendline.cxx32
-rw-r--r--chart2/source/controller/dialogs/res_Trendline.hxx2
-rw-r--r--chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx13
-rw-r--r--chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx14
-rw-r--r--chart2/source/inc/LinearRegressionCurveCalculator.hxx3
-rw-r--r--chart2/source/inc/MovingAverageRegressionCurveCalculator.hxx4
-rw-r--r--chart2/source/inc/RegressionCurveCalculator.hxx4
-rw-r--r--chart2/source/inc/chartview/ChartSfxItemIds.hxx3
-rw-r--r--chart2/source/tools/LinearRegressionCurveCalculator.cxx6
-rw-r--r--chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx55
-rw-r--r--chart2/source/tools/RegressionCurveCalculator.cxx4
-rw-r--r--chart2/source/tools/RegressionCurveModel.cxx9
-rw-r--r--chart2/source/view/charttypes/VSeriesPlotter.cxx8
-rw-r--r--chart2/source/view/main/ChartItemPool.cxx2
15 files changed, 145 insertions, 19 deletions
diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx b/chart2/source/controller/dialogs/ObjectNameProvider.cxx
index 56dca8dde908..5eae3853add8 100644
--- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx
+++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx
@@ -41,6 +41,7 @@
#include <unotools/localedatawrapper.hxx>
#include <com/sun/star/chart2/XTitle.hpp>
+#include <com/sun/star/chart2/MovingAverageType.hpp>
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
#include <tools/diagnose_ex.h>
@@ -567,6 +568,7 @@ OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Refe
Reference< chart2::XRegressionCurveCalculator > xCalculator( xCurve->getCalculator(), uno::UNO_SET_THROW );
sal_Int32 aDegree = 2;
sal_Int32 aPeriod = 2;
+ sal_Int32 aMovingType = css::chart2::MovingAverageType::Prior;
bool bForceIntercept = false;
double aInterceptValue = 0.0;
OUString aXName ("x"), aYName ("f(x)");
@@ -579,6 +581,7 @@ OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Refe
{
xProperties->getPropertyValue( "PolynomialDegree") >>= aDegree;
xProperties->getPropertyValue( "MovingAveragePeriod") >>= aPeriod;
+ xProperties->getPropertyValue( "MovingAverageType") >>= aMovingType;
xProperties->getPropertyValue( "ForceIntercept") >>= bForceIntercept;
if (bForceIntercept)
xProperties->getPropertyValue( "InterceptValue") >>= aInterceptValue;
@@ -591,7 +594,7 @@ OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Refe
aYName = "f(x)";
}
}
- xCalculator->setRegressionProperties(aDegree, bForceIntercept, aInterceptValue, 2);
+ xCalculator->setRegressionProperties(aDegree, bForceIntercept, aInterceptValue, 2, aMovingType);
xCalculator->setXYNames ( aXName, aYName );
RegressionCurveHelper::initializeCurveCalculator( xCalculator, xSeries, xChartModel );
diff --git a/chart2/source/controller/dialogs/res_Trendline.cxx b/chart2/source/controller/dialogs/res_Trendline.cxx
index 11514a19a84a..6d994e13bc6d 100644
--- a/chart2/source/controller/dialogs/res_Trendline.cxx
+++ b/chart2/source/controller/dialogs/res_Trendline.cxx
@@ -21,12 +21,16 @@
#include <bitmaps.hlst>
#include <chartview/ChartSfxItemIds.hxx>
+#include <com/sun/star/chart2/MovingAverageType.hpp>
+
#include <svl/intitem.hxx>
#include <svl/stritem.hxx>
#include <svl/zforlist.hxx>
#include <vcl/formatter.hxx>
#include <vcl/weld.hxx>
+using namespace css::chart2;
+
namespace chart
{
@@ -65,6 +69,7 @@ TrendlineResources::TrendlineResources(weld::Builder& rBuilder, const SfxItemSet
, m_xEE_XName(rBuilder.weld_entry("entry_Xname"))
, m_xEE_YName(rBuilder.weld_entry("entry_Yname"))
, m_xCB_ShowCorrelationCoeff(rBuilder.weld_check_button("showCorrelationCoefficient"))
+ , m_xCB_RegressionMovingType(rBuilder.weld_combo_box("combo_moving_type"))
{
FillValueSets();
@@ -240,6 +245,21 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs )
m_xCB_ShowCorrelationCoeff->set_active( static_cast< const SfxBoolItem * >( pPoolItem )->GetValue());
}
+ if( rInAttrs.GetItemState( SCHATTR_REGRESSION_MOVING_TYPE, true, &pPoolItem ) == SfxItemState::SET )
+ {
+ sal_Int32 nMovingType = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue();
+ if (nMovingType == MovingAverageType::Prior)
+ m_xCB_RegressionMovingType->set_active(0);
+ else if (nMovingType == MovingAverageType::Central)
+ m_xCB_RegressionMovingType->set_active(1);
+ else if (nMovingType == MovingAverageType::AveragedAbscissa)
+ m_xCB_RegressionMovingType->set_active(2);
+ }
+ else
+ {
+ m_xCB_RegressionMovingType->set_active(0);
+ }
+
if( !m_bTrendLineUnique )
return;
@@ -273,6 +293,17 @@ void TrendlineResources::FillItemSet(SfxItemSet* rOutAttrs) const
if( m_bTrendLineUnique )
rOutAttrs->Put( SvxChartRegressItem( m_eTrendLineType, SCHATTR_REGRESSION_TYPE ));
+ if (m_eTrendLineType == SvxChartRegress::MovingAverage)
+ {
+ sal_Int32 nType = MovingAverageType::Prior;
+ if (m_xCB_RegressionMovingType->get_active() == 1)
+ nType = MovingAverageType::Central;
+ else if (m_xCB_RegressionMovingType->get_active() == 2)
+ nType = MovingAverageType::AveragedAbscissa;
+
+ rOutAttrs->Put(SfxInt32Item(SCHATTR_REGRESSION_MOVING_TYPE, nType));
+ }
+
if( m_xCB_ShowEquation->get_state() != TRISTATE_INDET )
rOutAttrs->Put( SfxBoolItem( SCHATTR_REGRESSION_SHOW_EQUATION, m_xCB_ShowEquation->get_active() ));
@@ -346,6 +377,7 @@ void TrendlineResources::UpdateControlStates()
}
m_xCB_ShowEquation->set_sensitive( !bMovingAverage );
m_xCB_ShowCorrelationCoeff->set_sensitive( !bMovingAverage );
+ m_xCB_RegressionMovingType->set_sensitive(bMovingAverage);
m_xEE_XName->set_sensitive( !bMovingAverage && m_xCB_ShowEquation->get_active() );
m_xEE_YName->set_sensitive( !bMovingAverage && m_xCB_ShowEquation->get_active() );
}
diff --git a/chart2/source/controller/dialogs/res_Trendline.hxx b/chart2/source/controller/dialogs/res_Trendline.hxx
index 29d916fe068f..2327b05c355d 100644
--- a/chart2/source/controller/dialogs/res_Trendline.hxx
+++ b/chart2/source/controller/dialogs/res_Trendline.hxx
@@ -24,6 +24,7 @@
namespace weld { class Builder; }
namespace weld { class CheckButton; }
+namespace weld { class ComboBox; }
namespace weld { class Entry; }
namespace weld { class FormattedSpinButton; }
namespace weld { class Image; }
@@ -83,6 +84,7 @@ private:
std::unique_ptr<weld::Entry> m_xEE_XName;
std::unique_ptr<weld::Entry> m_xEE_YName;
std::unique_ptr<weld::CheckButton> m_xCB_ShowCorrelationCoeff;
+ std::unique_ptr<weld::ComboBox> m_xCB_RegressionMovingType;
void UpdateControlStates();
DECL_LINK(SelectTrendLine, weld::ToggleButton&, void);
diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
index 8859158ac5b8..7fe5d2acad41 100644
--- a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
@@ -212,6 +212,13 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
}
break;
+ case SCHATTR_REGRESSION_MOVING_TYPE:
+ {
+ uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
+ bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "MovingAverageType");
+ }
+ break;
+
case SCHATTR_REGRESSION_SHOW_EQUATION:
{
uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
@@ -304,6 +311,12 @@ void RegressionCurveItemConverter::FillSpecialItem(sal_uInt16 nWhichId, SfxItemS
}
break;
+ case SCHATTR_REGRESSION_MOVING_TYPE:
+ {
+ lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "MovingAverageType");
+ }
+ break;
+
case SCHATTR_REGRESSION_SHOW_EQUATION:
{
lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(), "ShowEquation");
diff --git a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
index c0691daf24cf..d9ec4ea1f534 100644
--- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
@@ -447,6 +447,13 @@ bool StatisticsItemConverter::ApplySpecialItem(
}
break;
+ case SCHATTR_REGRESSION_MOVING_TYPE:
+ {
+ uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
+ bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "MovingAverageType");
+ }
+ break;
+
case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD:
{
uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
@@ -729,6 +736,13 @@ void StatisticsItemConverter::FillSpecialItem(
}
break;
+ case SCHATTR_REGRESSION_MOVING_TYPE:
+ {
+ uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
+ lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "MovingAverageType");
+ }
+ break;
+
case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD:
{
uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
diff --git a/chart2/source/inc/LinearRegressionCurveCalculator.hxx b/chart2/source/inc/LinearRegressionCurveCalculator.hxx
index accc43c06294..57d85a24f884 100644
--- a/chart2/source/inc/LinearRegressionCurveCalculator.hxx
+++ b/chart2/source/inc/LinearRegressionCurveCalculator.hxx
@@ -34,7 +34,8 @@ private:
sal_Int32 aDegree,
sal_Bool aForceIntercept,
double aInterceptValue,
- sal_Int32 aPeriod) override;
+ sal_Int32 aPeriod,
+ sal_Int32 nMovingType) override;
virtual css::uno::Sequence<css::geometry::RealPoint2D> SAL_CALL getCurveValues(
double min,
diff --git a/chart2/source/inc/MovingAverageRegressionCurveCalculator.hxx b/chart2/source/inc/MovingAverageRegressionCurveCalculator.hxx
index 0b15ca5e817e..8ba5456c2939 100644
--- a/chart2/source/inc/MovingAverageRegressionCurveCalculator.hxx
+++ b/chart2/source/inc/MovingAverageRegressionCurveCalculator.hxx
@@ -19,6 +19,7 @@
#pragma once
#include "RegressionCurveCalculator.hxx"
+#include "RegressionCalculationHelper.hxx"
#include <vector>
namespace chart
@@ -51,6 +52,9 @@ private:
const css::uno::Reference<css::chart2::XScaling>& xScalingY,
sal_Bool bMaySkipPointsInCalculation ) override;
+ void calculateValues(RegressionCalculationHelper::tDoubleVectorPair aValues, sal_Int32 nPeriod,
+ bool bUseXAvg);
+
std::vector<double> aYList;
std::vector<double> aXList;
};
diff --git a/chart2/source/inc/RegressionCurveCalculator.hxx b/chart2/source/inc/RegressionCurveCalculator.hxx
index 1914c4effea9..6cf1f2914d5b 100644
--- a/chart2/source/inc/RegressionCurveCalculator.hxx
+++ b/chart2/source/inc/RegressionCurveCalculator.hxx
@@ -62,13 +62,15 @@ protected:
double mInterceptValue;
sal_Int32 mPeriod;
OUString mXName, mYName;
+ sal_Int32 mnMovingType;
// ____ XRegressionCurveCalculator ____
virtual void SAL_CALL setRegressionProperties(
sal_Int32 aDegree,
sal_Bool aForceIntercept,
double aInterceptValue,
- sal_Int32 aPeriod) override;
+ sal_Int32 aPeriod,
+ sal_Int32 nMovingType) override;
virtual void SAL_CALL recalculateRegression(
const css::uno::Sequence< double >& aXValues,
diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx
index 7ed412ce4500..55fec55872f3 100644
--- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx
+++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx
@@ -191,7 +191,8 @@ constexpr TypedWhichId<SvxDoubleItem> SCHATTR_REGRESSION_INTERCEPT_VALUE
constexpr TypedWhichId<SfxStringItem> SCHATTR_REGRESSION_CURVE_NAME (SCHATTR_REGRESSION_START + 9);
constexpr TypedWhichId<SfxStringItem> SCHATTR_REGRESSION_XNAME (SCHATTR_REGRESSION_START + 10);
constexpr TypedWhichId<SfxStringItem> SCHATTR_REGRESSION_YNAME (SCHATTR_REGRESSION_START + 11);
-constexpr sal_uInt16 SCHATTR_REGRESSION_END (SCHATTR_REGRESSION_YNAME);
+constexpr TypedWhichId<SfxInt32Item> SCHATTR_REGRESSION_MOVING_TYPE (SCHATTR_REGRESSION_START + 12);
+constexpr sal_uInt16 SCHATTR_REGRESSION_END (SCHATTR_REGRESSION_MOVING_TYPE);
constexpr sal_uInt16 SCHATTR_END (SCHATTR_REGRESSION_END);
diff --git a/chart2/source/tools/LinearRegressionCurveCalculator.cxx b/chart2/source/tools/LinearRegressionCurveCalculator.cxx
index 9cf3492d8e8e..811381507cb6 100644
--- a/chart2/source/tools/LinearRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/LinearRegressionCurveCalculator.cxx
@@ -35,13 +35,15 @@ void LinearRegressionCurveCalculator::setRegressionProperties(
sal_Int32 /*aDegree*/,
sal_Bool aForceIntercept,
double aInterceptValue,
- sal_Int32 aPeriod )
+ sal_Int32 aPeriod,
+ sal_Int32 /*nMovingType*/)
{
PolynomialRegressionCurveCalculator::setRegressionProperties(
1,
aForceIntercept,
aInterceptValue,
- aPeriod);
+ aPeriod,
+ 0);
}
uno::Sequence< geometry::RealPoint2D > SAL_CALL LinearRegressionCurveCalculator::getCurveValues(
diff --git a/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx b/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx
index 7774bec02a4f..bca154047935 100644
--- a/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx
@@ -24,7 +24,10 @@
#include <rtl/math.hxx>
+#include <com/sun/star/chart2/MovingAverageType.hpp>
+
using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart2;
namespace chart
{
@@ -47,25 +50,59 @@ void SAL_CALL MovingAverageRegressionCurveCalculator::recalculateRegression(
aXValues, aYValues,
RegressionCalculationHelper::isValid()));
- const size_t aSize = aValues.first.size();
-
aYList.clear();
aXList.clear();
- for( size_t i = mPeriod - 1; i < aSize; ++i )
+ switch (mnMovingType)
+ {
+ case MovingAverageType::Central:
+ {
+ sal_Int32 nCentralPeriod = (mPeriod % 2 == 0) ? (mPeriod / 2) : ((mPeriod - 1) / 2);
+ calculateValues(aValues, nCentralPeriod, false);
+ break;
+ }
+
+ case MovingAverageType::AveragedAbscissa:
+ {
+ calculateValues(aValues, mPeriod, true);
+ break;
+ }
+ case MovingAverageType::Prior:
+ default:
+ {
+ calculateValues(aValues, mPeriod, false);
+ break;
+ }
+ }
+}
+
+void MovingAverageRegressionCurveCalculator::calculateValues(
+ RegressionCalculationHelper::tDoubleVectorPair aValues, sal_Int32 nPeriod, bool bUseXAvg)
+{
+ const size_t aSize = aValues.first.size();
+ for (size_t i = nPeriod - 1; i < aSize; ++i)
{
- double yAvg;
- yAvg = 0.0;
+ double xAvg = 0.0;
+ double yAvg = 0.0;
- for (sal_Int32 j = 0; j < mPeriod; j++)
+ for (sal_Int32 j = 0; j < nPeriod; j++)
{
+ xAvg += aValues.first[i - j];
yAvg += aValues.second[i - j];
}
- yAvg /= mPeriod;
+ yAvg /= nPeriod;
+ xAvg /= nPeriod;
- double x = aValues.first[i];
aYList.push_back(yAvg);
- aXList.push_back(x);
+ if (bUseXAvg)
+ {
+ aXList.push_back(xAvg);
+ }
+ else
+ {
+ double x = aValues.first[i];
+ aXList.push_back(x);
+ }
}
}
diff --git a/chart2/source/tools/RegressionCurveCalculator.cxx b/chart2/source/tools/RegressionCurveCalculator.cxx
index ba8a7423c01e..c27a47e502cd 100644
--- a/chart2/source/tools/RegressionCurveCalculator.cxx
+++ b/chart2/source/tools/RegressionCurveCalculator.cxx
@@ -72,12 +72,14 @@ void RegressionCurveCalculator::setRegressionProperties(
sal_Int32 aDegree,
sal_Bool aForceIntercept,
double aInterceptValue,
- sal_Int32 aPeriod )
+ sal_Int32 aPeriod,
+ sal_Int32 nMovingType )
{
mDegree = aDegree;
mForceIntercept = aForceIntercept;
mInterceptValue = aInterceptValue;
mPeriod = aPeriod;
+ mnMovingType = nMovingType;
}
OUString RegressionCurveCalculator::getFormattedString(
diff --git a/chart2/source/tools/RegressionCurveModel.cxx b/chart2/source/tools/RegressionCurveModel.cxx
index 649e93e2702f..0fb7662830af 100644
--- a/chart2/source/tools/RegressionCurveModel.cxx
+++ b/chart2/source/tools/RegressionCurveModel.cxx
@@ -44,7 +44,8 @@ enum
PROPERTY_EXTRAPOLATE_BACKWARD,
PROPERTY_FORCE_INTERCEPT,
PROPERTY_INTERCEPT_VALUE,
- PROPERTY_CURVE_NAME
+ PROPERTY_CURVE_NAME,
+ PROPERTY_MOVING_AVERAGE_TYPE
};
void lcl_AddPropertiesToVector(
@@ -62,6 +63,12 @@ void lcl_AddPropertiesToVector(
beans::PropertyAttribute::BOUND |
beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "MovingAverageType",
+ PROPERTY_MOVING_AVERAGE_TYPE,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND |
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
rOutProperties.emplace_back( "ExtrapolateForward",
PROPERTY_EXTRAPOLATE_FORWARD,
cppu::UnoType<double>::get(),
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index c235148a2045..39a97c618a47 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -56,6 +56,7 @@
#include <com/sun/star/chart2/DataPointLabel.hpp>
#include <com/sun/star/chart/ErrorBarStyle.hpp>
#include <com/sun/star/chart/TimeUnit.hpp>
+#include <com/sun/star/chart2/MovingAverageType.hpp>
#include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
#include <com/sun/star/container/XChild.hpp>
@@ -1335,6 +1336,7 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries const & rVDataSer
sal_Int32 aDegree = 2;
sal_Int32 aPeriod = 2;
+ sal_Int32 aMovingAverageType = css::chart2::MovingAverageType::Prior;
double aExtrapolateForward = 0.0;
double aExtrapolateBackward = 0.0;
bool bForceIntercept = false;
@@ -1344,6 +1346,7 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries const & rVDataSer
{
xProperties->getPropertyValue( "PolynomialDegree") >>= aDegree;
xProperties->getPropertyValue( "MovingAveragePeriod") >>= aPeriod;
+ xProperties->getPropertyValue( "MovingAverageType") >>= aMovingAverageType;
xProperties->getPropertyValue( "ExtrapolateForward") >>= aExtrapolateForward;
xProperties->getPropertyValue( "ExtrapolateBackward") >>= aExtrapolateBackward;
xProperties->getPropertyValue( "ForceIntercept") >>= bForceIntercept;
@@ -1370,8 +1373,9 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries const & rVDataSer
fPointScale = std::min(fPointScale, 1000.0);
}
- xCalculator->setRegressionProperties(aDegree, bForceIntercept, aInterceptValue, aPeriod);
- xCalculator->recalculateRegression( rVDataSeries.getAllX(), rVDataSeries.getAllY() );
+ xCalculator->setRegressionProperties(aDegree, bForceIntercept, aInterceptValue, aPeriod,
+ aMovingAverageType);
+ xCalculator->recalculateRegression(rVDataSeries.getAllX(), rVDataSeries.getAllY());
sal_Int32 nPointCount = 100 * fPointScale;
if ( nPointCount < 2 )
diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx
index 7f67cdde45ca..8b5bade3ebc3 100644
--- a/chart2/source/view/main/ChartItemPool.cxx
+++ b/chart2/source/view/main/ChartItemPool.cxx
@@ -31,6 +31,7 @@
#include <vector>
#include <com/sun/star/chart2/LegendPosition.hpp>
+#include <com/sun/star/chart2/MovingAverageType.hpp>
namespace chart
{
@@ -165,6 +166,7 @@ ChartItemPool::ChartItemPool():
rPoolDefaults[SCHATTR_REGRESSION_CURVE_NAME - SCHATTR_START] = new SfxStringItem(SCHATTR_REGRESSION_CURVE_NAME, OUString());
rPoolDefaults[SCHATTR_REGRESSION_XNAME - SCHATTR_START] = new SfxStringItem(SCHATTR_REGRESSION_XNAME, "x");
rPoolDefaults[SCHATTR_REGRESSION_YNAME - SCHATTR_START] = new SfxStringItem(SCHATTR_REGRESSION_YNAME, "f(x)");
+ rPoolDefaults[SCHATTR_REGRESSION_MOVING_TYPE - SCHATTR_START] = new SfxInt32Item(SCHATTR_REGRESSION_MOVING_TYPE, css::chart2::MovingAverageType::Prior);
/**************************************************************************
* ItemInfos