Beispiel #1
0
        /// <summary>
        /// Create a URL for a <see cref="CurveItem" /> that includes the index of the
        /// point that was selected.
        /// </summary>
        /// <remarks>
        /// An "index" parameter is added to the <see cref="Url" /> property for this
        /// link to indicate which point was selected.  Further, if the 
        /// X or Y axes that correspond to this <see cref="CurveItem" /> are of
        /// <see cref="AxisType.Text" />, then an
        /// additional parameter will be added containing the text value that
        /// corresponds to the <paramref name="index" /> of the selected point.
        /// The <see cref="XAxis" /> text parameter will be labeled "xtext", and
        /// the <see cref="YAxis" /> text parameter will be labeled "ytext".
        /// </remarks>
        /// <param name="index">The zero-based index of the selected point</param>
        /// <param name="pane">The <see cref="GraphPane" /> of interest</param>
        /// <param name="curve">The <see cref="CurveItem" /> for which to
        /// make the url string.</param>
        /// <returns>A string containing the url with an index parameter added.</returns>
        public virtual string MakeCurveItemUrl( GraphPane pane, CurveItem curve, int index )
        {
            string url = _url;

            if ( url.IndexOf( '?' ) >= 0 )
                url += "&index=" + index.ToString();
            else
                url += "?index=" + index.ToString();

            Axis xAxis = curve.GetXAxis( pane );
            if (	xAxis.Type == AxisType.Text && index >= 0 &&
                    xAxis.Scale.TextLabels != null &&
                    index <= xAxis.Scale.TextLabels.Length )
                url += "&xtext=" + xAxis.Scale.TextLabels[index];

            Axis yAxis = curve.GetYAxis( pane );
            if (	yAxis != null && yAxis.Type == AxisType.Text && index >= 0 &&
                    yAxis.Scale.TextLabels != null &&
                    index <= yAxis.Scale.TextLabels.Length )
                url += "&ytext=" + yAxis.Scale.TextLabels[index];

            return url;
        }
Beispiel #2
0
        /// <summary>
        /// Find the data point that lies closest to the specified mouse (screen)
        /// point.
        /// </summary>
        /// <remarks>
        /// This method will search through all curves in
        /// <see cref="GraphPane.CurveList"/> to find which point is
        /// nearest.  It will only consider points that are within
        /// <see cref="Default.NearestTol"/> pixels of the screen point.
        /// </remarks>
        /// <param name="mousePt">The screen point, in pixel coordinates.</param>
        /// <param name="nearestCurve">A reference to the <see cref="CurveItem"/>
        /// instance that contains the closest point.  nearestCurve will be null if
        /// no data points are available.</param>
        /// <param name="iNearest">The index number of the closest point.  The
        /// actual data vpoint will then be <see cref="CurveItem.Points">CurveItem.Points[iNearest]</see>
        /// .  iNearest will
        /// be -1 if no data points are available.</param>
        /// <returns>true if a point was found and that point lies within
        /// <see cref="Default.NearestTol"/> pixels
        /// of the screen point, false otherwise.</returns>
        public bool FindNearestPoint( PointF mousePt,
			out CurveItem nearestCurve, out int iNearest )
        {
            return FindNearestPoint( mousePt, _curveList,
                out nearestCurve, out iNearest );
        }
