Example #1
0
        public int Compare(object x, object y)
        {
            Group gx = (Group)x;
            Group gy = (Group)y;

            bool strongTyped = false;

            if (strongTyped)
            {
                // strong typed   (propertyName is ignored ...)
                DoubleAggregateSummary dasx = (DoubleAggregateSummary)gx.GetSummary(summaryDescriptorName);
                DoubleAggregateSummary dasy = (DoubleAggregateSummary)gy.GetSummary(summaryDescriptorName);

                int v = dasx.Average.CompareTo(dasy.Average);

                return(v);
            }
            else
            {
                // using reflection (slower but more flexible using propertyName)
                object vx = gx.GetSummaryProperty(summaryDescriptorName, propertyName);
                object vy = gy.GetSummaryProperty(summaryDescriptorName, propertyName);

                return(((IComparable)vx).CompareTo(vy));
            }
        }
Example #2
0
        public virtual void PopulateWithListChoices()
        {
            this.Clear();

            //xxx is a dummy fieldname just to satisfy the constructor
            DoubleAggregateSummary sum = DoubleAggregateSummary.Empty;// new DoubleAggregateSummary(0, double.MaxValue, double.MinValue, 0d);

            this.Add(new PivotComputationInfo(sum, "Sum", "Sum of {*}", "xxx"));
            this.Add(new PivotComputationInfo(sum, "Average", "Average of {*}", "xxx"));

            DoubleVectorSummary v = DoubleVectorSummary.Empty;// new DoubleVectorSummary(new double[] { 1, 2, 3 }, 3);// any will do

            this.Add(new PivotComputationInfo(v, "Median", "Median of {*}", "xxx"));
            this.Add(new PivotComputationInfo(v, "Percentile25", "25 Percentile of {*}", "xxx"));
            this.Add(new PivotComputationInfo(v, "Percentile75", "75 Percentile of {*}", "xxx"));

            CountSummary c = CountSummary.Empty;// new VectorSummary(null, 0);

            this.Add(new PivotComputationInfo(c, "Count", "Count of {*}", "xxx"));

            DoubleStdDevSummary sd = DoubleStdDevSummary.Empty;

            this.Add(new PivotComputationInfo(sd, "StdDev", "StDev of {*}", "xxx"));
            this.Add(new PivotComputationInfo(sd, "StdDevP", "StDevP of {*}", "xxx"));
            this.Add(new PivotComputationInfo(sd, "Var", "Var of {*}", "xxx"));
            this.Add(new PivotComputationInfo(sd, "VarP", "VarP of {*}", "xxx"));
        }
Example #3
0
        public void Run()
        {
            foreach (Element el in engine1.Table.DisplayElements)
            {
                Console.WriteLine(el.ToString());
                if (el is Syncfusion.Grouping.SummarySection)
                {
                    // Cast summary to correct type before accessing idividual summary properties
                    Console.WriteLine("Summaries:");
                    ITreeTableSummary[] summaries = el.ParentGroup.GetSummaries(el.ParentTable);

                    DoubleAggregateSummary d0 = (DoubleAggregateSummary)summaries[el.ParentTableDescriptor.Summaries.IndexOf(sd0)];
                    Console.WriteLine("QuantityAverage = {0}", d0.Average);

                    TotalSummary d1 = (TotalSummary)summaries[el.ParentTableDescriptor.Summaries.IndexOf(sd1)];
                    Console.WriteLine("QuantityDistinctCount = {0}", d1.Total);

                    DistinctInt32CountSummary d2 = (DistinctInt32CountSummary)summaries[el.ParentTableDescriptor.Summaries.IndexOf(sd2)];
                    Console.WriteLine("QuantityTotal = {0}", d2.Count);

                    StatisticsSummary d3 = (StatisticsSummary)summaries[el.ParentTableDescriptor.Summaries.IndexOf(sd3)];
                    Console.WriteLine("QuantityMedian = {0}", d3.Median);

                    Console.WriteLine("QuantityAverage = {0}", GetAverageSummary(sd0, el.ParentGroup));
                }
            }
        }
