Ejemplo n.º 1
0
        /// <summary>
        /// Builds an overview A1-Mix graph for the user to add to a graph
        /// </summary>
        /// <param name="project"></param>
        /// <returns></returns>
        public static SeriesCollection BuildBarGraph(CarboProject project)
        {
            List <CarboDataPoint> pointCollection = new List <CarboDataPoint>();

            // get the current Project
            pointCollection = project.getPhaseTotals();

            SeriesCollection result = new SeriesCollection();

            //Build series

            foreach (CarboDataPoint pont in pointCollection)
            {
                StackedColumnSeries series = new StackedColumnSeries
                {
                    Values = new ChartValues <double>
                    {
                        Math.Round((pont.Value / 1000), 2),
                    },
                    StackMode  = StackMode.Values,
                    DataLabels = true,
                    Title      = pont.Name
                };

                result.Add(series);
            }

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This returns the pie chart of the projects phases total A1-D and Mixed
        /// </summary>
        /// <param name="carboLifeProject"></param>
        /// <returns></returns>
        internal static SeriesCollection GetPieChartTotals(CarboProject carboLifeProject)
        {
            SeriesCollection result = new SeriesCollection();

            try
            {
                List <CarboDataPoint> PieceListLifePoint = new List <CarboDataPoint>();

                PieceListLifePoint = carboLifeProject.getPhaseTotals();

                //Remove the zero's
                for (int i = PieceListLifePoint.Count - 1; i >= 0; i--)
                {
                    CarboDataPoint cp = PieceListLifePoint[i] as CarboDataPoint;
                    if (cp.Value == 0)
                    {
                        PieceListLifePoint.RemoveAt(i);
                    }
                }

                //make positive if negative
                foreach (CarboDataPoint cp in PieceListLifePoint)
                {
                    if (cp.Value < 0)
                    {
                        cp.Name  = "(Negative)" + cp.Name;
                        cp.Value = cp.Value * -1;
                    }
                }


                Func <ChartPoint, string> labelPoint = chartPoint => string.Format("{0} tCO₂", chartPoint.Y, chartPoint.Participation);


                foreach (CarboDataPoint ppin in PieceListLifePoint)
                {
                    PieSeries newSeries = new PieSeries
                    {
                        Title  = ppin.Name,
                        Values = new ChartValues <double> {
                            Math.Round(ppin.Value / 1000, 2)
                        },
                        PushOut    = 1,
                        DataLabels = true,
                        LabelPoint = labelPoint
                    };

                    newSeries.Foreground = Brushes.Black;
                    newSeries.FontWeight = FontWeights.Normal;
                    newSeries.FontStyle  = FontStyles.Normal;
                    newSeries.FontSize   = 12;

                    result.Add(newSeries);
                }
            }
            catch
            {
                return(null);
            }
            return(result);
        }