Esempio n. 1
0
        /// <summary>
        /// Calculate the user scale position of the center of the specified bar, using the
        /// <see cref="Axis"/> as specified by <see cref="GraphPane.BarBase"/>.  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)
            {
                if ((baseAxis.IsOrdinal || baseAxis.IsText) && iCluster >= 0 && !curve.IsOverrideOrdinal)
                {
                    return((double)iCluster + 1.0);
                }
                else
                {
                    return(val);
                }
            }
            else
            {
                float clusterWidth = pane.GetClusterWidth();
                float clusterGap   = pane.MinClusterGap * barWidth;
                float barGap       = barWidth * pane.MinBarGap;

                if ((curve.IsBar && !(pane.BarType == BarType.Cluster || pane.BarType == BarType.ClusterHiLow)))
                {
                    iOrdinal = 0;
                }

                float centerPix = baseAxis.Transform(curve.IsOverrideOrdinal, iCluster, val)
                                  - clusterWidth / 2.0F + clusterGap / 2.0F +
                                  iOrdinal * (barWidth + barGap) + 0.5F * barWidth;
                return(baseAxis.ReverseTransform(centerPix));
            }
        }
Esempio n. 2
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));
            }
        }
Esempio n. 3
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)
        {
            var baseAxis = curve.BaseAxis(_pane);

            if (curve is IBarItem)
            {
                return(baseAxis.Scale.IsAnyOrdinal && iCluster >= 0 && !curve.IsOverrideOrdinal
             ? iCluster + 1.0
             : val);
            }

            var clusterWidth = _pane._barSettings.GetClusterWidth();
            var clusterGap   = _pane._barSettings.MinClusterGap * barWidth;
            var barGap       = barWidth * _pane._barSettings.MinBarGap;

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

            var 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));
        }
Esempio n. 4
0
        /// <summary>
        /// Calculate the range for stacked bars and lines.
        /// </summary>
        /// <remarks>This method is required for the stacked
        /// types because (for bars), the negative values are a separate stack than the positive
        /// values.  If you just sum up the bars, you will get the sum of the positive plus negative,
        /// which is less than the maximum positive value and greater than the maximum negative value.
        /// </remarks>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="curve">The <see cref="CurveItem"/> for which to calculate the range</param>
        /// <param name="tXMinVal">The minimum X value so far</param>
        /// <param name="tYMinVal">The minimum Y value so far</param>
        /// <param name="tXMaxVal">The maximum X value so far</param>
        /// <param name="tYMaxVal">The maximum Y value so far</param>
        /// <param name="xLBound">The lower bound of allowable data for the X values.  This
        /// value allows you to subset the data values.  If the X range is bounded, then
        /// the resulting range for Y will reflect the Y values for the points within the X
        /// bounds.  Use <see cref="System.Double.MinValue"/> to have no bound.</param>
        /// <param name="xUBound">The upper bound of allowable data for the X values.  This
        /// value allows you to subset the data values.  If the X range is bounded, then
        /// the resulting range for Y will reflect the Y values for the points within the X
        /// bounds.  Use <see cref="System.Double.MaxValue"/> to have no bound.</param>
        /// <param name="yLBound">The lower bound of allowable data for the Y values.  This
        /// value allows you to subset the data values.  If the Y range is bounded, then
        /// the resulting range for X will reflect the X values for the points within the Y
        /// bounds.  Use <see cref="System.Double.MinValue"/> to have no bound.</param>
        /// <param name="yUBound">The upper bound of allowable data for the Y values.  This
        /// value allows you to subset the data values.  If the Y range is bounded, then
        /// the resulting range for X will reflect the X values for the points within the Y
        /// bounds.  Use <see cref="System.Double.MaxValue"/> to have no bound.</param>
        /// <seealso cref="GraphPane.IsBoundedRanges"/>
        private void GetStackRange(GraphPane pane, CurveItem curve, ref double tXMinVal,
                                   ref double tYMinVal, ref double tXMaxVal, ref double tYMaxVal,
                                   double xLBound, double xUBound,
                                   double yLBound, double yUBound)
        {
            ValueHandler valueHandler = new ValueHandler(pane, false);
            bool         isXBase      = curve.BaseAxis(pane) is XAxis;

            double lowVal, baseVal, hiVal;

            for (int i = 0; i < curve.Points.Count; i++)
            {
                valueHandler.GetValues(curve, i, out baseVal, out lowVal, out hiVal);
                double x = isXBase ? baseVal : hiVal;
                double y = isXBase ? hiVal : baseVal;

                if (x < tXMinVal)
                {
                    tXMinVal = x;
                }
                if (x > tXMaxVal)
                {
                    tXMaxVal = x;
                }
                if (y < tYMinVal)
                {
                    tYMinVal = y;
                }
                if (y > tYMaxVal)
                {
                    tYMaxVal = y;
                }

                if (!isXBase)
                {
                    if (lowVal < tXMinVal)
                    {
                        tXMinVal = lowVal;
                    }
                    if (lowVal > tXMaxVal)
                    {
                        tXMaxVal = lowVal;
                    }
                }
                else
                {
                    if (lowVal < tYMinVal)
                    {
                        tYMinVal = lowVal;
                    }
                    if (lowVal > tYMaxVal)
                    {
                        tYMaxVal = lowVal;
                    }
                }
            }
        }
 public DataFrameBuilder(GraphPane graphPane, CurveItem curveItem)
 {
     GraphPane = graphPane;
     CurveItem = curveItem;
     var msPointList = curveItem.Points as MSPointList;
     if (msPointList != null)
     {
         Points = msPointList.FullList;
     }
     else
     {
         Points = curveItem.Points;
     }
     XAxis = curveItem.GetXAxis(graphPane);
     YAxis = curveItem.GetYAxis(graphPane);
     BaseAxis = curveItem.BaseAxis(graphPane);
     ValueAxis = curveItem.ValueAxis(graphPane);
 }
