public TTestResult TTestPaired(double hypothesizedMeanDifference, double probability, string firstInputSeriesName, string secondInputSeriesName)
        {
            TTestResult tTestResult = new TTestResult();
            string      str         = hypothesizedMeanDifference.ToString(CultureInfo.InvariantCulture);

            str = str + "," + probability.ToString(CultureInfo.InvariantCulture);
            this.formulaData.Common.DataManager.Series.Add(this.tempOutputSeriesName);
            string inputSeries = firstInputSeriesName.ToString(CultureInfo.InvariantCulture) + "," + secondInputSeriesName.ToString(CultureInfo.InvariantCulture);

            this.formulaData.Formula("TTestPaired", str, inputSeries, this.tempOutputSeriesName);
            DataPointCollection points = this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName].Points;

            tTestResult.firstSeriesMean      = points[0].YValues[0];
            tTestResult.secondSeriesMean     = points[1].YValues[0];
            tTestResult.firstSeriesVariance  = points[2].YValues[0];
            tTestResult.secondSeriesVariance = points[3].YValues[0];
            tTestResult.tValue                = points[4].YValues[0];
            tTestResult.degreeOfFreedom       = points[5].YValues[0];
            tTestResult.probabilityTOneTail   = points[6].YValues[0];
            tTestResult.tCriticalValueOneTail = points[7].YValues[0];
            tTestResult.probabilityTTwoTail   = points[8].YValues[0];
            tTestResult.tCriticalValueTwoTail = points[9].YValues[0];
            this.formulaData.Common.DataManager.Series.Remove(this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName]);
            return(tTestResult);
        }
        public ZTestResult ZTest(double hypothesizedMeanDifference, double varianceFirstGroup, double varianceSecondGroup, double probability, string firstInputSeriesName, string secondInputSeriesName)
        {
            ZTestResult zTestResult = new ZTestResult();
            string      str         = hypothesizedMeanDifference.ToString(CultureInfo.InvariantCulture);

            str = str + "," + varianceFirstGroup.ToString(CultureInfo.InvariantCulture);
            str = str + "," + varianceSecondGroup.ToString(CultureInfo.InvariantCulture);
            str = str + "," + probability.ToString(CultureInfo.InvariantCulture);
            this.formulaData.Common.DataManager.Series.Add(this.tempOutputSeriesName);
            string inputSeries = firstInputSeriesName.ToString(CultureInfo.InvariantCulture) + "," + secondInputSeriesName.ToString(CultureInfo.InvariantCulture);

            this.formulaData.Formula("ZTest", str, inputSeries, this.tempOutputSeriesName);
            DataPointCollection points = this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName].Points;

            zTestResult.firstSeriesMean      = points[0].YValues[0];
            zTestResult.secondSeriesMean     = points[1].YValues[0];
            zTestResult.firstSeriesVariance  = points[2].YValues[0];
            zTestResult.secondSeriesVariance = points[3].YValues[0];
            zTestResult.zValue = points[4].YValues[0];
            zTestResult.probabilityZOneTail   = points[5].YValues[0];
            zTestResult.zCriticalValueOneTail = points[6].YValues[0];
            zTestResult.probabilityZTwoTail   = points[7].YValues[0];
            zTestResult.zCriticalValueTwoTail = points[8].YValues[0];
            this.formulaData.Common.DataManager.Series.Remove(this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName]);
            return(zTestResult);
        }
        public double Median(string inputSeriesName)
        {
            this.formulaData.Common.DataManager.Series.Add(this.tempOutputSeriesName);
            this.formulaData.Formula("Median", "", inputSeriesName, this.tempOutputSeriesName);
            DataPointCollection points = this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName].Points;
            double result = points[0].YValues[0];

            this.formulaData.Common.DataManager.Series.Remove(this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName]);
            return(result);
        }
        public double GammaFunction(double value)
        {
            this.formulaData.Common.DataManager.Series.Add(this.tempOutputSeriesName);
            string parameters = value.ToString(CultureInfo.InvariantCulture);

            this.formulaData.Formula("GammaFunction", parameters, this.tempOutputSeriesName, this.tempOutputSeriesName);
            DataPointCollection points = this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName].Points;
            double result = points[0].YValues[0];

            this.formulaData.Common.DataManager.Series.Remove(this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName]);
            return(result);
        }
        public double Covariance(string firstInputSeriesName, string secondInputSeriesName)
        {
            this.formulaData.Common.DataManager.Series.Add(this.tempOutputSeriesName);
            string inputSeries = firstInputSeriesName.ToString(CultureInfo.InvariantCulture) + "," + secondInputSeriesName.ToString(CultureInfo.InvariantCulture);

            this.formulaData.Formula("Covariance", "", inputSeries, this.tempOutputSeriesName);
            DataPointCollection points = this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName].Points;
            double result = points[0].YValues[0];

            this.formulaData.Common.DataManager.Series.Remove(this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName]);
            return(result);
        }
        public double Correlation(string firstInputSeriesName, string secondInputSeriesName)
        {
            this.formulaData.Common.DataManager.Series.Add(this.tempOutputSeriesName);
            string inputSeries = firstInputSeriesName + "," + secondInputSeriesName;

            this.formulaData.Formula("Correlation", "", inputSeries, this.tempOutputSeriesName);
            DataPointCollection points = this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName].Points;
            double result = points[0].YValues[0];

            this.formulaData.Common.DataManager.Series.Remove(this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName]);
            return(result);
        }
        public double InverseNormalDistribution(double probability)
        {
            string parameters = probability.ToString(CultureInfo.InvariantCulture);

            this.formulaData.Common.DataManager.Series.Add(this.tempOutputSeriesName);
            this.formulaData.Formula("InverseNormalDistribution", parameters, this.tempOutputSeriesName, this.tempOutputSeriesName);
            DataPointCollection points = this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName].Points;
            double result = points[0].YValues[0];

            this.formulaData.Common.DataManager.Series.Remove(this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName]);
            return(result);
        }
        public double Variance(string inputSeriesName, bool sampleVariance)
        {
            this.formulaData.Common.DataManager.Series.Add(this.tempOutputSeriesName);
            string parameters = sampleVariance.ToString(CultureInfo.InvariantCulture);

            this.formulaData.Formula("Variance", parameters, inputSeriesName, this.tempOutputSeriesName);
            DataPointCollection points = this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName].Points;
            double result = points[0].YValues[0];

            this.formulaData.Common.DataManager.Series.Remove(this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName]);
            return(result);
        }
        public double BetaFunction(double m, double n)
        {
            this.formulaData.Common.DataManager.Series.Add(this.tempOutputSeriesName);
            string str = m.ToString(CultureInfo.InvariantCulture);

            str = str + "," + n.ToString(CultureInfo.InvariantCulture);
            this.formulaData.Formula("BetaFunction", str, this.tempOutputSeriesName, this.tempOutputSeriesName);
            DataPointCollection points = this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName].Points;
            double result = points[0].YValues[0];

            this.formulaData.Common.DataManager.Series.Remove(this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName]);
            return(result);
        }
        public double InverseTDistribution(double probability, int degreeOfFreedom)
        {
            string str = probability.ToString(CultureInfo.InvariantCulture);

            str = str + "," + degreeOfFreedom.ToString(CultureInfo.InvariantCulture);
            this.formulaData.Common.DataManager.Series.Add(this.tempOutputSeriesName);
            this.formulaData.Formula("InverseTDistribution", str, this.tempOutputSeriesName, this.tempOutputSeriesName);
            DataPointCollection points = this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName].Points;
            double result = points[0].YValues[0];

            this.formulaData.Common.DataManager.Series.Remove(this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName]);
            return(result);
        }
        public double TDistribution(double value, int degreeOfFreedom, bool oneTail)
        {
            string str = value.ToString(CultureInfo.InvariantCulture);

            str = str + "," + degreeOfFreedom.ToString(CultureInfo.InvariantCulture);
            str = ((!oneTail) ? (str + ",2") : (str + ",1"));
            this.formulaData.Common.DataManager.Series.Add(this.tempOutputSeriesName);
            this.formulaData.Formula("TDistribution", str, this.tempOutputSeriesName, this.tempOutputSeriesName);
            DataPointCollection points = this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName].Points;
            double result = points[0].YValues[0];

            this.formulaData.Common.DataManager.Series.Remove(this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName]);
            return(result);
        }
        public double FDistribution(double value, int firstDegreeOfFreedom, int secondDegreeOfFreedom)
        {
            string str = value.ToString(CultureInfo.InvariantCulture);

            str = str + "," + firstDegreeOfFreedom.ToString(CultureInfo.InvariantCulture);
            str = str + "," + secondDegreeOfFreedom.ToString(CultureInfo.InvariantCulture);
            this.formulaData.Common.DataManager.Series.Add(this.tempOutputSeriesName);
            this.formulaData.Formula("FDistribution", str, this.tempOutputSeriesName, this.tempOutputSeriesName);
            DataPointCollection points = this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName].Points;
            double result = points[0].YValues[0];

            this.formulaData.Common.DataManager.Series.Remove(this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName]);
            return(result);
        }
