Ejemplo n.º 1
0
        /// <summary>
        /// Calculate ControlPoints of a DataPoint
        /// </summary>
        /// <param name="dataPoint">DataPoint</param>
        /// <param name="minimumZVal">Minimum ZValue</param>
        /// <param name="maximumZVal">Maximum ZValue</param>
        /// <param name="axisX">AxisX</param>
        /// <param name="axisY">AxisY</param>
        /// <returns></returns>
        private static List <Point> CalculateControlPointsOfDataPoint(DataPoint dataPoint, PlotGroup plotGroup, Double maxBubbleRadius, Double minimumZVal, Double maximumZVal, Axis axisX, Axis axisY)
        {
            Chart        chart    = dataPoint.Chart as Chart;
            List <Point> ctPoints = new List <Point>();

            if (chart != null && axisX != null && axisY != null)
            {
                Double leftRightOffset = 4; // One Pixel
                Double topBottomOffset = 4; // One Pixel

                Size initialPlotAreaSize = new Size(plotGroup._intialAxisXWidth, plotGroup._intialAxisYHeight);

                Double xPosition = Graphics.ValueToPixelPosition(0, initialPlotAreaSize.Width, (Double)plotGroup._initialAxisXMin, (Double)plotGroup._initialAxisXMax, dataPoint.InternalXValue);
                Double yPosition = Graphics.ValueToPixelPosition(initialPlotAreaSize.Height, 0, (Double)plotGroup._initialAxisYMin, (Double)plotGroup._initialAxisYMax, dataPoint.InternalYValue);

                if (axisY.Logarithmic)
                {
                    Double yValueInLog  = Graphics.PixelPositionToValue(initialPlotAreaSize.Height, 0, plotGroup._initialAxisYMin, plotGroup._initialAxisYMax, yPosition);
                    Double actualYValue = DataPoint.ConvertLogarithmicValue2ActualValue(chart, yValueInLog, axisY.AxisType);

                    Point pointLeft = new Point(
                        Graphics.PixelPositionToValue(0, initialPlotAreaSize.Width, plotGroup._initialAxisXMin, plotGroup._initialAxisXMax, xPosition - (maxBubbleRadius + leftRightOffset))
                        , actualYValue);

                    // Calculate right point of bubble in terms of XValue and YValue
                    Point pointRight = new Point(
                        Graphics.PixelPositionToValue(0, initialPlotAreaSize.Width, plotGroup._initialAxisXMin, plotGroup._initialAxisXMax, xPosition + (maxBubbleRadius + leftRightOffset))
                        , actualYValue);

                    yValueInLog  = Graphics.PixelPositionToValue(initialPlotAreaSize.Height, 0, plotGroup._initialAxisYMin, plotGroup._initialAxisYMax, yPosition - (maxBubbleRadius + topBottomOffset));
                    actualYValue = DataPoint.ConvertLogarithmicValue2ActualValue(chart, yValueInLog, axisY.AxisType);

                    // Calculate top point of bubble in terms of XValue and YValue
                    Point pointTop = new Point(
                        Graphics.PixelPositionToValue(0, initialPlotAreaSize.Width, plotGroup._initialAxisXMin, plotGroup._initialAxisXMax, xPosition)
                        , actualYValue);

                    yValueInLog  = Graphics.PixelPositionToValue(initialPlotAreaSize.Height, 0, plotGroup._initialAxisYMin, plotGroup._initialAxisYMax, yPosition + (maxBubbleRadius + topBottomOffset));
                    actualYValue = DataPoint.ConvertLogarithmicValue2ActualValue(chart, yValueInLog, axisY.AxisType);

                    // Calculate bottom point of bubble in terms of XValue and YValue
                    Point pointBottom = new Point(
                        Graphics.PixelPositionToValue(0, initialPlotAreaSize.Width, plotGroup._initialAxisXMin, plotGroup._initialAxisXMax, xPosition)
                        , actualYValue);

                    ctPoints.Add(pointLeft);
                    ctPoints.Add(pointRight);
                    ctPoints.Add(pointTop);
                    ctPoints.Add(pointBottom);
                }
                else
                {
                    // Calculate left point of bubble in terms of XValue and YValue
                    Point pointLeft = new Point(
                        Graphics.PixelPositionToValue(0, initialPlotAreaSize.Width, plotGroup._initialAxisXMin, plotGroup._initialAxisXMax, xPosition - (maxBubbleRadius + leftRightOffset))
                        , Graphics.PixelPositionToValue(0, initialPlotAreaSize.Height, plotGroup._initialAxisYMin, plotGroup._initialAxisYMax, yPosition));

                    // Calculate right point of bubble in terms of XValue and YValue
                    Point pointRight = new Point(
                        Graphics.PixelPositionToValue(0, initialPlotAreaSize.Width, plotGroup._initialAxisXMin, plotGroup._initialAxisXMax, xPosition + (maxBubbleRadius + leftRightOffset))
                        , Graphics.PixelPositionToValue(0, initialPlotAreaSize.Height, plotGroup._initialAxisYMin, plotGroup._initialAxisYMax, yPosition));

                    // Calculate top point of bubble in terms of XValue and YValue
                    Point pointTop = new Point(
                        Graphics.PixelPositionToValue(0, initialPlotAreaSize.Width, plotGroup._initialAxisXMin, plotGroup._initialAxisXMax, xPosition)
                        , Graphics.PixelPositionToValue(initialPlotAreaSize.Height, 0, plotGroup._initialAxisYMin, plotGroup._initialAxisYMax, yPosition - (maxBubbleRadius + topBottomOffset)));

                    // Calculate bottom point of bubble in terms of XValue and YValue
                    Point pointBottom = new Point(
                        Graphics.PixelPositionToValue(0, initialPlotAreaSize.Width, plotGroup._initialAxisXMin, plotGroup._initialAxisXMax, xPosition)
                        , Graphics.PixelPositionToValue(initialPlotAreaSize.Height, 0, plotGroup._initialAxisYMin, plotGroup._initialAxisYMax, yPosition + (maxBubbleRadius + topBottomOffset)));

                    ctPoints.Add(pointLeft);
                    ctPoints.Add(pointRight);
                    ctPoints.Add(pointTop);
                    ctPoints.Add(pointBottom);
                }
            }

            return(ctPoints);
        }