Example #1
0
            /// <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 (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 (rows_, out min_l, out max_l, (string)lowData_);
                    Utils.RowArrayMinMax (rows_, out min_h, out max_h, (string)highData_);
                }

                Axis a = new LinearAxis (min_l, max_h);
                a.IncreaseRange (0.08);
                return a;
            }
Example #2
0
        private void DrawAxisTests(Context ctx, Rectangle bounds)
        {
            Rectangle boundingBox;
            Point tl = Point.Zero;
            Point br = Point.Zero;;

            tl.X = bounds.Left + 30;	tl.Y = bounds.Top + 10;
            br.X = tl.X;				br.Y = bounds.Bottom - 100;

            LinearAxis a = new LinearAxis (0, 10);

            a.Draw (ctx, tl, br, out boundingBox);

            a.Reversed = true;
            a.Draw (ctx, new Point (60,10), new Point (60, 200), out boundingBox);

            a.SmallTickSize = 0;
            a.Draw (ctx, new Point(90,10), new Point(90, 200), out boundingBox);

            a.LargeTickStep = 2.5;
            a.Draw (ctx, new Point(120,10), new Point(120,200), out boundingBox);

            a.NumberOfSmallTicks = 5;
            a.SmallTickSize = 2;
            a.Draw (ctx, new Point(150,10), new Point(150,200), out boundingBox);

            a.LineColor = Colors.DarkBlue;
            a.Draw (ctx, new Point(180,10), new Point(180,200), out boundingBox);

            a.TickTextColor= Colors.DarkBlue;
            a.Draw (ctx, new Point(210,10), new Point(210,200), out boundingBox);

            a.TickTextColor = Colors.Black;
            a.Draw (ctx, new Point(240,10), new Point(300,200), out boundingBox);

            a.WorldMax = 100000;
            a.WorldMin = -3;
            a.LargeTickStep = double.NaN;
            a.Draw (ctx, new Point(330,10), new Point(330,200), out boundingBox);

            a.NumberFormat = "{0:0.0E+0}";
            a.Draw (ctx, new Point(380,10), new Point(380,200), out boundingBox);

            // Test for default TicksAngle (+90) on positive X-axis, ie Ticks below X-axis
            LinearAxis aX = new LinearAxis (0, 10);

            tl.X = bounds.Left + 30;	tl.Y = bounds.Bottom - 60;
            br.X = bounds.Right - 20;	br.Y = bounds.Bottom - 60;

            aX.Draw (ctx, tl, br, out boundingBox);

            // Set TicksAngle to -45 anti-clockwise from positive X-axis direction
            aX.TicksAngle = Math.PI / 4.0;
            tl.Y += 50;		br.Y += 50;

            aX.Draw (ctx, tl, br, out boundingBox);
        }
Example #3
0
        /// <summary>
        /// Helper method for Clone.
        /// </summary>
        protected void DoClone(LinearAxis src, LinearAxis dest)
        {
            Axis.DoClone (src, dest);

            dest.numberSmallTicks_ = src.numberSmallTicks_;
            dest.largeTickValue_ = src.largeTickValue_;
            dest.largeTickStep_ = src.largeTickStep_;

            dest.offset_ = src.offset_;
            dest.scale_ = src.scale_;
        }
Example #4
0
        /// <summary>
        /// Returns a y-axis that is suitable for drawing this plot.
        /// </summary>
        /// <returns>A suitable y-axis.</returns>
        public Axis SuggestYAxis()
        {
            if (IsStacked) {
                double tmpMax = 0.0f;
                ArrayList adapterList = new ArrayList();

                HistogramPlot currentPlot = this;
                do {
                    adapterList.Add (new SequenceAdapter (
                        currentPlot.DataSource,
                        currentPlot.DataMember,
                        currentPlot.OrdinateData,
                        currentPlot.AbscissaData)
                    );
                } while ((currentPlot = currentPlot.stackedTo) != null);

                SequenceAdapter[] adapters = (SequenceAdapter[])adapterList.ToArray (typeof(SequenceAdapter));

                for (int i=0; i<adapters[0].Count; ++i) {
                    double tmpHeight = 0.0f;
                    for (int j=0; j<adapters.Length; ++j) {
                        tmpHeight += adapters[j][i].Y;
                    }
                    tmpMax = Math.Max (tmpMax, tmpHeight);
                }

                Axis a = new LinearAxis (0.0,tmpMax);
                // TODO make 0.08 a parameter.
                a.IncreaseRange (0.08);
                return a;
            }
            else {
                SequenceAdapter data = new SequenceAdapter (DataSource, DataMember, OrdinateData, AbscissaData);
                return data.SuggestYAxis();
            }
        }
Example #5
0
 /// <summary>
 /// Deep copy of LinearAxis.
 /// </summary>
 /// <returns>A copy of the LinearAxis Class</returns>
 public override object Clone()
 {
     LinearAxis a = new LinearAxis ();
     // ensure that this isn't being called on a derived type. If it is, then oh no!
     if (this.GetType() != a.GetType()) {
         throw new XwPlotException( "Clone not defined in derived type. Help!" );
     }
     DoClone ( this, a);
     return a;
 }