Example #13
0
 public static void AutoDetectValuesType(Series series, IEnumerator xEnumerator, string xField, IEnumerator yEnumerator, string yField)
 {
     if (series.XValueType == ChartValueTypes.Auto)
     {
         series.XValueType = DataPointCollection.GetValueType(xEnumerator, xField);
         if (series.XValueType != 0)
         {
             series.autoXValueType = true;
         }
     }
     if (series.YValueType == ChartValueTypes.Auto)
     {
         series.YValueType = DataPointCollection.GetValueType(yEnumerator, yField);
         if (series.YValueType != 0)
         {
             series.autoYValueType = true;
         }
     }
 }
        public AnovaResult Anova(double probability, string inputSeriesNames)
        {
            AnovaResult anovaResult = new AnovaResult();
            string      parameters  = probability.ToString(CultureInfo.InvariantCulture);

            this.formulaData.Common.DataManager.Series.Add(this.tempOutputSeriesName);
            this.formulaData.Formula("Anova", parameters, inputSeriesNames, this.tempOutputSeriesName);
            DataPointCollection points = this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName].Points;

            anovaResult.sumOfSquaresBetweenGroups       = points[0].YValues[0];
            anovaResult.sumOfSquaresWithinGroups        = points[1].YValues[0];
            anovaResult.sumOfSquaresTotal               = points[2].YValues[0];
            anovaResult.degreeOfFreedomBetweenGroups    = points[3].YValues[0];
            anovaResult.degreeOfFreedomWithinGroups     = points[4].YValues[0];
            anovaResult.degreeOfFreedomTotal            = points[5].YValues[0];
            anovaResult.meanSquareVarianceBetweenGroups = points[6].YValues[0];
            anovaResult.meanSquareVarianceWithinGroups  = points[7].YValues[0];
            anovaResult.fRatio         = points[8].YValues[0];
            anovaResult.fCriticalValue = points[9].YValues[0];
            this.formulaData.Common.DataManager.Series.Remove(this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName]);
            return(anovaResult);
        }
        public FTestResult FTest(double probability, string firstInputSeriesName, string secondInputSeriesName)
        {
            FTestResult fTestResult = new FTestResult();
            string      parameters  = probability.ToString(CultureInfo.InvariantCulture);
            string      inputSeries = firstInputSeriesName.ToString(CultureInfo.InvariantCulture) + "," + secondInputSeriesName.ToString(CultureInfo.InvariantCulture);

            this.formulaData.Common.DataManager.Series.Add(this.tempOutputSeriesName);
            this.RemoveEmptyPoints(firstInputSeriesName);
            this.RemoveEmptyPoints(secondInputSeriesName);
            this.formulaData.Formula("FTest", parameters, inputSeries, this.tempOutputSeriesName);
            DataPointCollection points = this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName].Points;

            fTestResult.firstSeriesMean      = points[0].YValues[0];
            fTestResult.secondSeriesMean     = points[1].YValues[0];
            fTestResult.firstSeriesVariance  = points[2].YValues[0];
            fTestResult.secondSeriesVariance = points[3].YValues[0];
            fTestResult.fValue = points[4].YValues[0];
            fTestResult.probabilityFOneTail   = points[5].YValues[0];
            fTestResult.fCriticalValueOneTail = points[6].YValues[0];
            this.formulaData.Common.DataManager.Series.Remove(this.formulaData.Common.DataManager.Series[this.tempOutputSeriesName]);
            return(fTestResult);
        }
