public ChartData GetOverallRankedCategories() { int assessmentId = Auth.AssessmentForUser(); ChartData chartData = null; using (CSET_Context context = new CSET_Context()) { var results = new RankedCategoriesMultiResult(); context.LoadStoredProc("[usp_GetOverallRankedCategoriesPage]") .WithSqlParam("assessment_id", assessmentId) .ExecuteStoredProc((handler) => { results.Result1 = handler.ReadToList <usp_getRankedCategories>().ToList(); }); if (results.Count >= 1) { List <double> data = new List <double>(); ChartData overallBars = new ChartData() { backgroundColor = "red", borderWidth = "1", label = "Overall Ranked Categories", data = data }; chartData = new ChartData(); chartData.DataRows = new List <DataRows>(); int i = 1; foreach (usp_getRankedCategories c in results.Result1) { chartData.data.Add((double)(c.prc ?? 0)); chartData.Labels.Add(c.Question_Group_Heading); chartData.DataRows.Add(new DataRows() { failed = (c.nuCount ?? 0), percent = (c.prc ?? 0), total = (c.qc ?? 0), title = c.Question_Group_Heading, rank = i++ }); } } } return(chartData); }
public ChartData GetTopCategories([FromUri] int?total) { if (total == null) { total = 10000; } int assessmentId = Auth.AssessmentForUser(); ChartData chartData = null; using (CSET_Context context = new CSET_Context()) { var results = new RankedCategoriesMultiResult(); context.LoadStoredProc("[usp_GetRankedCategoriesPage]") .WithSqlParam("assessment_id", assessmentId) .ExecuteStoredProc((handler) => { results.Result1 = handler.ReadToList <usp_getRankedCategories>().ToList(); }); if (results.Count >= 1) { List <double> data = new List <double>(); ChartData overallBars = new ChartData() { backgroundColor = "red", borderWidth = "1", label = "Overall Ranked Categories", data = data }; chartData = new ChartData(); foreach (usp_getRankedCategories c in results.Result1.Take((int)total)) { chartData.data.Add((double)c.prc); chartData.Labels.Add(c.Question_Group_Heading); } } } return(chartData); }