示例#1
0
        /// <summary>Draws the specified series definition on the view.</summary>
        /// <param name="definition">The definition.</param>
        private void DrawOnView(SeriesDefinition definition)
        {
            if (!graph.DisabledSeries.Contains(definition.title))
            {
                // Create the series and populate it with data.
                if (definition.type == SeriesType.Bar)
                    graphView.DrawBar(definition.title, definition.x, definition.y,
                                      definition.xAxis, definition.yAxis, definition.colour, definition.showInLegend);

                else if (definition.type == SeriesType.Scatter)
                    graphView.DrawLineAndMarkers(definition.title, definition.x, definition.y,
                                                 definition.xAxis, definition.yAxis, definition.colour,
                                                 definition.line, definition.marker,
                                                 definition.lineThickness, definition.markerSize, definition.showInLegend);

                else if (definition.type == SeriesType.Area)
                    graphView.DrawArea(definition.title, definition.x, definition.y, definition.x2, definition.y2,
                                       definition.xAxis, definition.yAxis, definition.colour, definition.showInLegend);
            }
        }
示例#2
0
        /// <summary>Puts the 1:1 line on graph.</summary>
        /// <param name="definitions">The definitions.</param>
        /// <param name="x">The x data.</param>
        /// <param name="y">The y data.</param>
        private static void Put1To1LineOnGraph(List<SeriesDefinition> definitions, IEnumerable x, IEnumerable y)
        {
            double minimumX = MathUtilities.Min(x);
            double maximumX = MathUtilities.Max(x);
            double minimumY = MathUtilities.Min(y);
            double maximumY = MathUtilities.Max(y);
            double lowestAxisScale = Math.Min(minimumX, minimumY);
            double largestAxisScale = Math.Max(maximumX, maximumY);

            SeriesDefinition oneToOne = new SeriesDefinition();
            oneToOne.title = "1:1 line";
            oneToOne.colour = Color.Black;
            oneToOne.line = LineType.Dot;
            oneToOne.marker = MarkerType.None;
            oneToOne.showInLegend = true;
            oneToOne.type = SeriesType.Scatter;
            oneToOne.xAxis = Axis.AxisType.Bottom;
            oneToOne.yAxis = Axis.AxisType.Left;
            oneToOne.x = new double[] { lowestAxisScale, largestAxisScale };
            oneToOne.y = new double[] { lowestAxisScale, largestAxisScale };
            definitions.Add(oneToOne);
        }
示例#3
0
        /// <summary>Puts the regression line and 1:1 line on graph.</summary>
        /// <param name="definitions">The definitions.</param>
        /// <param name="x">The x data.</param>
        /// <param name="y">The y data.</param>
        /// <param name="colour">The colour of the regresion line.</param>
        /// <param name="title">The title to put in the legen.</param>
        private void PutRegressionLineOnGraph(List<SeriesDefinition> definitions, IEnumerable x, IEnumerable y, 
                                              Color colour, string title)
        {
            MathUtilities.RegrStats stat = MathUtilities.CalcRegressionStats(title, y, x);
            if (stat != null)
            {
                stats.Add(stat);
                double minimumX = MathUtilities.Min(x);
                double maximumX = MathUtilities.Max(x);
                double minimumY = MathUtilities.Min(y);
                double maximumY = MathUtilities.Max(y);
                double lowestAxisScale = Math.Min(minimumX, minimumY);
                double largestAxisScale = Math.Max(maximumX, maximumY);

                SeriesDefinition regressionDefinition = new SeriesDefinition();
                regressionDefinition.title = title;
                regressionDefinition.colour = colour;
                regressionDefinition.line = LineType.Solid;
                regressionDefinition.marker = MarkerType.None;
                regressionDefinition.showInLegend = true;
                regressionDefinition.type = SeriesType.Scatter;
                regressionDefinition.xAxis = Axis.AxisType.Bottom;
                regressionDefinition.yAxis = Axis.AxisType.Left;
                regressionDefinition.x = new double[] { minimumX, maximumX };
                regressionDefinition.y = new double[] { stat.Slope * minimumX + stat.Intercept, stat.Slope * maximumX + stat.Intercept };
                definitions.Add(regressionDefinition);
            }
        }
示例#4
0
文件: Series.cs 项目: sebxwolf/ApsimX
 /// <summary>Return a list of extra fields that the definition should read.</summary>
 /// <param name="seriesDefinition">The calling series definition.</param>
 /// <returns>A list of fields - never null.</returns>
 public IEnumerable <string> GetExtraFieldsToRead(SeriesDefinition seriesDefinition)
 {
     return(new string[0]);
 }
示例#5
0
 /// <summary>Set visual aspects (colour, line type, marker type) of the series definition.</summary>
 /// <param name="seriesDefinition">The definition to paint.</param>
 public void Paint(SeriesDefinition seriesDefinition)
 {
     seriesDefinition.Colour = colour;
     seriesDefinition.Line   = lineType;
     seriesDefinition.Marker = markerType;
 }
示例#6
0
 /// <summary>A static setter function for marker from an index</summary>
 /// <param name="definition">The series definition to change.</param>
 /// <param name="index">The index</param>
 public static void SetMarker(SeriesDefinition definition, int index)
 {
     definition.Marker = (MarkerType)Enum.GetValues(typeof(MarkerType)).GetValue(index);
 }
示例#7
0
 /// <summary>A static setter function for line type from an index</summary>
 /// <param name="definition">The series definition to change.</param>
 /// <param name="index">The index</param>
 public static void SetLineType(SeriesDefinition definition, int index)
 {
     definition.Line = (LineType)Enum.GetValues(typeof(LineType)).GetValue(index);
 }
示例#8
0
 /// <summary>A static setter function for colour from an index.</summary>
 /// <param name="definition">The series definition to change.</param>
 /// <param name="index">The colour index into the colour palette.</param>
 public static void SetColour(SeriesDefinition definition, int index)
 {
     definition.Colour = ColourUtilities.Colours[index];
 }