Exemplo n.º 1
0
        /// <summary>
        /// Gets the coordinates used to draw ticks and tick labels (numbers or category names).
        /// </summary>
        /// <param name="majorLabelValues">The major label values.</param>
        /// <param name="majorTickValues">The major tick values.</param>
        /// <param name="minorTickValues">The minor tick values.</param>
        public override void GetTickValues(out IList <double> majorLabelValues, out IList <double> majorTickValues, out IList <double> minorTickValues)
        {
            // For easier readability, the nomenclature of this function and all related functions assumes a base of 10, and therefore uses the
            // term "decade". However, the code supports all other bases as well.
            var logBandwidth  = Math.Abs(this.LogActualMaximum - this.LogActualMinimum);
            var axisBandwidth = Math.Abs(this.IsVertical() ? this.ScreenMax.Y - this.ScreenMin.Y : this.ScreenMax.X - this.ScreenMin.X);

            var desiredNumberOfTicks = axisBandwidth / this.IntervalLength;
            var ticksPerDecade       = desiredNumberOfTicks / logBandwidth;
            var logDesiredStepSize   = 1.0 / Math.Floor(ticksPerDecade);

            var intBase = Convert.ToInt32(this.Base);

            if (ticksPerDecade < 0.75)
            {   // Major Ticks every few decades (increase in powers of 2), up to eight minor tick subdivisions
                var decadesPerMajorTick = (int)Math.Pow(2, Math.Ceiling(Math.Log(1 / ticksPerDecade, 2)));
                majorTickValues = this.DecadeTicks(decadesPerMajorTick);
                minorTickValues = this.DecadeTicks(Math.Ceiling(decadesPerMajorTick / 8.0));
            }
            else if (Math.Abs(this.Base - intBase) > 1e-10)
            {   // fractional Base, best guess: naively subdivide decades
                majorTickValues = this.DecadeTicks(logDesiredStepSize);
                minorTickValues = this.DecadeTicks(0.5 * logDesiredStepSize);
            }
            else if (ticksPerDecade < 2)
            {   // Major Ticks at every decade, Minor Ticks at fractions (not for fractional base)
                majorTickValues = this.DecadeTicks();
                minorTickValues = this.SubdividedDecadeTicks();
            }
            else if (ticksPerDecade > this.Base * 1.5)
            {   // Fall back to linearly distributed tick values
                base.GetTickValues(out majorLabelValues, out majorTickValues, out minorTickValues);
            }
            else
            {
                // use subdivided decades as major candidates
                var logMajorCandidates = this.LogSubdividedDecadeTicks(false);

                if (logMajorCandidates.Count < 2)
                {   // this should usually not be the case, but if for some reason we should happen to have too few candidates, fall back to linear ticks
                    base.GetTickValues(out majorLabelValues, out majorTickValues, out minorTickValues);
                    return;
                }

                // check for large candidate intervals; if there are any, subdivide with minor ticks
                var logMinorCandidates = this.LogCalculateMinorCandidates(logMajorCandidates, logDesiredStepSize);

                // use all minor tick candidates that are in the axis range
                minorTickValues = this.PowList(logMinorCandidates, true);

                // find suitable candidates for every desired major step
                majorTickValues = this.AlignTicksToCandidates(logMajorCandidates, logDesiredStepSize);
            }

            majorLabelValues = majorTickValues;
            minorTickValues  = AxisUtilities.FilterRedundantMinorTicks(majorTickValues, minorTickValues);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the coordinates used to draw ticks and tick labels (numbers or category names).
        /// </summary>
        /// <param name="majorLabelValues">The major label values.</param>
        /// <param name="majorTickValues">The major tick values.</param>
        /// <param name="minorTickValues">The minor tick values.</param>
        public override void GetTickValues(
            out IList <double> majorLabelValues, out IList <double> majorTickValues, out IList <double> minorTickValues)
        {
            var minimum = this.StartAngle / this.Scale;
            var maximum = this.EndAngle / this.Scale;

            minorTickValues  = AxisUtilities.CreateTickValues(minimum, maximum, this.ActualMinorStep);
            majorTickValues  = AxisUtilities.CreateTickValues(minimum, maximum, this.ActualMajorStep);
            majorLabelValues = AxisUtilities.CreateTickValues(this.Minimum, this.Maximum, this.ActualMajorStep);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the tick values.
        /// </summary>
        /// <param name="majorLabelValues">The major label values.</param>
        /// <param name="majorTickValues">The major tick values.</param>
        /// <param name="minorTickValues">The minor tick values.</param>
        public override void GetTickValues(
            out IList <double> majorLabelValues, out IList <double> majorTickValues, out IList <double> minorTickValues)
        {
            minorTickValues = this.CreateDateTimeTickValues(
                this.ActualMinimum, this.ActualMaximum, this.ActualMinorStep, this.actualMinorIntervalType);
            majorTickValues = this.CreateDateTimeTickValues(
                this.ActualMinimum, this.ActualMaximum, this.ActualMajorStep, this.actualIntervalType);
            majorLabelValues = majorTickValues;

            minorTickValues = AxisUtilities.FilterRedundantMinorTicks(majorTickValues, minorTickValues);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates <see cref="DateTime" /> tick values.
        /// </summary>
        /// <param name="min">The min.</param>
        /// <param name="max">The max.</param>
        /// <param name="interval">The interval.</param>
        /// <param name="intervalType">The interval type.</param>
        /// <returns>A list of <see cref="DateTime" /> tick values.</returns>
        private IList <double> CreateDateTimeTickValues(
            double min, double max, double interval, DateTimeIntervalType intervalType)
        {
            // If the step size is more than 7 days (e.g. months or years) we use a specialized tick generation method that adds tick values with uneven spacing...
            if (intervalType > DateTimeIntervalType.Days)
            {
                return(this.CreateDateTickValues(min, max, interval, intervalType));
            }

            // For shorter step sizes we use the method from Axis
            return(AxisUtilities.CreateTickValues(min, max, interval));
        }
        /// <inheritdoc/>
        public override void GetTickValues(out IList <double> majorLabelValues, out IList <double> majorTickValues, out IList <double> minorTickValues)
        {
            var axisRect = new OxyRect(this.ScreenMin, this.ScreenMax);

            var distanceTopLeft     = axisRect.TopLeft.DistanceTo(this.MidPoint);
            var distanceTopRight    = axisRect.TopRight.DistanceTo(this.MidPoint);
            var distanceBottomRight = axisRect.BottomRight.DistanceTo(this.MidPoint);
            var distanceBottomLeft  = axisRect.BottomLeft.DistanceTo(this.MidPoint);

            var maxDistance = Math.Max(distanceTopLeft, distanceTopRight);

            maxDistance = Math.Max(maxDistance, distanceBottomRight);
            maxDistance = Math.Max(maxDistance, distanceBottomLeft);

            var actualMaximum = this.InverseTransform(maxDistance);

            majorTickValues = AxisUtilities.CreateTickValues(this.ActualMinimum, actualMaximum, this.ActualMajorStep);
            minorTickValues = AxisUtilities.CreateTickValues(this.ActualMinimum, actualMaximum, this.ActualMinorStep);
            minorTickValues = AxisUtilities.FilterRedundantMinorTicks(majorTickValues, minorTickValues);

            majorLabelValues = majorTickValues;
        }