Beispiel #3
0
        /// <summary>
        /// Find the data point that lies closest to the specified mouse (screen)
        /// point.
        /// </summary>
        /// <remarks>
        /// This method will search through the specified list of curves to find which point is
        /// nearest.  It will only consider points that are within
        /// <see cref="Default.NearestTol"/> pixels of the screen point, and it will
        /// only consider <see cref="CurveItem"/>'s that are in 
        /// <paramref name="targetCurveList"/>.
        /// </remarks>
        /// <param name="mousePt">The screen point, in pixel coordinates.</param>
        /// <param name="targetCurveList">A <see cref="CurveList"/> object containing
        /// a subset of <see cref="CurveItem"/>'s to be searched.</param>
        /// <param name="nearestCurve">A reference to the <see cref="CurveItem"/>
        /// instance that contains the closest point.  nearestCurve will be null if
        /// no data points are available.</param>
        /// <param name="iNearest">The index number of the closest point.  The
        /// actual data vpoint will then be <see cref="CurveItem.Points">CurveItem.Points[iNearest]</see>
        /// .  iNearest will
        /// be -1 if no data points are available.</param>
        /// <returns>true if a point was found and that point lies within
        /// <see cref="Default.NearestTol"/> pixels
        /// of the screen point, false otherwise.</returns>
        public bool FindNearestPoint( PointF mousePt, CurveList targetCurveList,
			out CurveItem nearestCurve, out int iNearest )
        {
            CurveItem nearestBar = null;
            int iNearestBar = -1;
            nearestCurve = null;
            iNearest = -1;

            // If the point is outside the ChartRect, always return false
            if ( !_chart._rect.Contains( mousePt ) )
                return false;

            double x, x2;
            double[] y;
            double[] y2;

            //ReverseTransform( mousePt, out x, out y, out y2 );
            ReverseTransform( mousePt, out x, out x2, out y, out y2 );

            if ( !AxisRangesValid() )
                return false;

            ValueHandler valueHandler = new ValueHandler( this, false );

            //double	yPixPerUnit = chartRect.Height / ( yAxis.Max - yAxis.Min );
            //double	y2PixPerUnit; // = chartRect.Height / ( y2Axis.Max - y2Axis.Min );

            double yPixPerUnitAct, yAct, yMinAct, yMaxAct, xAct;
            double minDist = 1e20;
            double xVal, yVal, dist = 99999, distX, distY;
            double tolSquared = Default.NearestTol * Default.NearestTol;

            int iBar = 0;

            foreach ( CurveItem curve in targetCurveList )
            {
                //test for pie first...if it's a pie rest of method superfluous
                if ( curve is PieItem && curve.IsVisible )
                {
                    if ( ( (PieItem)curve ).SlicePath != null &&
                            ( (PieItem)curve ).SlicePath.IsVisible( mousePt ) )
                    {
                        nearestBar = curve;
                        iNearestBar = 0;
                    }

                    continue;
                }
                else if ( curve.IsVisible )
                {
                    int yIndex = curve.GetYAxisIndex( this );
                    Axis yAxis = curve.GetYAxis( this );
                    Axis xAxis = curve.GetXAxis( this );

                    if ( curve.IsY2Axis )
                    {
                        yAct = y2[yIndex];
                        yMinAct = _y2AxisList[yIndex]._scale._min;
                        yMaxAct = _y2AxisList[yIndex]._scale._max;
                    }
                    else
                    {
                        yAct = y[yIndex];
                        yMinAct = _yAxisList[yIndex]._scale._min;
                        yMaxAct = _yAxisList[yIndex]._scale._max;
                    }

                    yPixPerUnitAct = _chart._rect.Height / ( yMaxAct - yMinAct );

                    double xPixPerUnit = _chart._rect.Width / ( xAxis._scale._max - xAxis._scale._min );
                    xAct = xAxis is XAxis ? x : x2;

                    IPointList points = curve.Points;
                    float barWidth = curve.GetBarWidth( this );
                    double barWidthUserHalf;
                    Axis baseAxis = curve.BaseAxis( this );
                    bool isXBaseAxis = ( baseAxis is XAxis || baseAxis is X2Axis );
                    if ( isXBaseAxis )
                        barWidthUserHalf = barWidth / xPixPerUnit / 2.0;
                    else
                        barWidthUserHalf = barWidth / yPixPerUnitAct / 2.0;

                    if ( points != null )
                    {
                        for ( int iPt = 0; iPt < curve.NPts; iPt++ )
                        {
                            // xVal is the user scale X value of the current point
                            if ( xAxis._scale.IsAnyOrdinal && !curve.IsOverrideOrdinal )
                                xVal = (double)iPt + 1.0;
                            else
                                xVal = points[iPt].X;

                            // yVal is the user scale Y value of the current point
                            if ( yAxis._scale.IsAnyOrdinal && !curve.IsOverrideOrdinal )
                                yVal = (double)iPt + 1.0;
                            else
                                yVal = points[iPt].Y;

                            if ( xVal != PointPair.Missing &&
                                    yVal != PointPair.Missing )
                            {

                                if ( curve.IsBar || curve is ErrorBarItem ||
                                    curve is HiLowBarItem || curve is OHLCBarItem ||
                                    curve is JapaneseCandleStickItem )
                                {
                                    double baseVal, lowVal, hiVal;
                                    valueHandler.GetValues( curve, iPt, out baseVal,
                                            out lowVal, out hiVal );

                                    if ( lowVal > hiVal )
                                    {
                                        double tmpVal = lowVal;
                                        lowVal = hiVal;
                                        hiVal = tmpVal;
                                    }

                                    if ( isXBaseAxis )
                                    {

                                        double centerVal = valueHandler.BarCenterValue( curve, barWidth, iPt, xVal, iBar );

                                        if ( xAct < centerVal - barWidthUserHalf ||
                                                xAct > centerVal + barWidthUserHalf ||
                                                yAct < lowVal || yAct > hiVal )
                                            continue;
                                    }
                                    else
                                    {
                                        double centerVal = valueHandler.BarCenterValue( curve, barWidth, iPt, yVal, iBar );

                                        if ( yAct < centerVal - barWidthUserHalf ||
                                                yAct > centerVal + barWidthUserHalf ||
                                                xAct < lowVal || xAct > hiVal )
                                            continue;
                                    }

                                    if ( nearestBar == null )
                                    {
                                        iNearestBar = iPt;
                                        nearestBar = curve;
                                    }
                                }
                                else if ( xVal >= xAxis._scale._min && xVal <= xAxis._scale._max &&
                                            yVal >= yMinAct && yVal <= yMaxAct )
                                {
                                    if ( curve is LineItem && _lineType == LineType.Stack )
                                    {
                                        double zVal;
                                        valueHandler.GetValues( curve, iPt, out xVal, out zVal, out yVal );
                                    }

                                    distX = ( xVal - xAct ) * xPixPerUnit;
                                    distY = ( yVal - yAct ) * yPixPerUnitAct;
                                    dist = distX * distX + distY * distY;

                                    if ( dist >= minDist )
                                        continue;

                                    minDist = dist;
                                    iNearest = iPt;
                                    nearestCurve = curve;
                                }

                            }
                        }

                        if ( curve.IsBar )
                            iBar++;
                    }
                }
            }

            if ( nearestCurve is LineItem )
            {
                float halfSymbol = (float)( ( (LineItem)nearestCurve ).Symbol.Size *
                    CalcScaleFactor() / 2 );
                minDist -= halfSymbol * halfSymbol;
                if ( minDist < 0 )
                    minDist = 0;
            }

            if ( minDist >= tolSquared && nearestBar != null )
            {
                // if no point met the tolerance, but a bar was found, use it
                nearestCurve = nearestBar;
                iNearest = iNearestBar;
                return true;
            }
            else if ( minDist < tolSquared )
            {
                // Did we find a close point, and is it within the tolerance?
                // (minDist is the square of the distance in pixel units)
                return true;
            }
            else  // otherwise, no valid point found
                return false;
        }