Esempio n. 6
0
        /// <summary>
        /// Calculate the screen pixel position of the center of the specified bar, using the
        /// <see cref="Axis"/> as specified by <see cref="GraphPane.BarBase"/>.  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 screen pixel X position of the center of the bar of interest.</returns>
        public double BarCenterValue(CurveItem curve, float barWidth, int iCluster,
                                     double val, int iOrdinal)
        {
            float clusterWidth = pane.GetClusterWidth();
            float clusterGap   = pane.MinClusterGap * barWidth;
            float barGap       = barWidth * pane.MinBarGap;

            if ((curve.IsBar && !(pane.BarType == BarType.Cluster)) ||
                curve is ErrorBarItem || curve is HiLowBarItem)
            {
                iOrdinal = 0;
            }

            Axis  baseAxis  = curve.BaseAxis(pane);
            float centerPix = baseAxis.Transform(iCluster, val)
                              - clusterWidth / 2.0F + clusterGap / 2.0F +
                              iOrdinal * (barWidth + barGap) + 0.5F * barWidth;

            return(baseAxis.ReverseTransform(centerPix));
        }
Esempio n. 7
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="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="PointPair.Missing"/>, invalid, etc. data.</returns>
        public static bool GetBarValues( 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 )
                return false;

            Axis baseAxis = curve.BaseAxis( pane );

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

            if ( curve is BarItem && ( pane.BarType == BarType.Stack ||
                        pane.BarType == BarType.PercentStack ) )
            {
                double positiveStack = 0;
                double negativeStack = 0;
                double curVal;
                foreach ( CurveItem tmpCurve in pane.CurveList )
                //for ( int iCurve=pane.CurveList.Count-1; iCurve >=0; iCurve-- )
                {
                    //CurveItem tmpCurve = pane.CurveList[iCurve];
                    if ( tmpCurve.IsBar && iPt < tmpCurve.Points.Count )
                    {
                        if ( baseAxis is XAxis )
                            curVal = tmpCurve.Points[iPt].Y;
                        else
                            curVal = tmpCurve.Points[iPt].X;

                        if ( curVal == PointPair.Missing )
                            continue;

                        if ( tmpCurve == curve )
                        {
                            if ( curVal >= 0 )
                            {
                                lowVal = positiveStack;
                                hiVal = positiveStack + curVal;
                            }
                            else
                            {
                                hiVal = negativeStack;
                                lowVal = negativeStack + curVal;
                            }
                        }

                        if ( curVal >= 0 )
                            positiveStack += curVal;
                        else
                            negativeStack += curVal;
                    }
                }

                if ( pane.BarType == BarType.PercentStack )
                {
                    positiveStack += Math.Abs( negativeStack );

                    if ( positiveStack != 0 )
                    {
                        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;
            }
            else
            {
                if ( curve is BarItem )
                    lowVal = 0;
                else
                    lowVal = curve.Points[iPt].LowValue;

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

            if ( baseVal == PointPair.Missing || hiVal == PointPair.Missing ||
                    ( lowVal == PointPair.Missing && ( curve is ErrorBarItem ||
                        curve is HiLowBarItem ) ) )
                return false;
            else
                return true;
        }
Esempio n. 8
0
        /// <summary>
        /// Calculate the screen pixel position of the center of the specified bar, using the
        /// <see cref="Axis"/> as specified by <see cref="GraphPane.BarBase"/>.  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 screen pixel X position of the center of the bar of interest.</returns>
        public double BarCenterValue( CurveItem curve, float barWidth, int iCluster,
										  double val, int iOrdinal )
        {
            float clusterWidth = pane.GetClusterWidth();
            float clusterGap = pane.MinClusterGap * barWidth;
            float barGap = barWidth * pane.MinBarGap;

            if ( ( curve.IsBar && !( pane.BarType == BarType.Cluster ) ) ||
                   curve is ErrorBarItem || curve is HiLowBarItem )
                iOrdinal = 0;

            Axis baseAxis = curve.BaseAxis( pane );
            float centerPix = baseAxis.Transform( iCluster, val )
                     - clusterWidth / 2.0F + clusterGap / 2.0F +
                     iOrdinal * ( barWidth + barGap ) + 0.5F * barWidth;
            return baseAxis.ReverseTransform( centerPix );
        }
Esempio n. 9
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;
        }
Esempio n. 10
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 );
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Calculate the range for stacked bars and lines.
        /// </summary>
        /// <remarks>This method is required for the stacked
        /// types because (for bars), the negative values are a separate stack than the positive
        /// values.  If you just sum up the bars, you will get the sum of the positive plus negative,
        /// which is less than the maximum positive value and greater than the maximum negative value.
        /// </remarks>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="curve">The <see cref="CurveItem"/> for which to calculate the range</param>
        /// <param name="tXMinVal">The minimum X value so far</param>
        /// <param name="tYMinVal">The minimum Y value so far</param>
        /// <param name="tXMaxVal">The maximum X value so far</param>
        /// <param name="tYMaxVal">The maximum Y value so far</param>
        /// <seealso cref="GraphPane.IsBoundedRanges"/>
        private void GetStackRange( GraphPane pane, CurveItem curve, out double tXMinVal,
									out double tYMinVal, out double tXMaxVal, out double tYMaxVal )
        {
            // initialize the values to outrageous ones to start
            tXMinVal = tYMinVal = Double.MaxValue;
            tXMaxVal = tYMaxVal = Double.MinValue;

            ValueHandler valueHandler = new ValueHandler( pane, false );
            Axis baseAxis = curve.BaseAxis( pane );
            bool isXBase = baseAxis is XAxis || baseAxis is X2Axis;

            double lowVal, baseVal, hiVal;

            for ( int i=0; i<curve.Points.Count; i++ )
            {
                valueHandler.GetValues( curve, i, out baseVal, out lowVal, out hiVal );
                double x = isXBase ? baseVal : hiVal;
                double y = isXBase ? hiVal : baseVal;

                if ( x != PointPair.Missing && y != PointPair.Missing && lowVal != PointPair.Missing )
                {
                    if ( x < tXMinVal )
                        tXMinVal = x;
                    if ( x > tXMaxVal )
                        tXMaxVal = x;
                    if ( y < tYMinVal )
                        tYMinVal = y;
                    if ( y > tYMaxVal )
                        tYMaxVal = y;

                    if ( !isXBase )
                    {
                        if ( lowVal < tXMinVal )
                            tXMinVal = lowVal;
                        if ( lowVal > tXMaxVal )
                            tXMaxVal = lowVal;
                    }
                    else
                    {
                        if ( lowVal < tYMinVal )
                            tYMinVal = lowVal;
                        if ( lowVal > tYMaxVal )
                            tYMaxVal = lowVal;
                    }
                }
            }
        }
