Пример #1
0
        private TrendGraphSeries AddSeries(DateTime start, DateTime end, Color color)
        {
            ChartCategory cat = new ChartCategory();

            cat.WpfColor = color;

            nfi.NumberDecimalDigits     = 2;
            nfi.CurrencyNegativePattern = 0;

            TimeSpan span = (end - start);
            int      days = span.Days;

            if (days > 360)
            {
                cat.Name = start.Year.ToString();
            }
            else
            {
                cat.Name = start.ToShortDateString();
            }

            TrendGraphSeries s = new TrendGraphSeries(cat.Name, cat.Name);

            chartData.AddSeries(s);


            if ((this.account != null && this.account.Type == AccountType.Credit) ||
                (this.category != null && this.category.Type == CategoryType.Expense))
            {
                s.Flipped = true;
            }

            IList <ChartValue> timeData = s.Values;

            s.BeginUpdate();

            bool        first   = true;
            double      balance = this.account != null ? (double)this.account.OpeningBalance : 0;
            DateTime    last    = start;
            Transaction lastt   = null;
            bool        started = this.account != null;

            foreach (object row in data)
            {
                Transaction t = row as Transaction;
                if (t == null)
                {
                    continue;
                }

                if (t.Account == this.account || // showing transactions for an account
                    (account == null))           // showing transactions by category // && ((!t.IsBudgeted && t.Account.IsBudgeted))
                {
                    decimal v = t.GetCategorizedAmount(this.category);
                    if (t.Date >= start && t.Date <= end)
                    {
                        started = true;
                        if (first)
                        {
                            string label = GetLabel(balance, t);
                            timeData.Add(new ChartValue(label, (double)balance, t));
                            first = false;
                        }

                        balance = AddDatum(balance, last, t.Date, t, timeData, (double)v);
                        last    = t.Date;
                        lastt   = t;
                    }
                    if (started)
                    {
                        balance += (double)v;
                    }
                }
            }

            if (last != end && lastt != null)
            {
                balance = AddDatum(balance, last, end, lastt, timeData, 0);
            }

            s.EndUpdate();
            //s.Accumulate = false;
            //s.Color = color;
            s.Category = cat;
            s.Start    = start;
            s.End      = end;

            return(s);
        }
Пример #2
0
        private TrendGraphSeries AddSeries(DateTime start, DateTime end, Color color)
        {
            ChartCategory cat = new ChartCategory();

            cat.WpfColor = color;

            nfi.NumberDecimalDigits     = 2;
            nfi.CurrencyNegativePattern = 0;

            TimeSpan span = (end - start);
            int      days = span.Days;

            if (days > 360)
            {
                cat.Name = start.Year.ToString();
            }
            else
            {
                cat.Name = start.ToShortDateString();
            }

            TrendGraphSeries s = new TrendGraphSeries(cat.Name, cat.Name);

            chartData.AddSeries(s);

            s.Flipped = generator.IsFlipped;

            IList <ChartValue> timeData = s.Values;

            s.BeginUpdate();

            DateTime   last  = start;
            TrendValue lastv = null;

            foreach (TrendValue v in this.data)
            {
                // calculate balances using data from the start of the account \ list so the end balance is correct
                if (v.Date <= end && v.Date >= start)
                {
                    // If the items are on the same day, don't add to the graph yet.
                    // Accumulate them and the accumulated value for the day will be displayed
                    if (last != v.Date)
                    {
                        AddDatum(v, last, v.Date, timeData);
                    }
                    last  = v.Date;
                    lastv = v;
                }
            }

            // Put the last item on the graph
            if (lastv != null)
            {
                AddDatum(lastv, last, end.AddDays(1), timeData);
            }

            s.EndUpdate();
            //s.Accumulate = false;
            //s.Color = color;
            s.Category = cat;
            s.Start    = start;
            s.End      = end;

            return(s);
        }
Пример #3
0
        private TrendGraphSeries AddSeries(DateTime start, DateTime end, Color color)
        {
            ChartCategory cat = new ChartCategory();

            cat.WpfColor = color;

            nfi.NumberDecimalDigits     = 2;
            nfi.CurrencyNegativePattern = 0;

            TimeSpan span = (end - start);
            int      days = span.Days;

            if (days > 360)
            {
                cat.Name = start.Year.ToString();
            }
            else
            {
                cat.Name = start.ToShortDateString();
            }

            TrendGraphSeries s = new TrendGraphSeries(cat.Name, cat.Name);

            chartData.AddSeries(s);

            s.Flipped = generator.IsFlipped;

            IList <ChartValue> timeData = s.Values;

            s.BeginUpdate();

            TrendValue emptyTrendValue = new TrendValue();

            emptyTrendValue.Value    = 0;
            emptyTrendValue.UserData = null;

            DateTime   last  = start;
            TrendValue lastv = emptyTrendValue;

            foreach (TrendValue v in this.data)
            {
                // NOTE: This list is assumed to be sorted
                if (v.Date > end)
                {
                    break;
                }

                if (v.Date >= start)
                {
                    // If the items are on the same day, don't add to the graph yet.
                    // Accumulate them and the accumulated value for the day will be displayed
                    if (last != v.Date)
                    {
                        AddDatum(lastv, last, v.Date, timeData);
                    }
                    last = v.Date;
                }
                lastv = v;
            }

            // Put the last item on the graph
            AddDatum(lastv, last, end.AddDays(1), timeData);

            s.EndUpdate();
            //s.Accumulate = false;
            //s.Color = color;
            s.Category = cat;
            s.Start    = start;
            s.End      = end;

            return(s);
        }