Example #4
0
        /// <summary>
        /// This code works with base engine, no dependency on GridEngine / GridSummaryColumnDescriptor etc.
        /// </summary>
        string GetAverageSummary(SummaryDescriptor summaryDescriptor, Group group)
        {
            Table           table       = group.ParentTable;
            TableDescriptor td          = table.TableDescriptor;
            string          summaryText = "";

            bool use31Code = true;

            if (use31Code)
            {
                // Option 1: Strong typed access to DoubleAggregateSummary.
                DoubleAggregateSummary summary1 = (DoubleAggregateSummary)group.GetSummary(summaryDescriptor);
                summaryText = string.Format("{0:c}", summary1.Average);

                // or Option 2: Use reflection to get "Average" property of summary
                summaryText = string.Format("{0:c}", group.GetSummaryProperty(summaryDescriptor, "Average"));
            }

            else
            {
                // This is the code you had to use in version 3.0 and earlier (still working but bit more complicate)
                if (summaryDescriptor != null)
                {
                    int indexOfSd1 = table.TableDescriptor.Summaries.IndexOf(summaryDescriptor);

                    // strong typed - you have to cast to DoubleAggregateSummary.

                    DoubleAggregateSummary summary1 = (DoubleAggregateSummary)group.GetSummaries(table)[indexOfSd1];
                    summaryText = string.Format("{0:c}", summary1.Average);
                }
            }
            return(summaryText);
        }
Example #5
0
        /// <summary>
        /// Demonstrates different alternatives to get to the summary text (strong typed vs GridSummaryColumnDescriptor.Format)
        /// </summary>
        string GetSummaryText(Group group, GridSummaryColumnDescriptor scd)
        {
            GridTable           table = (GridTable)group.ParentTable;
            GridTableDescriptor td    = table.TableDescriptor;

            string summaryText = "";

            bool use31Code = true;

            if (use31Code)
            {
                if (scd != null)
                {
                    // Option 1: GetDisplayText - this is actually the code used when you simply would call
                    // e.Style.Text = ((GridTable) table).GetSummaryText(group, "SummaryRow 1", "FreightAverage");
                    //
                    // Text is formatted as defined in GridSummaryColumnDescriptor.Format
                    summaryText = scd.GetDisplayText(group);

                    // or Option 2: Strong typed access to DoubleAggregateSummary.
                    DoubleAggregateSummary summary1 = (DoubleAggregateSummary)group.GetSummary(scd.SummaryDescriptor);
                    summaryText = string.Format("{0:c}", summary1.Average);

                    // or Option 3: Use reflection to get "Average" property of summary
                    summaryText = string.Format("{0:c}", group.GetSummaryProperty(scd.SummaryDescriptor, "Average"));
                }
            }
            else
            {
                // This is the code you had to use in version 3.0 and earlier (still working but bit more complicate)
                if (scd != null)
                {
                    SummaryDescriptor sd1 = scd.SummaryDescriptor;
                    if (sd1 != null)
                    {
                        int indexOfSd1 = table.TableDescriptor.Summaries.IndexOf(sd1);

                        ISummary sum1  = group.GetSummaries(table)[indexOfSd1];
                        string   text1 = scd.GetDisplayText(sum1);
                        summaryText = text1;

                        // - or - (access value directly)
                        // strong typed - you have to cast to Int32AggregateSummary.

                        DoubleAggregateSummary summary1 = (DoubleAggregateSummary)group.GetSummaries(table)[indexOfSd1];
                        summaryText = string.Format("{0:c}", summary1.Average);
                    }
                }
            }

            return(summaryText);
        }
 public double[] GetY(int yIndex)
 {
     if (this.DilutionFactor > 1)
     {
         // Return the average of the point values that were grouped into 1.
         DoubleAggregateSummary summary = this.engine.Table.TopLevelGroup.Groups[yIndex].GetSummary(0) as DoubleAggregateSummary;
         return(new double[] { summary.Average });
     }
     else
     {
         return(new double[] { Double.Parse(this.engine.Table.Records[yIndex].GetValue(this.yName).ToString()) });
     }
 }
        /// <summary>
        /// Returns the Max Y value in the data source.
        /// </summary>
        public double GetMaxY()
        {
            DoubleAggregateSummary summary = this.engine.Table.TopLevelGroup.GetSummary(0) as DoubleAggregateSummary;

            return(summary.Maximum);
        }