void GenerateProjectData(ref ChartJsData chartJsData, IEnumerable <ProjectData> datas) { foreach (var data in datas) { chartJsData.Data.Add(data.Name, data.TimeSpan.TotalHours); } }
ChartJsData GenerateCommonData(DataAnalyzer.DataType dataType, string name) { var chartJsData = new ChartJsData(); chartJsData.DataName = name; GenerateProjectData(ref chartJsData, dataAnalyzer.Get(dataType).OrderByDescending(x => x.TotalSeconds)); return(chartJsData); }
ChartJsData GenerateProjectsList() { var chartJsData = new ChartJsData(); chartJsData.DataName = "projectsData"; var data = dataAnalyzer.GetProjects().OrderByDescending(m => m.TotalSeconds).Cast <ProjectData>(); GenerateProjectData(ref chartJsData, data); return(chartJsData); }
ChartJsData GenerateBestDay() { var startDate = dataAnalyzer.GetStartDate(); var endDate = dataAnalyzer.GetEndDate(); var chartJsData = new ChartJsData(); chartJsData.DataName = "bestDayData"; for (int year = startDate.Year; year <= endDate.Year; year++) { var bestDay = dataAnalyzer.GetBestDay(new DateTime(year, 1, 1), new DateTime(year, 12, 31)); chartJsData.Data.Add(year.ToString(), bestDay.GrandTotal.TimeSpan.TotalHours); } return(chartJsData); }
ChartJsData GenerateDailyAverage() { var startDate = dataAnalyzer.GetStartDate(); var endDate = dataAnalyzer.GetEndDate(); var chartJsData = new ChartJsData(); chartJsData.DataName = "averageData"; chartJsData.Data.Add("All time", dataAnalyzer.GetDailyAverage().TotalHours); for (int year = startDate.Year; year <= endDate.Year; year++) { var total = dataAnalyzer.GetDailyAverage(new DateTime(year, 1, 1), new DateTime(year, 12, 31)); chartJsData.Data.Add(year.ToString(), total.TotalHours); } return(chartJsData); }