1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef CHART2_STATISTICSHELPER_HXX
24 #define CHART2_STATISTICSHELPER_HXX
25 
26 #include <com/sun/star/uno/Sequence.hxx>
27 #include <com/sun/star/uno/XComponentContext.hpp>
28 #include <com/sun/star/chart2/data/XDataSource.hpp>
29 #include <com/sun/star/chart2/data/XDataProvider.hpp>
30 #include <com/sun/star/chart2/XDataSeries.hpp>
31 #include "charttoolsdllapi.hxx"
32 
33 namespace chart
34 {
35 
36 class OOO_DLLPUBLIC_CHARTTOOLS StatisticsHelper
37 {
38 public:
39     /** Calculates 1/n * sum (x_i - x_mean)^2.
40 
41         @see http://mathworld.wolfram.com/Variance.html
42 
43         @param bUnbiasedEstimator
44             If true, 1/(n-1) * sum (x_i - x_mean)^2 is returned.
45      */
46     static double getVariance( const ::com::sun::star::uno::Sequence< double > & rData,
47         bool bUnbiasedEstimator = false );
48 
49     // square root of the variance
50     static double getStandardDeviation( const ::com::sun::star::uno::Sequence< double > & rData );
51 
52     // also called "Standard deviation of the mean (SDOM)"
53     static double getStandardError( const ::com::sun::star::uno::Sequence< double > & rData );
54 
55     static ::com::sun::star::uno::Reference<
56             ::com::sun::star::chart2::data::XLabeledDataSequence >
57         getErrorLabeledDataSequenceFromDataSource(
58             const ::com::sun::star::uno::Reference<
59                 ::com::sun::star::chart2::data::XDataSource > & xDataSource,
60             bool bPositiveValue,
61             bool bYError = true );
62 
63     static ::com::sun::star::uno::Reference<
64             ::com::sun::star::chart2::data::XDataSequence >
65         getErrorDataSequenceFromDataSource(
66             const ::com::sun::star::uno::Reference<
67                 ::com::sun::star::chart2::data::XDataSource > & xDataSource,
68             bool bPositiveValue,
69             bool bYError = true );
70 
71     static double getErrorFromDataSource(
72         const ::com::sun::star::uno::Reference<
73             ::com::sun::star::chart2::data::XDataSource > & xDataSource,
74         sal_Int32 nIndex,
75         bool bPositiveValue,
76         bool bYError = true );
77 
78     static void setErrorDataSequence(
79         const ::com::sun::star::uno::Reference<
80             ::com::sun::star::chart2::data::XDataSource > & xDataSource,
81         const ::com::sun::star::uno::Reference<
82             ::com::sun::star::chart2::data::XDataProvider > & xDataProvider,
83         const ::rtl::OUString & rNewRange,
84         bool bPositiveValue,
85         bool bYError = true,
86         ::rtl::OUString * pXMLRange = 0 );
87 
88     /// @return the newly created or existing error bar object
89     static ::com::sun::star::uno::Reference<
90             ::com::sun::star::beans::XPropertySet >
91         addErrorBars(
92             const ::com::sun::star::uno::Reference<
93                 ::com::sun::star::chart2::XDataSeries > & xDataSeries,
94             const ::com::sun::star::uno::Reference<
95                 ::com::sun::star::uno::XComponentContext > & xContext,
96             sal_Int32 nStyle,
97             bool bYError = true );
98 
99     static ::com::sun::star::uno::Reference<
100             ::com::sun::star::beans::XPropertySet >
101         getErrorBars(
102             const ::com::sun::star::uno::Reference<
103                 ::com::sun::star::chart2::XDataSeries > & xDataSeries,
104             bool bYError = true );
105 
106     static bool hasErrorBars(
107         const ::com::sun::star::uno::Reference<
108             ::com::sun::star::chart2::XDataSeries > & xDataSeries,
109         bool bYError = true );
110 
111     static void removeErrorBars(
112         const ::com::sun::star::uno::Reference<
113             ::com::sun::star::chart2::XDataSeries > & xDataSeries,
114         bool bYError = true );
115 
116     static bool usesErrorBarRanges(
117         const ::com::sun::star::uno::Reference<
118             ::com::sun::star::chart2::XDataSeries > & xDataSeries,
119         bool bYError = true );
120 
121 private:
122     // not implemented
123 	StatisticsHelper();
124 };
125 
126 } //  namespace chart
127 
128 // CHART2_STATISTICSHELPER_HXX
129 #endif
130