public ActionResult Chart(String filterString, string title) { List<ChartFilter> filters = new List<ChartFilter>(); Chart chart = new Chart(); if (!String.IsNullOrEmpty(filterString)) { try { filters = (List<ChartFilter>)(new JavaScriptSerializer().Deserialize(filterString, typeof(List<ChartFilter>))); } catch { } if (!String.IsNullOrEmpty(title)) { chart.Title = title; } else { chart.Title = "GO vs SCALA"; } foreach (ChartFilter filter in filters) { if (chart.Filters == null) { chart.Filters = new List<ChartFilter>(); } var langId = filter.LanguageId; byte envId = filter.EnvironmentId; var pc = filter.ProcCounts[0]; var tt = filter.TimeTypeIds[0]; Language lang = null; AppStats.Models.Environment env = null; if (langId != null && envId != null) { lang = db.Languages.Where(l => l.LanguageId == langId).FirstOrDefault(); env = db.Environments.FirstOrDefault(e => e.EnvinronmentId == envId); List<TimeStatistic> recs = db.TimeStatistics.Where(t => t.LanguageId == lang.LanguageId && t.EnvironmentId == env.EnvinronmentId && t.ProcessorCount == pc && t.TimeTypeId == tt && t.DatasetSize >= filter.StartVal && t.DatasetSize <= filter.EndVal).OrderBy(o => o.DatasetSize).ToList(); //chart.Sizes.AddRange( recs.Select(r => r.DatasetSize).Distinct().ToList()); filter.Data = new List<ChartData>(); ChartData cd = new ChartData() { Environment = null, Language = lang }; foreach (TimeStatistic stat in recs) { if (lang.Name.ToLower().Contains("go")) { cd.Data.Add(new Tuple<int, decimal>(stat.DatasetSize, stat.MeanAverage / goDivisor)); } else { cd.Data.Add(new Tuple<int, decimal>(stat.DatasetSize, stat.MeanAverage)); } } if (String.IsNullOrEmpty(filter.Name)) { if (lang.Name.ToLower().Contains("stock")) { filter.Name = String.Format("{0}", lang.Name, env.Name, filter.ProcCounts[0]); } else { filter.Name = String.Format("{0}-{2}pc", lang.Name, env.Name, filter.ProcCounts[0]); } } filter.Data.Add(cd); chart.Filters.Add(filter); } } } //else //{ // chart.Filters.Add(new ChartFilter() { StartVal = startVal }); //} //chart.Sizes = chart.Sizes.Distinct().ToList() ; return View(chart); }
public ActionResult Index() { Chart chart = new Chart(); chart.Filters = new List<ChartFilter>(); chart.Filters.Add(new ChartFilter()); return View(chart); }