Example #1
0
        void ResizeAxis(Rectangle r)
        {
            //If the rectangle has zero width or zero height return
            if (r.Width == 0)
            {
                return;
            }
            if (r.Height == 0)
            {
                return;
            }

            //Get the points from the rectangle
            double x1 = r.X - this.CurveArea.X;
            double y1 = r.Y - this.CurveArea.Y;
            double x2 = x1 + r.Width;
            double y2 = y1 + r.Height;

            //Transform rectangle points into real values
            x1 = GraphTransform.InvTranslateX(x1);
            y1 = GraphTransform.InvTranslateY(y1);
            x2 = GraphTransform.InvTranslateX(x2);
            y2 = GraphTransform.InvTranslateY(y2);

            //If logarithmic x axis transform x values
            if (this.AxisTypeX == AxisType.LOG)
            {
                x1 = (double)Math.Pow(10, x1);
                x2 = (double)Math.Pow(10, x2);
            }

            //If logarithmic y axis transform y values
            if (this.AxisTypeY == AxisType.LOG)
            {
                y1 = (double)Math.Pow(10, y1);
                y2 = (double)Math.Pow(10, y2);
            }

            //If this chart has autoscale enabled disable it
            if (this.AutoScale)
            {
                this.AutoScale = false;
            }

            //Set the new axisrange
            this.AxisRangeX = new AxisData(x1, x2, Math.Abs(x2 - x1) / 5);
            this.AxisRangeY = new AxisData(y2, y1, Math.Abs(y1 - y2) / 5);

            //Redraw the control
            RedrawChart();
        }
Example #2
0
        private void ResizeAxis(Rectangle r)
        {
            if (r.Width == 0)
            {
                return;
            }
            if (r.Height == 0)
            {
                return;
            }

            double x1 = r.X - this.CurveArea.X;
            double y1 = r.Y - this.CurveArea.Y;
            double x2 = x1 + r.Width;
            double y2 = y1 + r.Height;

            x1 = GraphTransform.InvTranslateX(x1);
            y1 = GraphTransform.InvTranslateY(y1);
            x2 = GraphTransform.InvTranslateX(x2);
            y2 = GraphTransform.InvTranslateY(y2);

            if (this.AxisTypeX == AxisType.LOG)
            {
                x1 = Math.Pow(10, x1);
                x2 = Math.Pow(10, x2);
            }

            if (this.AxisTypeY == AxisType.LOG)
            {
                y1 = Math.Pow(10, y1);
                y2 = Math.Pow(10, y2);
            }

            this.AxisRangeX = new AxisData(x1, x2, Math.Abs(x2 - x1) / 5);
            this.AxisRangeY = new AxisData(y2, y1, Math.Abs(y1 - y2) / 5);


            Invalidate();
        }