Example #16
0
 public void DataPointInit(ref DataPoint dataPoint)
 {
     DataPointCollection.DataPointInit(this.series, ref dataPoint);
 }
 public void DataBind(IEnumerable dataSource, ArrayList seriesList)
 {
     if (dataSource != null && base.common != null)
     {
         if (seriesList == null)
         {
             seriesList = new ArrayList();
             foreach (Series item in base.common.Chart.Series)
             {
                 if (base.common.Chart.IsDesignMode())
                 {
                     if (item.ValueMembersY.Length > 0)
                     {
                         seriesList.Add(item);
                     }
                 }
                 else
                 {
                     seriesList.Add(item);
                 }
             }
         }
         foreach (Series series4 in seriesList)
         {
             if (series4.ValueMemberX.Length > 0 || series4.ValueMembersY.Length > 0)
             {
                 series4.Points.Clear();
             }
         }
         IEnumerator enumerator3 = dataSource.GetEnumerator();
         if (enumerator3.GetType() != typeof(DbEnumerator))
         {
             try
             {
                 enumerator3.Reset();
             }
             catch
             {
             }
         }
         bool flag  = true;
         bool flag2 = true;
         do
         {
             flag = enumerator3.MoveNext();
             foreach (Series series5 in seriesList)
             {
                 if (series5.ValueMemberX.Length <= 0 && series5.ValueMembersY.Length <= 0)
                 {
                     continue;
                 }
                 string[] array = null;
                 if (series5.ValueMembersY.Length > 0)
                 {
                     array = series5.ValueMembersY.Replace(",,", "\n").Split(',');
                     for (int i = 0; i < array.Length; i++)
                     {
                         array[i] = array[i].Replace("\n", ",").Trim();
                     }
                 }
                 if (dataSource is string)
                 {
                     throw new ArgumentException(SR.ExceptionDataBindYValuesToString, "dataSource");
                 }
                 if (array != null && array.GetLength(0) <= series5.YValuesPerPoint)
                 {
                     if (flag)
                     {
                         if (flag2)
                         {
                             flag2 = false;
                             string text = array[0];
                             int    num  = 1;
                             while (text.Length == 0 && num < array.Length)
                             {
                                 text = array[num++];
                             }
                             DataPointCollection.AutoDetectValuesType(series5, enumerator3, series5.ValueMemberX.Trim(), enumerator3, text);
                         }
                         DataPoint dataPoint = new DataPoint(series5);
                         bool      flag3     = false;
                         bool      flag4     = false;
                         object[]  array2    = new object[array.Length];
                         object    obj2      = null;
                         if (series5.ValueMemberX.Length > 0)
                         {
                             obj2 = DataPointCollection.ConvertEnumerationItem(enumerator3.Current, series5.ValueMemberX.Trim());
                             if (obj2 is DBNull || obj2 == null)
                             {
                                 flag4 = true;
                                 flag3 = true;
                                 obj2  = 0.0;
                             }
                         }
                         if (array.Length == 0)
                         {
                             array2[0] = DataPointCollection.ConvertEnumerationItem(enumerator3.Current, null);
                             if (array2[0] is DBNull || array2[0] == null)
                             {
                                 flag3     = true;
                                 array2[0] = 0.0;
                             }
                         }
                         else
                         {
                             for (int j = 0; j < array.Length; j++)
                             {
                                 if (array[j].Length > 0)
                                 {
                                     array2[j] = DataPointCollection.ConvertEnumerationItem(enumerator3.Current, array[j]);
                                     if (array2[j] is DBNull || array2[j] == null)
                                     {
                                         flag3     = true;
                                         array2[j] = 0.0;
                                     }
                                 }
                                 else
                                 {
                                     array2[j] = (((Series)seriesList[0]).IsYValueDateTime() ? DateTime.Now.Date.ToOADate() : 0.0);
                                 }
                             }
                         }
                         if (!flag4)
                         {
                             if (flag3)
                             {
                                 if (obj2 != null)
                                 {
                                     dataPoint.SetValueXY(obj2, array2);
                                 }
                                 else
                                 {
                                     dataPoint.SetValueXY(0, array2);
                                 }
                                 series5.Points.DataPointInit(ref dataPoint);
                                 dataPoint.Empty = true;
                                 series5.Points.Add(dataPoint);
                             }
                             else
                             {
                                 if (obj2 != null)
                                 {
                                     dataPoint.SetValueXY(obj2, array2);
                                 }
                                 else
                                 {
                                     dataPoint.SetValueXY(0, array2);
                                 }
                                 series5.Points.DataPointInit(ref dataPoint);
                                 series5.Points.Add(dataPoint);
                             }
                         }
                         if (base.common.Chart.IsDesignMode())
                         {
                             ((DataPointAttributes)series5)["TempDesignData"] = "true";
                         }
                     }
                     continue;
                 }
                 throw new ArgumentOutOfRangeException("yValue", SR.ExceptionDataPointYValuesCountMismatch(series5.YValuesPerPoint.ToString(CultureInfo.InvariantCulture)));
             }
         }while (flag);
     }
 }
