/// <summary>Called by the graph presenter to get a list of all annotations to put on the graph.</summary> public IEnumerable <IAnnotation> GetAnnotations() { if (showEquation) { for (int i = 0; i < stats.Count; i++) { // Add an equation annotation. TextAnnotation equation = new TextAnnotation(); StringBuilder text = new StringBuilder(); text.AppendLine($"y = {stats[i].Slope:F2}x + {stats[i].Intercept:F2}, r\u00B2 = {stats[i].R2:F2}, n = {stats[i].n:F0}"); text.AppendLine($"NSE = {stats[i].NSE:F2}, ME = {stats[i].ME:F2}, MAE = {stats[i].MAE:F2}"); text.AppendLine($"RSR = {stats[i].RSR:F2}, RMSD = {stats[i].RMSE:F2}"); equation.Name = $"Regression{i}"; equation.text = text.ToString(); equation.colour = equationColours[i]; equation.leftAlign = true; equation.textRotation = 0; if (stats.Count > 1) { equation.x = double.MinValue; // More than one stats equation. Use default positioning equation.y = double.MinValue; } yield return(equation); } } }
/// <summary>Called by the graph presenter to get a list of all annotations to put on the graph.</summary> public IEnumerable <IAnnotation> GetAnnotations() { if (showEquation) { for (int i = 0; i < stats.Count; i++) { // Add an equation annotation. TextAnnotation equation = new TextAnnotation(); equation.text = string.Format("y = {0:F2} x + {1:F2}, r2 = {2:F2}, n = {3:F0}\r\n" + "NSE = {4:F2}, ME = {5:F2}, MAE = {6:F2}\r\n" + "RSR = {7:F2}, RMSD = {8:F2}", new object[] { stats[i].Slope, stats[i].Intercept, stats[i].R2, stats[i].n, stats[i].NSE, stats[i].ME, stats[i].MAE, stats[i].RSR, stats[i].RMSE }); equation.colour = equationColours[i]; equation.leftAlign = true; equation.textRotation = 0; equation.x = double.MinValue; equation.y = double.MinValue; yield return(equation); } } }
/// <summary>Called by the graph presenter to get a list of all annotations to put on the graph.</summary> public IEnumerable <IAnnotation> GetAnnotations() { List <IAnnotation> annotations = new List <IAnnotation>(); Graph parentGraph = Parent.Parent as Graph; if (data != null && ColumnName != null && xFieldName != null) { string phenologyColumnName = FindPhenologyStageColumn(data); if (phenologyColumnName != null && data.Columns.Contains(xFieldName)) { string[] names = DataTableUtilities.GetColumnAsStrings(data, phenologyColumnName); List <object> x; Type columnType = data.Columns[xFieldName].DataType; if (columnType == typeof(DateTime)) { x = DataTableUtilities.GetColumnAsDates(data, xFieldName).Cast <object>().ToList(); } else if (columnType == typeof(int)) { x = DataTableUtilities.GetColumnAsIntegers(data, xFieldName).Cast <object>().ToList(); } else if (columnType == typeof(double)) { x = DataTableUtilities.GetColumnAsDoubles(data, xFieldName).Cast <object>().ToList(); } else { throw new Exception($"Error in EventNamesOnGraph {Name}: unknown column type '{columnType.FullName}' in column '{xFieldName}'"); } if (names.Length == x.Count) { for (int i = 0; i < names.Length; i++) { if (names[i] != "?" && !string.IsNullOrEmpty(names[i])) { // Add a line annotation. LineAnnotation line = new LineAnnotation(); line.colour = Color.Black; line.type = LineType.Dot; line.x1 = x[i]; line.y1 = double.MinValue; line.x2 = x[i]; line.y2 = double.MaxValue; annotations.Add(line); // Add a text annotation. TextAnnotation text = new TextAnnotation(); text.text = names[i]; text.colour = Color.Black; text.leftAlign = true; text.x = x[i]; text.y = double.MinValue; text.textRotation = 270; annotations.Add(text); } } } } } return(annotations); }