예제 #1
0
        /// <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);
            }
        }
예제 #2
0
        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());
        }
예제 #3
0
 private static IEnumerable <ExplainLine> GetPieChartFieldExplainLines(ExplainModel explainModel)
 {
     return(explainModel.GetFieldExplainLines().Where(e => e.ScorePercent != 0));
 }
예제 #4
0
        private string[] BuildPieChartColors(ExplainModel explainModel)
        {
            var explainLines = GetPieChartFieldExplainLines(explainModel);

            return(Constants.RgbaColors.Take(explainLines.Count()).ToArray());
        }
예제 #5
0
        private decimal?[] BuildPieChartDataPointsPercent(ExplainModel explainModel)
        {
            var explainLines = GetPieChartFieldExplainLines(explainModel);

            return(explainLines.OrderByDescending(o => o.ScorePercent).Select(s => s.ScorePercent).ToArray());
        }