Example #18
0
 public void DataBindXY(IEnumerable xValue, string xField, IEnumerable yValue, string yFields)
 {
     this.series.TraceWrite("ChartDataBinding", SR.TraceMessagePopulatingSeriesDataPoints(this.series.Name));
     string[] array = null;
     if (yFields != null)
     {
         array = yFields.Replace(",,", "\n").Split(',');
         for (int i = 0; i < array.Length; i++)
         {
             array[i] = array[i].Replace("\n", ",");
         }
     }
     if (yValue == null)
     {
         throw new ArgumentNullException("yValue", SR.ExceptionDataPointInsertionYValueNotSpecified);
     }
     if (yValue is string)
     {
         throw new ArgumentException(SR.ExceptionDataBindYValuesToString, "yValue");
     }
     if (xValue is string)
     {
         throw new ArgumentException(SR.ExceptionDataBindXValuesToString, "xValue");
     }
     if (array != null && array.GetLength(0) <= this.series.YValuesPerPoint)
     {
         this.array.Clear();
         IEnumerator enumerator           = null;
         IEnumerator dataSourceEnumerator = DataPointCollection.GetDataSourceEnumerator(yValue);
         if (dataSourceEnumerator.GetType() != typeof(DbEnumerator))
         {
             dataSourceEnumerator.Reset();
         }
         if (xValue != null)
         {
             if (xValue != yValue)
             {
                 enumerator = DataPointCollection.GetDataSourceEnumerator(xValue);
                 if (enumerator.GetType() != typeof(DbEnumerator))
                 {
                     enumerator.Reset();
                 }
             }
             else
             {
                 enumerator = dataSourceEnumerator;
             }
         }
         bool     flag   = false;
         bool     flag2  = true;
         object[] array2 = new object[array.Length];
         object   obj    = null;
         bool     flag3  = true;
         do
         {
             if (flag2)
             {
                 flag2 = dataSourceEnumerator.MoveNext();
             }
             if (xValue != null)
             {
                 if (xValue != yValue)
                 {
                     flag = enumerator.MoveNext();
                     if (flag2 && !flag)
                     {
                         throw new ArgumentOutOfRangeException("xValue", SR.ExceptionDataPointInsertionXValuesQtyIsLessYValues);
                     }
                 }
                 else
                 {
                     flag = flag2;
                 }
             }
             if (flag3)
             {
                 flag3 = false;
                 DataPointCollection.AutoDetectValuesType(this.series, enumerator, xField, dataSourceEnumerator, array[0]);
             }
             if (flag || flag2)
             {
                 DataPoint dataPoint = new DataPoint(this.series);
                 bool      flag4     = false;
                 if (flag)
                 {
                     obj = DataPointCollection.ConvertEnumerationItem(enumerator.Current, xField);
                     if (DataPointCollection.IsEmptyValue(obj))
                     {
                         flag4 = true;
                         obj   = 0.0;
                     }
                 }
                 if (array.Length == 0)
                 {
                     array2[0] = DataPointCollection.ConvertEnumerationItem(dataSourceEnumerator.Current, null);
                     if (DataPointCollection.IsEmptyValue(array2[0]))
                     {
                         flag4     = true;
                         array2[0] = 0.0;
                     }
                 }
                 else
                 {
                     for (int j = 0; j < array.Length; j++)
                     {
                         array2[j] = DataPointCollection.ConvertEnumerationItem(dataSourceEnumerator.Current, array[j]);
                         if (DataPointCollection.IsEmptyValue(array2[j]))
                         {
                             flag4     = true;
                             array2[j] = 0.0;
                         }
                     }
                 }
                 if (flag4)
                 {
                     if (obj != null)
                     {
                         dataPoint.SetValueXY(obj, array2);
                     }
                     else
                     {
                         dataPoint.SetValueXY(0, array2);
                     }
                     this.DataPointInit(ref dataPoint);
                     dataPoint.Empty = true;
                     this.array.Add(dataPoint);
                 }
                 else
                 {
                     if (obj != null)
                     {
                         dataPoint.SetValueXY(obj, array2);
                     }
                     else
                     {
                         dataPoint.SetValueXY(0, array2);
                     }
                     this.DataPointInit(ref dataPoint);
                     this.array.Add(dataPoint);
                 }
             }
         }while (flag || flag2);
         this.series.TraceWrite("ChartDataBinding", SR.TraceMessageSeriesPopulatedWithDataPoints(this.series.Name, this.array.Count.ToString(CultureInfo.CurrentCulture)));
         return;
     }
     throw new ArgumentOutOfRangeException("yValue", SR.ExceptionDataPointYValuesCountMismatch(this.series.YValuesPerPoint.ToString(CultureInfo.InvariantCulture)));
 }
