Exemple #1
0
        public void ZoomY()
        {
            if (XAxis == null)
            {
                return;
            }

            foreach (var group in _sections.SelectMany(x => x).Where(x => x != null).GroupBy(x => x.Series.YAxisKey))
            {
                var axisMinMax = new MinMaxTracker();

                foreach (var wrapper in group)
                {
                    var minMax = wrapper.GetMinMaxY(XAxis.ActualMinimum, XAxis.ActualMaximum);
                    if (!double.IsNaN(minMax.Min) && !double.IsNaN(minMax.Max))
                    {
                        axisMinMax.Track(minMax.Min, minMax.Max);
                    }
                }

                if (!double.IsNaN(axisMinMax.Min) && !double.IsNaN(axisMinMax.Max))
                {
                    double delta = Math.Abs(axisMinMax.Max - axisMinMax.Min) * 0.02;
                    Axes.First(x => x.Key == group.Key).Zoom(axisMinMax.Min - delta, axisMinMax.Max + delta);
                }
            }
        }
Exemple #2
0
        private void RebuildSeries()
        {
            _xTracker.Reset();
            Series.Clear();
            foreach (var axis in Axes.Where(x => x.Position == AxisPosition.Left).ToList())
            {
                Axes.Remove(axis);
            }

            var    trueSections  = _sections.Where(x => x.Any(s => s != null)).ToList();
            double sectionHeight = 1.0d / trueSections.Count;

            for (int i = 0; i < trueSections.Count; i++)
            {
                string axisKey = Guid.NewGuid().ToString();
                var    axis    = YAxisFactory();
                axis.StartPosition = sectionHeight * i;
                axis.EndPosition   = sectionHeight * i + sectionHeight * (i == trueSections.Count - 1 ? 1.0 : 0.9);
                axis.Key           = axisKey;

                Axes.Add(axis);

                foreach (var series in trueSections[i].Where(x => x != null))
                {
                    series.Series.YAxisKey = axisKey;
                    Series.Add(series.Series);
                }
            }

            ((IPlotModel)this).Update(true);
            foreach (var series in Series.OfType <XYAxisSeries>())
            {
                _xTracker.Track(series.MinX);
                _xTracker.Track(series.MaxX);
            }
        }
Exemple #3
0
        public void ZoomX()
        {
            if (XAxis == null)
            {
                return;
            }

            var tracker = new MinMaxTracker();

            foreach (var series in FlatSeries)
            {
                var minMax = series.GetMinMaxX();
                if (minMax != null)
                {
                    tracker.Track(minMax.Value.Min, minMax.Value.Max);
                }
            }

            double delta = Math.Abs(tracker.Max - tracker.Min) * 0.02;

            XAxis.Zoom(tracker.Min - delta, tracker.Max + delta);
        }
Exemple #4
0
        public override MinMaxTracker GetMinMaxY(double startX, double endX)
        {
            var result = new MinMaxTracker();

            if (_points.Count == 0)
            {
                return(result);
            }

            GotoX(startX);

            PointWrapper point;
            int          idx = _curIdx;

            while (idx < _points.Count && (point = _pointWrapperFunc(_points[idx])).X < endX)
            {
                result.Track(point.MaxY, point.MinY);
                idx++;
            }

            return(result);
        }