NPlot.StepPlot.SuggestXAxis C# (CSharp) Method

SuggestXAxis() public method

Returns an X-axis suitable for use by this plot. The axis will be one that is just long enough to show all data.
public SuggestXAxis ( ) : Axis
return Axis
        public Axis SuggestXAxis()
        {
            SequenceAdapter data =
                new SequenceAdapter( this.DataSource, this.DataMember, this.OrdinateData, this.AbscissaData );

            if (data.Count < 2)
            {
                return data.SuggestXAxis();
            }

            // else

            Axis a = data.SuggestXAxis();

            PointD p1 = data[0];
            PointD p2 = data[1];
            PointD p3 = data[data.Count-2];
            PointD p4 = data[data.Count-1];

            double offset1;
            double offset2;

            if (!center_)
            {
                offset1 = 0.0f;
                offset2 = p4.X - p3.X;
            }
            else
            {
                offset1 = (p2.X - p1.X)/2.0f;
                offset2 = (p4.X - p3.X)/2.0f;
            }

            a.WorldMin -= offset1;
            a.WorldMax += offset2;

            return a;
        }