Example #19
0
 public void DataBindXY(IEnumerable xValue, params IEnumerable[] yValues)
 {
     this.series.TraceWrite("ChartDataBinding", SR.TraceMessagePopulatingSeriesDataPoints(this.series.Name));
     for (int i = 0; i < yValues.Length; i++)
     {
         if (yValues[i] is string)
         {
             throw new ArgumentException(SR.ExceptionDataBindYValuesToString, "yValues");
         }
     }
     if (yValues != null && yValues.GetLength(0) != 0)
     {
         if (yValues.GetLength(0) > this.series.YValuesPerPoint)
         {
             throw new ArgumentOutOfRangeException("yValues", SR.ExceptionDataPointYValuesBindingCountMismatch(this.series.YValuesPerPoint.ToString(CultureInfo.InvariantCulture)));
         }
         this.array.Clear();
         IEnumerator   enumerator = null;
         IEnumerator[] array      = new IEnumerator[yValues.GetLength(0)];
         if (xValue != null)
         {
             if (xValue is string)
             {
                 throw new ArgumentException(SR.ExceptionDataBindXValuesToString, "xValue");
             }
             enumerator = DataPointCollection.GetDataSourceEnumerator(xValue);
             if (enumerator.GetType() != typeof(DbEnumerator))
             {
                 enumerator.Reset();
             }
         }
         for (int j = 0; j < yValues.Length; j++)
         {
             array[j] = DataPointCollection.GetDataSourceEnumerator(yValues[j]);
             if (array[j].GetType() != typeof(DbEnumerator))
             {
                 array[j].Reset();
             }
         }
         bool     flag   = false;
         bool     flag2  = true;
         object[] array2 = new object[this.series.YValuesPerPoint];
         object   obj    = null;
         bool     flag3  = true;
         do
         {
             flag2 = true;
             for (int k = 0; k < yValues.Length; k++)
             {
                 if (flag2)
                 {
                     flag2 = array[k].MoveNext();
                 }
             }
             if (xValue != null)
             {
                 flag = enumerator.MoveNext();
                 if (flag2 && !flag)
                 {
                     throw new ArgumentOutOfRangeException("xValue", SR.ExceptionDataPointInsertionXValuesQtyIsLessYValues);
                 }
             }
             if (flag3)
             {
                 flag3 = false;
                 DataPointCollection.AutoDetectValuesType(this.series, enumerator, null, array[0], null);
             }
             if (flag || flag2)
             {
                 DataPoint dataPoint = new DataPoint(this.series);
                 bool      flag4     = false;
                 if (flag)
                 {
                     obj = DataPointCollection.ConvertEnumerationItem(enumerator.Current, null);
                     if (obj is DBNull || obj == null)
                     {
                         flag4 = true;
                         obj   = 0.0;
                     }
                 }
                 for (int l = 0; l < yValues.Length; l++)
                 {
                     array2[l] = DataPointCollection.ConvertEnumerationItem(array[l].Current, null);
                     if (array2[l] is DBNull || array2[l] == null)
                     {
                         flag4     = true;
                         array2[l] = 0.0;
                     }
                 }
                 if (flag4)
                 {
                     if (obj != null)
                     {
                         dataPoint.SetValueXY(obj, array2);
                     }
                     else
                     {
                         dataPoint.SetValueXY(0, array2);
                     }
                     this.DataPointInit(ref dataPoint);
                     dataPoint.Empty = true;
                     this.array.Add(dataPoint);
                 }
                 else
                 {
                     if (obj != null)
                     {
                         dataPoint.SetValueXY(obj, array2);
                     }
                     else
                     {
                         dataPoint.SetValueXY(0, array2);
                     }
                     this.DataPointInit(ref dataPoint);
                     this.array.Add(dataPoint);
                 }
             }
         }while (flag || flag2);
         this.series.TraceWrite("ChartDataBinding", SR.TraceMessageSeriesPopulatedWithDataPoints(this.series.Name, this.array.Count.ToString(CultureInfo.CurrentCulture)));
         return;
     }
     throw new ArgumentNullException("yValues", SR.ExceptionDataPointBindingYValueNotSpecified);
 }
