Beispiel #1
0
        public ITicksInfo <T> GetTicks(Range <T> range, int ticksCount)
        {
            Verify.IsTrue(ticksCount > 0);

            T        start  = range.Min;
            T        end    = range.Max;
            TimeSpan length = GetDifference(start, end);

            diff = strategy.GetDifference(length);

            TicksInfo <T> res = new TicksInfo <T> {
                Info = diff
            };

            if (providers.ContainsKey(diff))
            {
                ITicksInfo <T> result     = providers[diff].GetTicks(range, ticksCount);
                T[]            mayorTicks = result.Ticks;

                res.Ticks   = mayorTicks;
                this.result = res;
                return(res);
            }

            throw new InvalidOperationException(Properties.Resources.UnsupportedRangeInAxis);
        }
Beispiel #2
0
        public ITicksInfo <double> GetTicks(Range <double> range, int ticksCount)
        {
            double start  = range.Min;
            double finish = range.Max;

            double delta = finish - start;

            int log = (int)Math.Round(Math.Log10(delta));

            double newStart  = RoundHelper.Round(start, log);
            double newFinish = RoundHelper.Round(finish, log);

            if (newStart == newFinish)
            {
                log--;
                newStart  = RoundHelper.Round(start, log);
                newFinish = RoundHelper.Round(finish, log);
            }

            // calculating step between ticks
            double unroundedStep = (newFinish - newStart) / ticksCount;
            int    stepLog       = log;
            // trying to round step
            double step = RoundHelper.Round(unroundedStep, stepLog);

            if (step == 0)
            {
                stepLog--;
                step = RoundHelper.Round(unroundedStep, stepLog);
                if (step == 0)
                {
                    // step will not be rounded if attempts to be rounded to zero.
                    step = unroundedStep;
                }
            }

            if (step < minStep)
            {
                step = minStep;
            }

            if (step != 0.0)
            {
                ticks = CreateTicks(start, finish, step);
            }
            else
            {
                ticks = new double[] { };
            }

            TicksInfo <double> res = new TicksInfo <double> {
                Info = log, Ticks = ticks
            };

            return(res);
        }
        public ITicksInfo <double> GetTicks(Range <double> range, int ticksCount)
        {
            if (Coeffs.Length == 0)
            {
                return(new TicksInfo <double>());
            }

            var minorTicks = ranges.Select(r => CreateTicks(r)).SelectMany(m => m);
            var res        = new TicksInfo <double>();

            res.TickSizes = minorTicks.Select(m => m.Value).ToArray();
            res.Ticks     = minorTicks.Select(m => m.Tick).ToArray();

            return(res);
        }
Beispiel #4
0
        public ITicksInfo <T> GetTicks(Range <T> range, int ticksCount)
        {
            if (mayorTicks.Length == 0)
            {
                return(new TicksInfo <T>());
            }

            ticksCount /= mayorTicks.Length;
            if (ticksCount == 0)
            {
                ticksCount = 2;
            }

            var ticks = mayorTicks.GetPairs().Select(r => Clip(provider.GetTicks(r, ticksCount), r)).
                        SelectMany(t => t.Ticks).ToArray();

            var res = new TicksInfo <T>
            {
                Ticks     = ticks,
                TickSizes = ArrayExtensions.CreateArray(ticks.Length, ticksSize)
            };

            return(res);
        }