Esempio n. 12
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)) && (!(curve is ErrorBarItem)))
                {
                    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);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Calculate the range for stacked bars and lines.
        /// </summary>
        /// <remarks>This method is required for the stacked
        /// types because (for bars), the negative values are a separate stack than the positive
        /// values.  If you just sum up the bars, you will get the sum of the positive plus negative,
        /// which is less than the maximum positive value and greater than the maximum negative value.
        /// </remarks>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="curve">The <see cref="CurveItem"/> for which to calculate the range</param>
        /// <param name="tXMinVal">The minimum X value so far</param>
        /// <param name="tYMinVal">The minimum Y value so far</param>
        /// <param name="tXMaxVal">The maximum X value so far</param>
        /// <param name="tYMaxVal">The maximum Y value so far</param>
        /// <seealso cref="GraphPane.IsBoundedRanges"/>
        private void GetStackRange(GraphPane pane, CurveItem curve, out double tXMinVal,
                                   out double tYMinVal, out double tXMaxVal, out double tYMaxVal)
        {
            // initialize the values to outrageous ones to start
            tXMinVal = tYMinVal = Double.MaxValue;
            tXMaxVal = tYMaxVal = Double.MinValue;

            ValueHandler valueHandler = new ValueHandler(pane, false);
            Axis         baseAxis     = curve.BaseAxis(pane);
            bool         isXBase      = baseAxis is XAxis || baseAxis is X2Axis;

            double lowVal, baseVal, hiVal;

            for (int i = 0; i < curve.Points.Count; i++)
            {
                valueHandler.GetValues(curve, i, out baseVal, out lowVal, out hiVal);
                double x = isXBase ? baseVal : hiVal;
                double y = isXBase ? hiVal : baseVal;

                if (x != PointPair.Missing && y != PointPair.Missing && lowVal != PointPair.Missing)
                {
                    if (x < tXMinVal)
                    {
                        tXMinVal = x;
                    }
                    if (x > tXMaxVal)
                    {
                        tXMaxVal = x;
                    }
                    if (y < tYMinVal)
                    {
                        tYMinVal = y;
                    }
                    if (y > tYMaxVal)
                    {
                        tYMaxVal = y;
                    }

                    if (!isXBase)
                    {
                        if (lowVal < tXMinVal)
                        {
                            tXMinVal = lowVal;
                        }
                        if (lowVal > tXMaxVal)
                        {
                            tXMaxVal = lowVal;
                        }
                    }
                    else
                    {
                        if (lowVal < tYMinVal)
                        {
                            tYMinVal = lowVal;
                        }
                        if (lowVal > tYMaxVal)
                        {
                            tYMaxVal = lowVal;
                        }
                    }
                }
            }
        }
