/// <summary> /// Determines where in the tree to insert this new line /// </summary> /// <param name="explainModel"></param> /// <param name="lastLine"></param> /// <param name="line"></param> /// <param name="newLine"></param> private void InsertNewLine(ExplainModel explainModel, ExplainLine lastLine, string line, ExplainLine newLine) { // Determine where to insert // If this is the first explainLine if (explainModel.ExplainLine == null) { explainModel.ExplainLine = newLine; explainModel.DocumentScore = newLine.Score; } // If the last inserted line was a lower indent, then make this its child else if (lastLine.Indent < GetIndentAmount(line)) { lastLine.AddChild(newLine); } // If the last inserted line was at the same indent, then give this the same parent as the last insert else if (lastLine.Indent == GetIndentAmount(line)) { lastLine.Parent.AddChild(newLine); } // If the last inserted has a higher indent, find the last insert with a lower indent and be the child of that line else if (lastLine.Indent > GetIndentAmount(line)) { var parent = lastLine.Parent; while (parent.Indent >= newLine.Indent) { parent = parent.Parent; } parent.AddChild(newLine); } }
private string[] BuildPieChartFieldNames(ExplainModel explainModel) { var explainLines = GetPieChartFieldExplainLines(explainModel); var fieldNames = explainLines.OrderByDescending(o => o.ScorePercent).Select(s => $"{s.FieldName.Truncate(32)} : {s.FieldQuery.Truncate(32)} ({s.Score})"); return(fieldNames.ToArray()); }
private static IEnumerable <ExplainLine> GetPieChartFieldExplainLines(ExplainModel explainModel) { return(explainModel.GetFieldExplainLines().Where(e => e.ScorePercent != 0)); }
private string[] BuildPieChartColors(ExplainModel explainModel) { var explainLines = GetPieChartFieldExplainLines(explainModel); return(Constants.RgbaColors.Take(explainLines.Count()).ToArray()); }
private decimal?[] BuildPieChartDataPointsPercent(ExplainModel explainModel) { var explainLines = GetPieChartFieldExplainLines(explainModel); return(explainLines.OrderByDescending(o => o.ScorePercent).Select(s => s.ScorePercent).ToArray()); }