예제 #1
0
        /// <summary>
        /// Select a reasonable ordinal axis scale given a range of data values, with the expectation that
        /// dates will be displayed.
        /// </summary>
        /// <remarks>
        /// This method only applies to <see cref="AxisType.DateAsOrdinal"/> type axes, and it
        /// is called by the general <see cref="PickScale"/> method.  For this type,
        /// the first curve is the "master", which contains the dates to be applied.
        /// <para>On Exit:</para>
        /// <para><see cref="Scale.Min"/> is set to scale minimum (if <see cref="Scale.MinAuto"/> = true)</para>
        /// <para><see cref="Scale.Max"/> is set to scale maximum (if <see cref="Scale.MaxAuto"/> = true)</para>
        /// <para><see cref="Scale.MajorStep"/> is set to scale step size (if <see cref="Scale.MajorStepAuto"/> = true)</para>
        /// <para><see cref="Scale.MinorStep"/> is set to scale minor step size (if <see cref="Scale.MinorStepAuto"/> = true)</para>
        /// <para><see cref="Scale.Mag"/> is set to a magnitude multiplier according to the data</para>
        /// <para><see cref="Scale.Format"/> is set to the display format for the values (this controls the
        /// number of decimal places, whether there are thousands separators, currency types, etc.)</para>
        /// </remarks>
        /// <param name="pane">A reference to the <see cref="GraphPane"/> object
        /// associated with this <see cref="Axis"/></param>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <seealso cref="PickScale"/>
        /// <seealso cref="AxisType.Ordinal"/>
        override public void PickScale(GraphPane pane, Graphics g, float scaleFactor)
        {
            // call the base class first
            base.PickScale(pane, g, scaleFactor);

            /*			// First, get the date ranges from the first curve in the list
             *          double xMin; // = Double.MaxValue;
             *          double xMax; // = Double.MinValue;
             *          double yMin; // = Double.MaxValue;
             *          double yMax; // = Double.MinValue;
             *          double range = 1;
             *
             *          foreach ( CurveItem curve in pane.CurveList )
             *          {
             *              if ( ( _ownerAxis is Y2Axis && curve.IsY2Axis ) ||
             *                      ( _ownerAxis is YAxis && !curve.IsY2Axis ) ||
             *                      ( _ownerAxis is X2Axis && curve.IsX2Axis ) ||
             *                      ( _ownerAxis is XAxis && !curve.IsX2Axis ) )
             *              {
             *                  curve.GetRange( out xMin, out xMax, out yMin, out yMax, false, pane.IsBoundedRanges, pane );
             *                  if ( _ownerAxis is XAxis || _ownerAxis is X2Axis )
             *                      range = xMax - xMin;
             *                  else
             *                      range = yMax - yMin;
             *              }
             *          }
             */
            // Set the DateFormat by calling CalcDateStepSize
            //			DateScale.CalcDateStepSize( range, Default.TargetXSteps, this );
            SetDateFormat(pane);

            // Now, set the axis range based on a ordinal scale
            base.PickScale(pane, g, scaleFactor);
            OrdinalScale.PickScale(pane, g, scaleFactor, this);
        }
        /// <summary>
        /// Select a reasonable ordinal axis scale given a range of data values, with the expectation that
        /// linear values will be displayed.
        /// </summary>
        /// <remarks>
        /// This method only applies to <see cref="AxisType.DateAsOrdinal"/> type axes, and it
        /// is called by the general <see cref="Scale.PickScale"/> method.  For this type,
        /// the first curve is the "master", which contains the dates to be applied.
        /// <para>On Exit:</para>
        /// <para><see cref="Scale.Min"/> is set to scale minimum (if <see cref="Scale.MinAuto"/> = true)</para>
        /// <para><see cref="Scale.Max"/> is set to scale maximum (if <see cref="Scale.MaxAuto"/> = true)</para>
        /// <para><see cref="Scale.MajorStep"/> is set to scale step size (if <see cref="Scale.MajorStepAuto"/> = true)</para>
        /// <para><see cref="Scale.MinorStep"/> is set to scale minor step size (if <see cref="Scale.MinorStepAuto"/> = true)</para>
        /// <para><see cref="Scale.Mag"/> is set to a magnitude multiplier according to the data</para>
        /// <para><see cref="Scale.Format"/> is set to the display format for the values (this controls the
        /// number of decimal places, whether there are thousands separators, currency types, etc.)</para>
        /// </remarks>
        /// <param name="pane">A reference to the <see cref="GraphPane"/> object
        /// associated with this <see cref="Axis"/></param>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <seealso cref="PickScale"/>
        /// <seealso cref="AxisType.Ordinal"/>
        override public void PickScale(GraphPane pane, Graphics g, float scaleFactor)
        {
            // call the base class first
            base.PickScale(pane, g, scaleFactor);

            // First, get the date ranges from the first curve in the list
            double xMin; // = Double.MaxValue;
            double xMax; // = Double.MinValue;
            double yMin; // = Double.MaxValue;
            double yMax; // = Double.MinValue;
            double tMin = 0;
            double tMax = 1;

            foreach (CurveItem curve in pane.CurveList)
            {
                if ((_ownerAxis is Y2Axis && curve.IsY2Axis) ||
                    (_ownerAxis is YAxis && !curve.IsY2Axis) ||
                    (_ownerAxis is X2Axis && curve.IsX2Axis) ||
                    (_ownerAxis is XAxis && !curve.IsX2Axis))
                {
                    curve.GetRange(out xMin, out xMax, out yMin, out yMax, false, false, pane);
                    if (_ownerAxis is XAxis || _ownerAxis is X2Axis)
                    {
                        tMin = xMin;
                        tMax = xMax;
                    }
                    else
                    {
                        tMin = yMin;
                        tMax = yMax;
                    }
                }
            }

            double range = Math.Abs(tMax - tMin);

            // Now, set the axis range based on a ordinal scale
            base.PickScale(pane, g, scaleFactor);
            OrdinalScale.PickScale(pane, g, scaleFactor, this);

            SetScaleMag(tMin, tMax, range / Default.TargetXSteps);
        }