Beispiel #1
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));
                }
            }
        }
        protected double[] CombineHelper(StatisticsSummary other, bool distinct, out int length)
        {
            double[] d      = new double[(Count + other.Count)];
            double[] others = other.Values;

            int n1   = 0;
            int n2   = 0;
            int len1 = Count;
            int len2 = other.Count;
            int n3   = 0;

            while (n1 < len1 && n2 < len2)
            {
                int cmp = _Compare(_values[n1], others[n2]);
                if (cmp > 0)
                {
                    d[n3] = (_values[n1++]);
                }
                else if (cmp < 0)
                {
                    d[n3] = (others[n2++]);
                }
                else
                {
                    d[n3] = (_values[n1++]);
                    if (distinct)
                    {
                        n2++;
                    }
                }
                n3++;
            }
            while (n1 < len1)
            {
                d[n3++] = (_values[n1++]);
            }

            while (n2 < len2)
            {
                d[n3++] = (others[n2++]);
            }

            length = n3;
            return(d);
        }
        public StatisticsSummary Combine(StatisticsSummary other)
        {
            int length;

            double[] d = CombineHelper(other, false, out length);
            if (length == this.Count)
            {
                return(this);
            }
            else if (length == other.Count)
            {
                return(other);
            }
            else
            {
                return(new StatisticsSummary(d, length));
            }
        }