Calculate correct standard deviation for XErrorBar.

- Add method to calculate X standard deviation.
- Set correct XErrorBar position when using standard deviation error
type.
This commit is contained in:
Rafael Dominguez 2012-04-02 19:04:01 -04:30 committed by Markus Mohrhard
parent 0e3bd5c0c4
commit 67c45c9dbd
3 changed files with 23 additions and 1 deletions

View File

@ -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

View File

@ -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;

View File

@ -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 ) )