Ejemplo n.º 1
0
        internal static DataPoint GetDataPoint(Type dataPointType, Transaction transaction, decimal total)
        {
            DataPoint dataPoint = null;

            if (dataPointType == typeof(LineChartDataPoint))
            {
                dataPoint = new LineChartDataPoint
                {
                    X = transaction.Date,
                    Y = total,
                };
            }
            else if (dataPointType == typeof(PieChartDataPoint))
            {
                dataPoint = new PieChartDataPoint
                {
                    Name  = transaction.Payee,
                    Value = transaction.Amount,
                };
            }
            else
            {
                throw new ArgumentException($"Invalid Data Point Type {dataPointType}");
            }
            return(dataPoint);
        }
Ejemplo n.º 2
0
        protected override void LoadDataPoints()
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                DataFilter filter = GetFilter(ReportType);
                DataPoints.Clear();
                var dataPoints = filter.Filter <PieChartDataPoint>(_dataModel.Transactions, StartDate, EndDate);

                foreach (var dataPoint in dataPoints)
                {
                    DataPoint existingDataPoint = GetDataPoint(dataPoint.Name);

                    if (existingDataPoint != null)
                    {
                        PieChartDataPoint newDataPoint = new PieChartDataPoint
                        {
                            Name  = dataPoint.Name,
                            Value = ((PieChartDataPoint)existingDataPoint).Value += dataPoint.Value,
                        };

                        DataPoints.Remove(existingDataPoint);
                        DataPoints.Add(newDataPoint);
                    }
                    else
                    {
                        DataPoints.Add(dataPoint);
                    }
                }
            });
        }