示例#1
0
        /// <summary>Called by the graph presenter to get a list of all annotations to put on the graph.</summary>
        /// <param name="annotations">A list of annotations to add to.</param>
        public void GetAnnotationsToPutOnGraph(List <Annotation> annotations)
        {
            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);
                    DateTime[] dates = DataTableUtilities.GetColumnAsDates(data, xFieldName);
                    if (names.Length == dates.Length)
                    {
                        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     = dates[i];
                                line.y1     = double.MinValue;
                                line.x2     = dates[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         = dates[i];

                                text.y            = double.MinValue;
                                text.textRotation = 270;
                                annotations.Add(text);
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        /// <summary>Called by the graph presenter to get a list of all annotations to put on the graph.</summary>
        /// <param name="annotations">A list of annotations to add to.</param>
        public void GetAnnotationsToPutOnGraph(List<Annotation> annotations)
        {
            Graph parentGraph = Parent.Parent as Graph;

            if (data != null && ColumnName != null && xFieldName != null)
            {
                string phenologyColumnName = FindPhenologyStageColumn(data);
                if (phenologyColumnName != null && data.Table.Columns.Contains(xFieldName))
                {
                    string[] names = DataTableUtilities.GetColumnAsStrings(data, phenologyColumnName);
                    DateTime[] dates = DataTableUtilities.GetColumnAsDates(data, xFieldName);
                    if (names.Length == dates.Length)
                    {
                        for (int i = 0; i < names.Length; i++)
                        {
                            if (names[i] != "?")
                            {
                                // Add a line annotation.
                                LineAnnotation line = new LineAnnotation();
                                line.colour = Color.Black;
                                line.type = LineType.Dot;
                                line.x1 = dates[i];
                                line.y1 = double.MinValue;
                                line.x2 = dates[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 = dates[i];
                                text.y = double.MinValue;
                                text.textRotation = 270;
                                annotations.Add(text);
                            }
                        }
                    }
                }
            }
        }
示例#3
0
 /// <summary>Called by the graph presenter to get a list of all annotations to put on the graph.</summary>
 /// <param name="annotations">A list of annotations to add to.</param>
 public void GetAnnotationsToPutOnGraph(List <Annotation> annotations)
 {
     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;
         annotations.Add(equation);
     }
 }
示例#4
0
 /// <summary>Called by the graph presenter to get a list of all annotations to put on the graph.</summary>
 /// <param name="annotations">A list of annotations to add to.</param>
 public void GetAnnotationsToPutOnGraph(List<Annotation> annotations)
 {
     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;
         annotations.Add(equation);
     }
 }
示例#5
0
        /// <summary>Called by the graph presenter to get a list of all annotations to put on the graph.</summary>
        /// <param name="annotations">A list of annotations to add to.</param>
        public void GetAnnotationsToPutOnGraph(List <Annotation> annotations)
        {
            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);
                            }
                        }
                    }
                }
            }
        }