Esempio n. 14
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="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="PointPair.Missing"/>, invalid, etc. data.</returns>
        public static bool GetBarValues(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)
            {
                return(false);
            }

            Axis baseAxis = curve.BaseAxis(pane);

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

            if (curve is BarItem && (pane.BarType == BarType.Stack ||
                                     pane.BarType == BarType.PercentStack))
            {
                double positiveStack = 0;
                double negativeStack = 0;
                double curVal;
                foreach (CurveItem tmpCurve in pane.CurveList)
                //for ( int iCurve=pane.CurveList.Count-1; iCurve >=0; iCurve-- )
                {
                    //CurveItem tmpCurve = pane.CurveList[iCurve];
                    if (tmpCurve.IsBar && iPt < tmpCurve.Points.Count)
                    {
                        if (baseAxis is XAxis)
                        {
                            curVal = tmpCurve.Points[iPt].Y;
                        }
                        else
                        {
                            curVal = tmpCurve.Points[iPt].X;
                        }

                        if (curVal == PointPair.Missing)
                        {
                            continue;
                        }

                        if (tmpCurve == curve)
                        {
                            if (curVal >= 0)
                            {
                                lowVal = positiveStack;
                                hiVal  = positiveStack + curVal;
                            }
                            else
                            {
                                hiVal  = negativeStack;
                                lowVal = negativeStack + curVal;
                            }
                        }

                        if (curVal >= 0)
                        {
                            positiveStack += curVal;
                        }
                        else
                        {
                            negativeStack += curVal;
                        }
                    }
                }

                if (pane.BarType == BarType.PercentStack)
                {
                    positiveStack += Math.Abs(negativeStack);

                    if (positiveStack != 0)
                    {
                        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);
                }
            }
            else
            {
                if (curve is BarItem)
                {
                    lowVal = 0;
                }
                else
                {
                    lowVal = curve.Points[iPt].LowValue;
                }

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

            if (baseVal == PointPair.Missing || hiVal == PointPair.Missing ||
                (lowVal == PointPair.Missing && (curve is ErrorBarItem ||
                                                 curve is HiLowBarItem)))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 15
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="PointPair.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)
            {
                return(false);
            }

            Axis baseAxis = curve.BaseAxis(pane);

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

            // is it a stacked bar type?
            if (curve is BarItem && (pane.BarType == BarType.Stack ||
                                     pane.BarType == 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, and only if
                    // it has a point for this ordinal position
                    if (tmpCurve.IsBar && iPt < tmpCurve.Points.Count)
                    {
                        // Get the value for the appropriate value axis
                        if (baseAxis is XAxis)
                        {
                            curVal = tmpCurve.Points[iPt].Y;
                        }
                        else
                        {
                            curVal = tmpCurve.Points[iPt].X;
                        }

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

                        // 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  = positiveStack + curVal;
                            }
                            // otherwise, use the negative stack
                            else
                            {
                                hiVal  = negativeStack;
                                lowVal = negativeStack + curVal;
                            }
                        }

                        // Add all positive values to the positive stack, and negative values to the
                        // negative stack
                        if (curVal >= 0)
                        {
                            positiveStack += curVal;
                        }
                        else
                        {
                            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.BarType == BarType.PercentStack)
                {
                    // 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, and that it has a value for the
                    // current ordinal position iPt.
                    if (tmpCurve is LineItem && 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, skip it
                        if (curVal == PointPair.Missing)
                        {
                            continue;
                        }

                        // if the current curve is the target curve, save the values
                        if (tmpCurve == curve)
                        {
                            lowVal = stack;
                            hiVal  = stack + curVal;
                        }

                        // sum all the curves to a single total.  This includes both positive and
                        // negative values (unlike the bar stack type).
                        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 BarItem && pane.BarType != BarType.ClusterHiLow)
                {
                    lowVal = 0;
                }
                else
                {
                    lowVal = curve.Points[iPt].LowValue;
                }

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

            if (baseVal == PointPair.Missing || hiVal == PointPair.Missing ||
                (lowVal == PointPair.Missing && (curve is ErrorBarItem ||
                                                 curve is HiLowBarItem)))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }