示例#1
0
        /// <summary>
        /// Get completion graph components such as marking, axis, and series.
        /// </summary>
        /// <param name="statsFromDb">DTOStatistic collection from db.</param>
        /// <returns>A DTOCompletionStatistic object that corresponds to the completion graph.</returns>
        private DTOCompletionStatistic getCompletionGraphComponents(List <DTOStatistic> statsFromDb)
        {
            var totalTasks = statsFromDb.Count > 0 ? statsFromDb.FirstOrDefault().TotalItems : 0;

            // Get completion serie
            var completionSerieSeconds = (from completionRecord in statsFromDb.Select(z => new { Id = z.Id, CompletedTasks = z.DescendingItemComplete })
                                          join timeRecord in statsFromDb.Select(z => new { Id = z.Id, z.AcumulativeTimeInSeconds })
                                          on completionRecord.Id equals timeRecord.Id
                                          select new double[] { timeRecord.AcumulativeTimeInSeconds, completionRecord.CompletedTasks }).ToList();

            // Get completion axis
            var completionAxis = new DTOAxisLimitJqueryFlot
            {
                ThereIsY = true,
                FromY    = 0,
                ToY      = totalTasks
            };

            // Get completion markings
            var completionMarkings = new List <DTOMarkingsJqueryFlot>
            {
                new DTOMarkingsJqueryFlot
                {
                    IsY   = true,
                    YLine = totalTasks * 0.5,
                    Color = Hp.getStringFromAppConfig("completionMarkings")
                }
            };

            // Get estimation serie by using regression
            var xData = completionSerieSeconds.Select(x => x[0]).ToArray();
            var yData = completionSerieSeconds.Select(x => x[1]).ToArray();
            var regressionParameters = Hp.getRegressionParameters(xData, yData);

            var             averageFinishTimeSeconds    = -regressionParameters.Interception / regressionParameters.Slope;
            var             averageRemainingTimeSeconds = averageFinishTimeSeconds - xData.Max();
            List <double[]> estimationLineSeconds       = new List <double[]>
            {
                new double[] { xData.Min(), xData.Min() *regressionParameters.Slope + regressionParameters.Interception },
                new double[] { averageFinishTimeSeconds, 0 }
            };

            // Map DTO and return it
            return(new DTOCompletionStatistic
            {
                CompletionSerieSeconds = completionSerieSeconds,
                EstimationSerieSeconds = estimationLineSeconds,
                AverageCompletionTimeSeconds = averageFinishTimeSeconds,
                AverageRemainingTimeSeconds = averageRemainingTimeSeconds,
                CompletionAxisLimits = completionAxis,
                CompletionMarkings = completionMarkings,
                R = Math.Round(regressionParameters.R, 2)
            });
        }
示例#2
0
        /// <summary>
        /// Get acumulative graph components such as marking, axis, and series.
        /// </summary>
        /// <param name="statsFromDb">DTOStatistic collection from db.</param>
        /// <returns>A DTOAcumulativeStatistic object that corresponds to the acumulative graph.</returns>
        private DTOAcumulativeStatistic getAcumulativeGraphComponents(List <DTOStatistic> statsFromDb)
        {
            // Get serie
            var acumulativeSerie = (from percentageRecord in statsFromDb.Select(z => new { Id = z.Id, Percentage = z.PercentageComplete })
                                    join timeRecord in statsFromDb.Select(z => new { Id = z.Id, z.AcumulativeTimeInSeconds })
                                    on percentageRecord.Id equals timeRecord.Id
                                    select new double[] { timeRecord.AcumulativeTimeInSeconds, percentageRecord.Percentage }).ToList();

            // Get average
            var acumulativeAverage = statsFromDb.Average(x => x.VelocityInPercentagePerSeconds);

            // Get markings
            var acumulativeMarkings = new List <DTOMarkingsJqueryFlot>
            {
                new DTOMarkingsJqueryFlot
                {
                    IsY   = true,
                    YLine = Hp.getIntegerFromAppConfig("acumulativeMarkingHorizontalLine"),
                    Color = Hp.getStringFromAppConfig("acumulativeMarkings")
                }
            };

            // Get axis
            var acumulativeAxis = new DTOAxisLimitJqueryFlot
            {
                ThereIsY = true,
                FromY    = Hp.getIntegerFromAppConfig("acumulativeAxisFromY"),
                ToY      = Hp.getIntegerFromAppConfig("acumulativeAxisToY")
            };

            // Map DTO and return it
            return(new DTOAcumulativeStatistic
            {
                AveragePercentageSeconds = acumulativeAverage,
                AcumulativeSerieSeconds = acumulativeSerie,
                AcumulativeMarkings = acumulativeMarkings,
                AcumulativeAxisLimits = acumulativeAxis
            });
        }