ArrayMinMax() public static method

Returns the minimum and maximum values in an IList. The members of the list can be of different types - any type for which the function Utils.ConvertToDouble knows how to convert into a double.
public static ArrayMinMax ( IList a, double &min, double &max ) : bool
a IList The IList to search.
min double The minimum value.
max double The maximum value.
return bool
コード例 #1
0
            /// <summary>
            /// Calculates a suggested axis for the IList data.
            /// </summary>
            /// <returns>the suggested axis</returns>
            public Axis Get()
            {
                double min;
                double max;

                if (Utils.ArrayMinMax(data_, out min, out max))
                {
                    if (data_[0] is DateTime)
                    {
                        return(new DateTimeAxis(min, max));
                    }
                    else
                    {
                        return(new LinearAxis(min, max));
                    }

                    // perhaps return LogAxis here if range large enough
                    // + other constraints?
                }

                return(new LinearAxis(0.0, 1.0));
            }
コード例 #2
0
ファイル: CandlePlot.cs プロジェクト: nigelis/NPlotB
            /// <summary>
            /// Returns a y-axis that is suitable for drawing the data.
            /// </summary>
            /// <returns>A suitable y-axis.</returns>
            public Axis SuggestYAxis()
            {
                double min_l;
                double max_l;
                double min_h;
                double max_h;

                if (this.rows_ == null)
                {
                    Utils.ArrayMinMax((System.Collections.IList)lowData_, out min_l, out max_l);
                    Utils.ArrayMinMax((System.Collections.IList)highData_, out min_h, out max_h);
                }
                else
                {
                    Utils.RowArrayMinMax(this.rows_, out min_l, out max_l, (string)this.lowData_);
                    Utils.RowArrayMinMax(this.rows_, out min_h, out max_h, (string)this.highData_);
                }

                Axis a = new LinearAxis(min_l, max_h);

                a.IncreaseRange(0.08);
                return(a);
            }
コード例 #3
0
ファイル: CandlePlot.cs プロジェクト: nigelis/NPlotB
            /// <summary>
            /// Returns an x-axis that is suitable for drawing the data.
            /// </summary>
            /// <returns>A suitable x-axis.</returns>
            public Axis SuggestXAxis()
            {
                double min;
                double max;
                double minStep = 0.0;

                if (this.rows_ == null)
                {
                    Utils.ArrayMinMax((System.Collections.IList) this.abscissaData_, out min, out max);

                    if (((System.Collections.IList)abscissaData_).Count > 1)
                    {
                        double first  = Utils.ToDouble(((Array)abscissaData_).GetValue(0));
                        double second = Utils.ToDouble(((Array)abscissaData_).GetValue(1));
                        minStep = Math.Abs(second - first);
                    }
                    if (((System.Collections.IList)abscissaData_).Count > 2)
                    {
                        double first  = Utils.ToDouble(((Array)abscissaData_).GetValue(1));
                        double second = Utils.ToDouble(((Array)abscissaData_).GetValue(2));
                        if (Math.Abs(second - first) < minStep)
                        {
                            minStep = Math.Abs(second - first);
                        }
                    }
                    if (((System.Collections.IList)abscissaData_)[0] is DateTime)
                    {
                        return(new DateTimeAxis(min - minStep / 2.0, max + minStep / 2.0));
                    }
                    else
                    {
                        return(new LinearAxis(min - minStep / 2.0, max + minStep / 2.0));
                    }
                }
                else
                {
                    Utils.RowArrayMinMax(this.rows_, out min, out max, (string)this.abscissaData_);

                    if (rows_.Count > 1)
                    {
                        double first  = Utils.ToDouble(rows_[0][(string)abscissaData_]);
                        double second = Utils.ToDouble(rows_[1][(string)abscissaData_]);
                        minStep = Math.Abs(second - first);
                    }
                    if (rows_.Count > 2)
                    {
                        double first  = Utils.ToDouble(rows_[1][(string)abscissaData_]);
                        double second = Utils.ToDouble(rows_[2][(string)abscissaData_]);
                        if (Math.Abs(second - first) < minStep)
                        {
                            minStep = Math.Abs(second - first);
                        }
                    }

                    if ((rows_[0])[(string)abscissaData_] is DateTime)
                    {
                        return(new DateTimeAxis(min - minStep / 2.0, max + minStep / 2.0));
                    }
                    else
                    {
                        return(new LinearAxis(min - minStep / 2.0, max + minStep / 2.0));
                    }
                }
            }