/// <summary> /// Evaluates the limits in the chart values /// </summary> public void Initialize(ISeriesView seriesView) { var config = GetConfig(seriesView); if (config == null) { return; } var xMin = double.PositiveInfinity; var xMax = double.NegativeInfinity; var yMin = double.PositiveInfinity; var yMax = double.NegativeInfinity; var wMin = double.PositiveInfinity; var wMax = double.NegativeInfinity; var tracker = GetTracker(seriesView); var cp = new ChartPoint(); var ax = seriesView.Model.Chart.AxisX[seriesView.ScalesXAt]; var ay = seriesView.Model.Chart.AxisY[seriesView.ScalesYAt]; double fx = double.IsNaN(ax.MinValue) ? double.NegativeInfinity : ax.MinValue, tx = double.IsNaN(ax.MaxValue) ? double.PositiveInfinity : ax.MaxValue, fy = double.IsNaN(ay.MinValue) ? double.NegativeInfinity : ay.MinValue, ty = double.IsNaN(ay.MaxValue) ? double.PositiveInfinity : ay.MaxValue; var isHorizontal = seriesView.Model.SeriesOrientation == SeriesOrientation.Horizontal; var index = 0; foreach (var item in this) { config.Evaluate(index, item, cp); index++; if (isHorizontal) { if (cp.X < fx || cp.X > tx) { continue; } } else { if (cp.Y < fy || cp.Y > ty) { continue; } } if (seriesView is IFinancialSeriesView) { if (cp.X < xMin) { xMin = cp.X; } if (cp.X > xMax) { xMax = cp.X; } if (cp.Low < yMin) { yMin = cp.Low; } if (cp.High > yMax) { yMax = cp.High; } if (cp.Weight < wMin) { wMin = cp.Weight; } if (cp.Weight > wMax) { wMax = cp.Weight; } } else if (seriesView is IScatterSeriesView || seriesView is IHeatSeriesView) { if (cp.X < xMin) { xMin = cp.X; } if (cp.X > xMax) { xMax = cp.X; } if (cp.Y < yMin) { yMin = cp.Y; } if (cp.Y > yMax) { yMax = cp.Y; } if (cp.Weight < wMin) { wMin = cp.Weight; } if (cp.Weight > wMax) { wMax = cp.Weight; } } else { if (cp.X < xMin) { xMin = cp.X; } if (cp.X > xMax) { xMax = cp.X; } if (cp.Y < yMin) { yMin = cp.Y; } if (cp.Y > yMax) { yMax = cp.Y; } } } tracker.XLimit = new CoreLimit(double.IsInfinity(xMin) ? 0 : xMin, double.IsInfinity(yMin) ? 1 : xMax); tracker.YLimit = new CoreLimit(double.IsInfinity(yMin) ? 0 : yMin, double.IsInfinity(yMax) ? 1 : yMax); tracker.WLimit = new CoreLimit(double.IsInfinity(wMin) ? 0 : wMin, double.IsInfinity(wMax) ? 1 : wMax); }
private static bool IsGarbage(ChartPoint point, PointTracker tracker) { return(point.Gci < tracker.Gci || double.IsNaN(point.X) || double.IsNaN(point.Y)); }