void PieChart_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            DependencyObject d = e.OriginalSource as DependencyObject;

            if (e == null)
            {
                return;
            }
            while (d != null)
            {
                FrameworkElement f = d as FrameworkElement;
                if (f != null && f.DataContext != null)
                {
                    CategoryData data = f.DataContext as CategoryData;
                    if (data != null)
                    {
                        Selection = data;
                        return;
                    }
                }
                d = VisualTreeHelper.GetParent(d);
            }
        }
        bool Tally(Transaction t, Category c, decimal total, bool expense)
        {
            // ALERT: this method has to be kept in sync with WillTally

            if (c == null)
            {
                c = unassigned;
            }

            switch (this.CategoryType)
            {
            case CategoryType.None:
                if (c.Type != Data.CategoryType.None && c.Type != Data.CategoryType.Transfer)
                {
                    return(false);
                }
                break;

            case CategoryType.Income:
                if (c.Type != Data.CategoryType.Income && c.Type != Data.CategoryType.Savings)
                {
                    return(false);
                }
                break;

            case CategoryType.Expense:
                if (c.Type != Data.CategoryType.Expense)
                {
                    return(false);
                }
                break;

            default:
                System.Diagnostics.Debug.Assert(false, "Unexpected category type here, need to change this code if you want a chart of these");
                return(false);
            }

            if (filter == null)
            {
                c = c.Root;
            }
            else
            {
                while (c != null && c != filter && c.ParentCategory != filter)
                {
                    // then we are looking at a "grand child category", so need to roll this up to the child category
                    c = c.ParentCategory;
                }
                if (c == null)
                {
                    return(false);
                }
            }

            CategoryData cd;

            if (!map.TryGetValue(c, out cd))
            {
                map[c] = cd = new CategoryData(c);

                if (string.IsNullOrWhiteSpace(c.InheritedColor))
                {
                    c.Root.Color = cd.Color.ToString();
                }
            }

            cd.Transactions.Add(t);

            cd.Total += (double)total;
            return(true);
        }