Beispiel #4
0
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The CurveItem object from which to copy</param>
        public CurveItem( CurveItem rhs )
        {
            _label = rhs._label.Clone();
            _isY2Axis = rhs.IsY2Axis;
            _isX2Axis = rhs.IsX2Axis;
            _isVisible = rhs.IsVisible;
            _isOverrideOrdinal = rhs._isOverrideOrdinal;
            _yAxisIndex = rhs._yAxisIndex;

            if ( rhs.Tag is ICloneable )
                this.Tag = ((ICloneable) rhs.Tag).Clone();
            else
                this.Tag = rhs.Tag;

            _points = (IPointList) rhs.Points.Clone();

            _link = rhs._link.Clone();
        }
Beispiel #5
0
        /// <summary>
        /// Find the data point that lies closest to the specified mouse (screen)
        /// point for the specified curve.
        /// </summary>
        /// <remarks>
        /// This method will search only through the points for the specified
        /// curve to determine which point is
        /// nearest the mouse point.  It will only consider points that are within
        /// <see cref="Default.NearestTol"/> pixels of the screen point.
        /// </remarks>
        /// <param name="mousePt">The screen point, in pixel coordinates.</param>
        /// <param name="nearestCurve">A reference to the <see cref="CurveItem"/>
        /// instance that contains the closest point.  nearestCurve will be null if
        /// no data points are available.</param>
        /// <param name="targetCurve">A <see cref="CurveItem"/> object containing
        /// the data points to be searched.</param>
        /// <param name="iNearest">The index number of the closest point.  The
        /// actual data vpoint will then be <see cref="CurveItem.Points">CurveItem.Points[iNearest]</see>
        /// .  iNearest will
        /// be -1 if no data points are available.</param>
        /// <returns>true if a point was found and that point lies within
        /// <see cref="Default.NearestTol"/> pixels
        /// of the screen point, false otherwise.</returns>
        public bool FindNearestPoint( PointF mousePt, CurveItem targetCurve,
				out CurveItem nearestCurve, out int iNearest )
        {
            CurveList targetCurveList = new CurveList();
            targetCurveList.Add( targetCurve );
            return FindNearestPoint( mousePt, targetCurveList,
                out nearestCurve, out iNearest );
        }
