示例#1
0
        public override uint GetBestScale(double xAxisMax, double yAxisMax)
        {
            var xTop    = Center.X + Radius;
            var xBottom = Center.X - Radius;
            var yLeft   = Center.Y - Radius;
            var yRight  = Center.X + Radius;

            uint scale = 1;

            if (xTop > xAxisMax)
            {
                scale = GraphMathUtilities.CalculateScale(GraphAxis.X, xTop, xAxisMax, yAxisMax);
            }

            if (xBottom < (-1 * xAxisMax))
            {
                scale = GraphMathUtilities.CalculateScale(GraphAxis.X, xBottom, xAxisMax, yAxisMax);
            }

            if (yRight > yAxisMax)
            {
                scale = GraphMathUtilities.CalculateScale(GraphAxis.Y, yRight, xAxisMax, yAxisMax);
            }

            if (yLeft < (-1 * yAxisMax))
            {
                scale = GraphMathUtilities.CalculateScale(GraphAxis.Y, yLeft, xAxisMax, yAxisMax);
            }

            return(scale);
        }
示例#2
0
        public override uint GetBestScale(double xAxisMax, double yAxisMax)
        {
            var pointsX = Points.OrderByDescending(p => p.Value.X);
            var pointsY = Points.OrderByDescending(p => p.Value.Y);

            var xMax = pointsX.First().Value.X;
            var yMax = pointsY.First().Value.Y;
            var xMin = pointsX.Last().Value.X;
            var yMin = pointsY.Last().Value.Y;

            uint scale = 1;

            if (xMax > yMax)
            {
                scale = GraphMathUtilities.CalculateScale(GraphAxis.X, xMax, xAxisMax, yAxisMax);
            }

            if (yMax > xMax)
            {
                scale = GraphMathUtilities.CalculateScale(GraphAxis.Y, yMax, xAxisMax, yAxisMax);
            }

            if (xMin < yMin)
            {
                scale = GraphMathUtilities.CalculateScale(GraphAxis.X, xMin, xAxisMax, yAxisMax);
            }

            if (yMin < xMin)
            {
                scale = GraphMathUtilities.CalculateScale(GraphAxis.Y, yMin, xAxisMax, yAxisMax);
            }

            return(scale);
        }