コード例 #1
0
        private List <RangeCounter> CreateRangeCounters(double minValue, double maxValue, double step, bool useLog, double logBase)
        {
            List <RangeCounter> rangeCounters = new List <RangeCounter>();

            if (useLog)
            {
                minValue = Math.Log(minValue, logBase);
                maxValue = Math.Log(maxValue, logBase);
                step     = Math.Log(step, logBase);
            }

            int count = (int)Math.Round(Math.Ceiling((maxValue - minValue) / step));

            for (int i = 0; i < count; i++)
            {
                RangeCounter r   = new RangeCounter();
                double       min = minValue + i * step;
                if (useLog)
                {
                    min = AxisMath.Trunc(Math.Pow(logBase, min));
                }

                r.MinValue = min;
                if (i == 0)
                {
                    r.IncludeMin = true;
                }
                else
                {
                    r.IncludeMin = false;
                }

                double max = minValue + (i + 1) * step;
                if (useLog)
                {
                    max = AxisMath.Trunc(Math.Pow(logBase, max));
                }
                r.MaxValue = max;

                if (r.MaxValue > (useLog? Math.Pow(logBase, maxValue):maxValue))
                {
                    r.MaxValue = useLog? AxisMath.Trunc(Math.Pow(logBase, maxValue)):maxValue;
                }

                r.IncludeMax = true;
                rangeCounters.Add(r);
            }
            return(rangeCounters);
        }
コード例 #2
0
 private void OnMaximumValueChanged(object sender, EventArgs e)
 {
     this.nudMaximum.DecimalPlaces = AxisMath.FracMinors(this.nudMaximum.Value);
 }