/// <summary> /// Add a single point to the <see cref="PointPairList"/> from values of type double. /// </summary> /// <param name="x">The X value</param> /// <param name="y">The Y value</param> /// <returns>The zero-based ordinal index where the point was added in the list.</returns> public void Add(double x, double y) { _sorted = false; PointPair2D point = new PointPair2D(x, y); base.Add(point); }
/// <summary> /// Indexer: get the DataPoint instance at the specified ordinal position in the list /// </summary> /// <remarks> /// This method will throw an exception if the index is out of range. This can happen /// if the index is less than the number of filtered values, or if data points are /// removed from a filtered dataset with updating the filter (by calling /// <see cref="FilterData" />). /// </remarks> /// <param name="index">The ordinal position in the list of points</param> /// <returns>Returns a <see cref="PointPair" /> instance. The <see cref="PointPair.Z" /> /// and <see cref="PointPair.Tag" /> properties will be defaulted to /// <see cref="PointPairBase.Missing" /> and null, respectively. /// </returns> public new IPointPair this[int index] { get { int j = index; if (_isFiltered) { j = _visibleIndicies[index]; } DataPoint dp = base[j]; PointPair2D pt = new PointPair2D(dp.X, dp.Y); return(pt); } set { int j = index; if (_isFiltered) { j = _visibleIndicies[index]; } DataPoint dp; dp.X = value.X; dp.Y = value.Y; base[j] = dp; } }
/// <summary> /// Add a set of points to the PointPairList from two arrays of type double. /// If either array is null, then a set of ordinal values is automatically /// generated in its place (see <see cref="AxisType.Ordinal"/>. /// If the arrays are of different size, then the larger array prevails and the /// smaller array is padded with <see cref="PointPairBase.Missing"/> values. /// </summary> /// <param name="x">A double[] array of X values</param> /// <param name="y">A double[] array of Y values</param> /// <returns>The zero-based ordinal index where the last point was added in the list, /// or -1 if no points were added.</returns> public void Add(double[] x, double[] y) { int len = 0; if (x != null) { len = x.Length; } if (y != null && y.Length > len) { len = y.Length; } for (int i = 0; i < len; i++) { PointPair2D point = new PointPair2D(0, 0); if (x == null) { point.X = (double)i + 1.0; } else if (i < x.Length) { point.X = x[i]; } else { point.X = PointPair.Missing; } if (y == null) { point.Y = (double)i + 1.0; } else if (i < y.Length) { point.Y = y[i]; } else { point.Y = PointPair.Missing; } base.Add(point); } _sorted = false; }