summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorRafael Dominguez <venccsralph@gmail.com>2012-04-02 19:04:01 -0430
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-04-11 17:55:41 +0200
commit67c45c9dbde0eb164df28d6f8cae935869de85d4 (patch)
treebefdc6813096008ea1c7fde9acaeb7ad3666edb1 /chart2
parent0e3bd5c0c4e18d9daa6bc827996e860ede1f438b (diff)
Calculate correct standard deviation for XErrorBar.
- Add method to calculate X standard deviation. - Set correct XErrorBar position when using standard deviation error type.
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/view/charttypes/VSeriesPlotter.cxx7
-rw-r--r--chart2/source/view/inc/VDataSeries.hxx2
-rw-r--r--chart2/source/view/main/VDataSeries.cxx15
3 files changed, 23 insertions, 1 deletions
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index 1c84ca069743..c693a0b58a33 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -823,7 +823,12 @@ void VSeriesPlotter::createErrorBar(
drawing::Position3D aUnscaledLogicPosition(rUnscaledLogicPosition);
if(nErrorBarStyle==::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION)
- aUnscaledLogicPosition.PositionY = rVDataSeries.getYMeanValue();
+ {
+ if (bYError)
+ aUnscaledLogicPosition.PositionY = rVDataSeries.getYMeanValue();
+ else
+ aUnscaledLogicPosition.PositionX = rVDataSeries.getXMeanValue();
+ }
bool bCreateNegativeBorder = false;//make a vertical line at the negative end of the error bar
bool bCreatePositiveBorder = false;//make a vertical line at the positive end of the error bar
diff --git a/chart2/source/view/inc/VDataSeries.hxx b/chart2/source/view/inc/VDataSeries.hxx
index 64679cd96425..cb10cef81ff0 100644
--- a/chart2/source/view/inc/VDataSeries.hxx
+++ b/chart2/source/view/inc/VDataSeries.hxx
@@ -102,6 +102,7 @@ public:
::com::sun::star::uno::Sequence< double > getAllX() const;
::com::sun::star::uno::Sequence< double > getAllY() const;
+ double getXMeanValue() const;
double getYMeanValue() const;
bool hasExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPercentage ) const;
@@ -216,6 +217,7 @@ private: //member
VDataSequence* m_pValueSequenceForDataLabelNumberFormatDetection;
+ mutable double m_fXMeanValue;
mutable double m_fYMeanValue;
::com::sun::star::uno::Sequence< sal_Int32 > m_aAttributedDataPointIndexList;
diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx
index 5cad9ca7d8dc..25420ad45342 100644
--- a/chart2/source/view/main/VDataSeries.cxx
+++ b/chart2/source/view/main/VDataSeries.cxx
@@ -176,6 +176,7 @@ VDataSeries::VDataSeries( const uno::Reference< XDataSeries >& xDataSeries )
, m_aValues_Bubble_Size()
, m_pValueSequenceForDataLabelNumberFormatDetection(&m_aValues_Y)
+ , m_fXMeanValue(1.0)
, m_fYMeanValue(1.0)
, m_aAttributedDataPointIndexList()
@@ -207,6 +208,7 @@ VDataSeries::VDataSeries( const uno::Reference< XDataSeries >& xDataSeries )
, m_nMissingValueTreatment(::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP)
, m_bAllowPercentValueInDataLabel(false)
{
+ ::rtl::math::setNan( & m_fXMeanValue );
::rtl::math::setNan( & m_fYMeanValue );
uno::Reference<data::XDataSource> xDataSource =
@@ -729,6 +731,19 @@ uno::Sequence< double > VDataSeries::getAllY() const
return m_aValues_Y.Doubles;
}
+double VDataSeries::getXMeanValue() const
+{
+ if( ::rtl::math::isNan( m_fXMeanValue ) )
+ {
+ uno::Reference< XRegressionCurveCalculator > xCalculator( RegressionCurveHelper::createRegressionCurveCalculatorByServiceName( "com.sun.star.chart2.MeanValueRegressionCurve" ) );
+ uno::Sequence< double > aXValuesDummy;
+ xCalculator->recalculateRegression( aXValuesDummy, getAllX() );
+ double fXDummy = 1.0;
+ m_fXMeanValue = xCalculator->getCurveValue( fXDummy );
+ }
+ return m_fXMeanValue;
+}
+
double VDataSeries::getYMeanValue() const
{
if( ::rtl::math::isNan( m_fYMeanValue ) )