Beispiel #6
0
        //public static Color SelectedSymbolColor = Color.Gray;

        #endregion Other

        #if ( DOTNET1 )

        // Define a "Contains" method so that this class works with .Net 1.1 or 2.0
        internal bool Contains( CurveItem item )
        {
            foreach ( CurveItem ci in this )
                if ( item == ci )
                    return true;

            return false;
        }
Beispiel #7
0
        /// <summary>
        /// Add a <see cref="CurveItem" /> to the selection list.
        /// </summary>
        /// <param name="master">The <see cref="MasterPane" /> that is the "owner"
        /// of the <see cref="CurveItem" />'s.</param>
        /// <param name="ci">The <see cref="CurveItem" /> to be added to the list.</param>
        public void AddToSelection( MasterPane master, CurveItem ci )
        {
            if ( this.Contains( ci ) == false )
                Add( ci );

            UpdateSelection( master );
        }
Beispiel #8
0
        /// <summary>
        /// Place a <see cref="CurveItem" /> in the selection list, removing all other
        /// items.
        /// </summary>
        /// <param name="master">The <see cref="MasterPane" /> that is the "owner"
        /// of the <see cref="CurveItem" />'s.</param>
        /// <param name="ci">The <see cref="CurveItem" /> to be added to the list.</param>
        public void Select( MasterPane master, CurveItem ci )
        {
            //Clear the selection, but don't send the event,
            //the event will be sent in "AddToSelection" by calling "UpdateSelection"
            ClearSelection( master, false );

            AddToSelection( master, ci );
        }
Beispiel #9
0
        /// <summary>
        /// Remove the specified <see cref="CurveItem" /> from the selection list.
        /// </summary>
        /// <param name="master">The <see cref="MasterPane" /> that is the "owner"
        /// of the <see cref="CurveItem" />'s.</param>
        /// <param name="ci">The <see cref="CurveItem" /> to be removed from the list.</param>
        public void RemoveFromSelection( MasterPane master, CurveItem ci )
        {
            if ( this.Contains( ci ) )
                this.Remove( ci );

            UpdateSelection( master );
        }