Example #20
0
 public void DataBind(IEnumerable dataSource, string xField, string yFields, string otherFields)
 {
     this.series.TraceWrite("ChartDataBinding", SR.TraceMessagePopulatingSeriesDataPoints(this.series.Name));
     string[] array = null;
     if (yFields != null)
     {
         array = yFields.Replace(",,", "\n").Split(',');
         for (int i = 0; i < array.Length; i++)
         {
             array[i] = array[i].Replace("\n", ",");
         }
     }
     string[] array2 = null;
     string[] array3 = null;
     string[] array4 = null;
     DataPointCollection.ParsePointFieldsParameter(otherFields, ref array2, ref array3, ref array4);
     if (dataSource == null)
     {
         throw new ArgumentNullException("dataSource", SR.ExceptionDataPointInsertionNoDataSource);
     }
     if (dataSource is string)
     {
         throw new ArgumentException(SR.ExceptionDataBindSeriesToString, "dataSource");
     }
     if (array != null && array.GetLength(0) <= this.series.YValuesPerPoint)
     {
         this.array.Clear();
         IEnumerator dataSourceEnumerator = DataPointCollection.GetDataSourceEnumerator(dataSource);
         if (dataSourceEnumerator.GetType() != typeof(DbEnumerator))
         {
             dataSourceEnumerator.Reset();
         }
         bool     flag   = true;
         object[] array5 = new object[array.Length];
         object   obj    = null;
         bool     flag2  = true;
         do
         {
             if (flag)
             {
                 flag = dataSourceEnumerator.MoveNext();
             }
             if (flag2)
             {
                 flag2 = false;
                 DataPointCollection.AutoDetectValuesType(this.series, dataSourceEnumerator, xField, dataSourceEnumerator, array[0]);
             }
             if (flag)
             {
                 DataPoint dataPoint = new DataPoint(this.series);
                 bool      flag3     = false;
                 if (xField.Length > 0)
                 {
                     obj = DataPointCollection.ConvertEnumerationItem(dataSourceEnumerator.Current, xField);
                     if (DataPointCollection.IsEmptyValue(obj))
                     {
                         flag3 = true;
                         obj   = 0.0;
                     }
                 }
                 if (array.Length == 0)
                 {
                     array5[0] = DataPointCollection.ConvertEnumerationItem(dataSourceEnumerator.Current, null);
                     if (DataPointCollection.IsEmptyValue(array5[0]))
                     {
                         flag3     = true;
                         array5[0] = 0.0;
                     }
                 }
                 else
                 {
                     for (int j = 0; j < array.Length; j++)
                     {
                         array5[j] = DataPointCollection.ConvertEnumerationItem(dataSourceEnumerator.Current, array[j]);
                         if (DataPointCollection.IsEmptyValue(array5[j]))
                         {
                             flag3     = true;
                             array5[j] = 0.0;
                         }
                     }
                 }
                 if (array2 != null && array2.Length > 0)
                 {
                     for (int k = 0; k < array3.Length; k++)
                     {
                         object obj2 = DataPointCollection.ConvertEnumerationItem(dataSourceEnumerator.Current, array3[k]);
                         if (!DataPointCollection.IsEmptyValue(obj2))
                         {
                             dataPoint.SetPointAttribute(obj2, array2[k], array4[k]);
                         }
                     }
                 }
                 if (flag3)
                 {
                     if (obj != null)
                     {
                         dataPoint.SetValueXY(obj, array5);
                     }
                     else
                     {
                         dataPoint.SetValueXY(0, array5);
                     }
                     this.DataPointInit(ref dataPoint);
                     dataPoint.Empty = true;
                     this.array.Add(dataPoint);
                 }
                 else
                 {
                     if (obj != null)
                     {
                         dataPoint.SetValueXY(obj, array5);
                     }
                     else
                     {
                         dataPoint.SetValueXY(0, array5);
                     }
                     this.DataPointInit(ref dataPoint);
                     this.array.Add(dataPoint);
                 }
             }
         }while (flag);
         this.series.TraceWrite("ChartDataBinding", SR.TraceMessageSeriesPopulatedWithDataPoints(this.series.Name, this.array.Count.ToString(CultureInfo.CurrentCulture)));
         return;
     }
     throw new ArgumentOutOfRangeException("yFields", SR.ExceptionDataPointYValuesCountMismatch(this.series.YValuesPerPoint.ToString(CultureInfo.InvariantCulture)));
 }
        public void DataBindCrossTab(IEnumerable dataSource, string seriesGroupByField, string xField, string yFields, string otherFields, bool sort, PointsSortOrder sortingOrder)
        {
            ArrayList arrayList  = new ArrayList();
            ArrayList arrayList2 = new ArrayList();

            string[] array = null;
            if (yFields != null)
            {
                array = yFields.Replace(",,", "\n").Split(',');
                for (int i = 0; i < array.Length; i++)
                {
                    array[i] = array[i].Replace("\n", ",");
                }
            }
            string[] array2 = null;
            string[] array3 = null;
            string[] array4 = null;
            DataPointCollection.ParsePointFieldsParameter(otherFields, ref array2, ref array3, ref array4);
            if (dataSource == null)
            {
                throw new ArgumentNullException("dataSource", SR.ExceptionDataPointInsertionNoDataSource);
            }
            if (dataSource is string)
            {
                throw new ArgumentException(SR.ExceptionDataBindSeriesToString, "dataSource");
            }
            if (array != null && array.Length != 0)
            {
                if (seriesGroupByField != null && seriesGroupByField.Length != 0)
                {
                    IEnumerator dataSourceEnumerator = DataPointCollection.GetDataSourceEnumerator(dataSource);
                    if (dataSourceEnumerator.GetType() != typeof(DbEnumerator))
                    {
                        try
                        {
                            dataSourceEnumerator.Reset();
                        }
                        catch
                        {
                        }
                    }
                    bool     flag   = true;
                    object[] array5 = new object[array.Length];
                    object   obj2   = null;
                    bool     flag2  = true;
                    do
                    {
                        if (flag)
                        {
                            flag = dataSourceEnumerator.MoveNext();
                        }
                        if (flag)
                        {
                            object obj3   = DataPointCollection.ConvertEnumerationItem(dataSourceEnumerator.Current, seriesGroupByField);
                            Series series = null;
                            int    num    = arrayList2.IndexOf(obj3);
                            if (num >= 0)
                            {
                                series = (Series)arrayList[num];
                            }
                            else
                            {
                                series = new Series();
                                series.YValuesPerPoint = array.GetLength(0);
                                if (arrayList.Count > 0)
                                {
                                    series.XValueType     = ((Series)arrayList[0]).XValueType;
                                    series.autoXValueType = ((Series)arrayList[0]).autoXValueType;
                                    series.YValueType     = ((Series)arrayList[0]).YValueType;
                                    series.autoYValueType = ((Series)arrayList[0]).autoYValueType;
                                }
                                if (obj3 is string)
                                {
                                    series.Name = (string)obj3;
                                }
                                else
                                {
                                    series.Name = seriesGroupByField + " - " + obj3.ToString();
                                }
                                arrayList2.Add(obj3);
                                arrayList.Add(series);
                            }
                            if (flag2)
                            {
                                flag2 = false;
                                DataPointCollection.AutoDetectValuesType(series, dataSourceEnumerator, xField, dataSourceEnumerator, array[0]);
                            }
                            DataPoint dataPoint = new DataPoint(series);
                            bool      flag3     = false;
                            if (xField.Length > 0)
                            {
                                obj2 = DataPointCollection.ConvertEnumerationItem(dataSourceEnumerator.Current, xField);
                                if (DataPointCollection.IsEmptyValue(obj2))
                                {
                                    flag3 = true;
                                    obj2  = 0.0;
                                }
                            }
                            if (array.Length == 0)
                            {
                                array5[0] = DataPointCollection.ConvertEnumerationItem(dataSourceEnumerator.Current, null);
                                if (DataPointCollection.IsEmptyValue(array5[0]))
                                {
                                    flag3     = true;
                                    array5[0] = 0.0;
                                }
                            }
                            else
                            {
                                for (int j = 0; j < array.Length; j++)
                                {
                                    array5[j] = DataPointCollection.ConvertEnumerationItem(dataSourceEnumerator.Current, array[j]);
                                    if (DataPointCollection.IsEmptyValue(array5[j]))
                                    {
                                        flag3     = true;
                                        array5[j] = 0.0;
                                    }
                                }
                            }
                            if (array2 != null && array2.Length > 0)
                            {
                                for (int k = 0; k < array3.Length; k++)
                                {
                                    object obj4 = DataPointCollection.ConvertEnumerationItem(dataSourceEnumerator.Current, array3[k]);
                                    if (!DataPointCollection.IsEmptyValue(obj4))
                                    {
                                        dataPoint.SetPointAttribute(obj4, array2[k], array4[k]);
                                    }
                                }
                            }
                            if (flag3)
                            {
                                if (obj2 != null)
                                {
                                    dataPoint.SetValueXY(obj2, array5);
                                }
                                else
                                {
                                    dataPoint.SetValueXY(0, array5);
                                }
                                DataPointCollection.DataPointInit(series, ref dataPoint);
                                dataPoint.Empty = true;
                                series.Points.Add(dataPoint);
                            }
                            else
                            {
                                if (obj2 != null)
                                {
                                    dataPoint.SetValueXY(obj2, array5);
                                }
                                else
                                {
                                    dataPoint.SetValueXY(0, array5);
                                }
                                DataPointCollection.DataPointInit(series, ref dataPoint);
                                series.Points.Add(dataPoint);
                            }
                        }
                    }while (flag);
                    if (sort)
                    {
                        ArrayList arrayList3 = (ArrayList)arrayList2.Clone();
                        arrayList2.Sort();
                        if (sortingOrder == PointsSortOrder.Descending)
                        {
                            arrayList2.Reverse();
                        }
                        ArrayList arrayList4 = new ArrayList();
                        foreach (object item in arrayList2)
                        {
                            arrayList4.Add(arrayList[arrayList3.IndexOf(item)]);
                        }
                        arrayList = arrayList4;
                    }
                    foreach (Series item2 in arrayList)
                    {
                        base.common.Chart.Series.Add(item2);
                    }
                    return;
                }
                throw new ArgumentException(SR.ExceptionDataBindSeriesGroupByParameterIsEmpty, "seriesGroupByField");
            }
            throw new ArgumentOutOfRangeException("yFields", SR.ExceptionChartDataPointsInsertionFailedYValuesEmpty);
        }