Beispiel #10
0
        /// <summary>
        /// Get the user scale values associate with a particular point of a
        /// particular curve.</summary>
        /// <remarks>The main purpose of this method is to handle
        /// stacked bars and lines, in which case the stacked values are returned rather
        /// than the individual data values.  However, this method works generically for any
        /// curve type.
        /// </remarks>
        /// <param name="pane">The parent <see cref="GraphPane"/> object.</param>
        /// <param name="curve">A <see cref="CurveItem"/> object of interest.</param>
        /// <param name="iPt">The zero-based point index for the point of interest.</param>
        /// <param name="baseVal">A <see cref="Double"/> value representing the value
        /// for the independent axis.</param>
        /// <param name="lowVal">A <see cref="Double"/> value representing the lower
        /// value for the dependent axis.</param>
        /// <param name="hiVal">A <see cref="Double"/> value representing the upper
        /// value for the dependent axis.</param>
        /// <returns>true if the data point is value, false for
        /// <see cref="PointPairBase.Missing"/>, invalid, etc. data.</returns>
        public static bool GetValues( GraphPane pane, CurveItem curve, int iPt,
							out double baseVal, out double lowVal, out double hiVal )
        {
            hiVal = PointPair.Missing;
            lowVal = PointPair.Missing;
            baseVal = PointPair.Missing;

            if ( curve == null || curve.Points.Count <= iPt || !curve.IsVisible )
                return false;

            Axis baseAxis = curve.BaseAxis( pane );
            Axis valueAxis = curve.ValueAxis( pane );

            if ( baseAxis is XAxis || baseAxis is X2Axis )
                baseVal = curve.Points[iPt].X;
            else
                baseVal = curve.Points[iPt].Y;

            // is it a stacked bar type?
            if ( curve is BarItem && ( pane._barSettings.Type == BarType.Stack ||
                        pane._barSettings.Type == BarType.PercentStack ) )
            {
                double positiveStack = 0;
                double negativeStack = 0;
                double curVal;

                // loop through all the curves, summing up the values to get a total (only
                // for the current ordinal position iPt)
                foreach ( CurveItem tmpCurve in pane.CurveList )
                {
                    // Sum the value for the current curve only if it is a bar
                    if ( tmpCurve.IsBar && tmpCurve.IsVisible )
                    {
                        curVal = PointPair.Missing;
                        // For non-ordinal curves, find a matching base value (must match exactly)
                        if ( curve.IsOverrideOrdinal || !baseAxis._scale.IsAnyOrdinal )
                        {
                            IPointList points = tmpCurve.Points;

                            for ( int i=0; i<points.Count; i++ )
                            {
                                if ( ( baseAxis is XAxis || baseAxis is X2Axis ) && points[i].X == baseVal )
                                {
                                    curVal = points[i].Y;
                                    break;
                                }
                                else if ( !(baseAxis is XAxis || baseAxis is X2Axis) && points[i].Y == baseVal )
                                {
                                    curVal = points[i].X;
                                    break;
                                }
                            }
                        }
                        // otherwise, it's an ordinal type so use the value at the same ordinal position
                        else if ( iPt < tmpCurve.Points.Count )
                        {
                            // Get the value for the appropriate value axis
                            if ( baseAxis is XAxis || baseAxis is X2Axis )
                                curVal = tmpCurve.Points[iPt].Y;
                            else
                                curVal = tmpCurve.Points[iPt].X;
                        }

                        // If it's a missing value, skip it
                        if ( curVal == PointPair.Missing )
                        {
                            positiveStack = PointPair.Missing;
                            negativeStack = PointPair.Missing;
                        }

                        // the current curve is the target curve, save the summed values for later
                        if ( tmpCurve == curve )
                        {
                            // if the value is positive, use the positive stack
                            if ( curVal >= 0 )
                            {
                                lowVal = positiveStack;
                                hiVal = ( curVal == PointPair.Missing || positiveStack == PointPair.Missing ) ?
                                        PointPair.Missing : positiveStack + curVal;
                            }
                            // otherwise, use the negative stack
                            else
                            {
                                hiVal = negativeStack;
                                lowVal = ( curVal == PointPair.Missing || negativeStack == PointPair.Missing ) ?
                                        PointPair.Missing : negativeStack + curVal;
                            }
                        }

                        // Add all positive values to the positive stack, and negative values to the
                        // negative stack
                        if ( curVal >= 0 )
                            positiveStack = ( curVal == PointPair.Missing || positiveStack == PointPair.Missing ) ?
                                        PointPair.Missing : positiveStack + curVal;
                        else
                            negativeStack = ( curVal == PointPair.Missing || negativeStack == PointPair.Missing ) ?
                                        PointPair.Missing : negativeStack + curVal;
                    }
                }

                // if the curve is a PercentStack type, then calculate the percent for this bar
                // based on the total height of the stack
                if ( pane._barSettings.Type == BarType.PercentStack &&
                            hiVal != PointPair.Missing && lowVal != PointPair.Missing )
                {
                    // Use the total magnitude of the positive plus negative bar stacks to determine
                    // the percentage value
                    positiveStack += Math.Abs( negativeStack );

                    // just to avoid dividing by zero...
                    if ( positiveStack != 0 )
                    {
                        // calculate the percentage values
                        lowVal = lowVal / positiveStack * 100.0;
                        hiVal = hiVal / positiveStack * 100.0;
                    }
                    else
                    {
                        lowVal = 0;
                        hiVal = 0;
                    }
                }

                if ( baseVal == PointPair.Missing || lowVal == PointPair.Missing ||
                        hiVal == PointPair.Missing )
                    return false;
                else
                    return true;
            }
            // If the curve is a stacked line type, then sum up the values similar to the stacked bar type
            else if ( curve is LineItem && pane.LineType == LineType.Stack )
            {
                double stack = 0;
                double curVal;

                // loop through all the curves, summing up the values to get a total (only
                // for the current ordinal position iPt)
                foreach ( CurveItem tmpCurve in pane.CurveList )
                {
                    // make sure the curve is a Line type
                    if ( tmpCurve is LineItem && tmpCurve.IsVisible )
                    {
                        curVal = PointPair.Missing;
                        // For non-ordinal curves, find a matching base value (must match exactly)
                        if ( curve.IsOverrideOrdinal || !baseAxis._scale.IsAnyOrdinal )
                        {
                            IPointList points = tmpCurve.Points;

                            for ( int i = 0; i < points.Count; i++ )
                            {
                                if ( points[i].X == baseVal )
                                {
                                    curVal = points[i].Y;
                                    break;
                                }
                            }
                        }
                        // otherwise, it's an ordinal type so use the value at the same ordinal position
                        else if ( iPt < tmpCurve.Points.Count )
                        {
                            // For line types, the Y axis is always the value axis
                            curVal = tmpCurve.Points[iPt].Y;
                        }

                        // if the current value is missing, then the rest of the stack is missing
                        if ( curVal == PointPair.Missing )
                            stack = PointPair.Missing;

                        // if the current curve is the target curve, save the values
                        if ( tmpCurve == curve )
                        {
                            lowVal = stack;
            //							if ( curVal < 0 && stack == 0 )
            //							{
            //								stack = curVal;
            //								lowVal = curVal;
            //								hiVal = curVal;
            //							}
            //							else
                                hiVal = ( curVal == PointPair.Missing || stack == PointPair.Missing ) ?
                                    PointPair.Missing : stack + curVal;
                        }

                        // sum all the curves to a single total.  This includes both positive and
                        // negative values (unlike the bar stack type).
                        stack = ( curVal == PointPair.Missing || stack == PointPair.Missing ) ?
                                PointPair.Missing : stack + curVal;
                    }
                }

                if ( baseVal == PointPair.Missing || lowVal == PointPair.Missing ||
                    hiVal == PointPair.Missing )
                    return false;
                else
                    return true;
            }
            // otherwise, the curve is not a stacked type (not a stacked bar or stacked line)
            else
            {
                if ( ! (curve is HiLowBarItem) )
                    lowVal = 0;
                else
                    lowVal = curve.Points[iPt].LowValue;

                if ( baseAxis is XAxis || baseAxis is X2Axis )
                    hiVal = curve.Points[iPt].Y;
                else
                    hiVal = curve.Points[iPt].X;
            }

            // Special Exception: Bars on log scales should always plot from the Min value upwards,
            // since they can never be zero
            if ( curve is BarItem && valueAxis._scale.IsLog && lowVal == 0 )
                lowVal = valueAxis._scale._min;

            if ( baseVal == PointPair.Missing || hiVal == PointPair.Missing ||
                    ( lowVal == PointPair.Missing && ( curve is ErrorBarItem ||
                        curve is HiLowBarItem ) ) )
                return false;
            else
                return true;
        }
Beispiel #11
0
        /// <summary>
        /// Get the user scale values associate with a particular point of a
        /// particular curve.</summary>
        /// <remarks>The main purpose of this method is to handle
        /// stacked bars, in which case the stacked values are returned rather
        /// than the individual data values.
        /// </remarks>
        /// <param name="curve">A <see cref="CurveItem"/> object of interest.</param>
        /// <param name="iPt">The zero-based point index for the point of interest.</param>
        /// <param name="baseVal">A <see cref="Double"/> value representing the value
        /// for the independent axis.</param>
        /// <param name="lowVal">A <see cref="Double"/> value representing the lower
        /// value for the dependent axis.</param>
        /// <param name="hiVal">A <see cref="Double"/> value representing the upper
        /// value for the dependent axis.</param>
        /// <returns>true if the data point is value, false for
        /// <see cref="PointPairBase.Missing"/>, invalid, etc. data.</returns>
        public bool GetValues( CurveItem curve, int iPt, out double baseVal,
							out double lowVal, out double hiVal )
        {
            return GetValues( _pane, curve, iPt, out baseVal,
                                    out lowVal, out hiVal );
        }
Beispiel #12
0
        /// <summary>
        /// Calculate the user scale position of the center of the specified bar, using the
        /// <see cref="Axis"/> as specified by <see cref="BarSettings.Base"/>.  This method is
        /// used primarily by the
        /// <see cref="GraphPane.FindNearestPoint(PointF,out CurveItem,out int)"/> method in order to
        /// determine the bar "location," which is defined as the center of the top of the individual bar.
        /// </summary>
        /// <param name="curve">The <see cref="CurveItem"/> representing the
        /// bar of interest.</param>
        /// <param name="barWidth">The width of each individual bar. This can be calculated using
        /// the <see cref="CurveItem.GetBarWidth"/> method.</param>
        /// <param name="iCluster">The cluster number for the bar of interest.  This is the ordinal
        /// position of the current point.  That is, if a particular <see cref="CurveItem"/> has
        /// 10 points, then a value of 3 would indicate the 4th point in the data array.</param>
        /// <param name="val">The actual independent axis value for the bar of interest.</param>
        /// <param name="iOrdinal">The ordinal position of the <see cref="CurveItem"/> of interest.
        /// That is, the first bar series is 0, the second is 1, etc.  Note that this applies only
        /// to the bars.  If a graph includes both bars and lines, then count only the bars.</param>
        /// <returns>A user scale value position of the center of the bar of interest.</returns>
        public double BarCenterValue( CurveItem curve, float barWidth, int iCluster,
										  double val, int iOrdinal )
        {
            Axis baseAxis = curve.BaseAxis( _pane );
            if ( curve is ErrorBarItem || curve is HiLowBarItem ||
                    curve is OHLCBarItem || curve is JapaneseCandleStickItem )
            {
                if ( baseAxis._scale.IsAnyOrdinal && iCluster >= 0 && !curve.IsOverrideOrdinal )
                    return (double) iCluster + 1.0;
                else
                    return val;
            }
            else
            {
                float clusterWidth = _pane._barSettings.GetClusterWidth();
                float clusterGap = _pane._barSettings.MinClusterGap * barWidth;
                float barGap = barWidth * _pane._barSettings.MinBarGap;

                if ( curve.IsBar && _pane._barSettings.Type != BarType.Cluster )
                    iOrdinal = 0;

                float centerPix = baseAxis.Scale.Transform( curve.IsOverrideOrdinal, iCluster, val )
                    - clusterWidth / 2.0F + clusterGap / 2.0F +
                    iOrdinal * ( barWidth + barGap ) + 0.5F * barWidth;
                return baseAxis.Scale.ReverseTransform( centerPix );
            }
        }