0
Ülevaatamisel

Series.Points showing returning an empty list when databound?

Xavier Hahn 10 aastat tagasi uuendatud 10 aastat tagasi 4
I've updated to the latest version of Oxyplot and seem to have a regression on the ScatterSeries<T> class.

I've written an extension method for a scatter series in "multiple selection" mode that allows to select all the points that return "true" at a specific function passed in parameter.

public static void SelectAll<T>(this ScatterSeries<T> series, Func<T, bool> func) where T : ScatterPoint, new()
{
foreach (var dataPoint in series.Points.Where(func))
{
series.SelectItem(series.Points.IndexOf(dataPoint));
}
}

it was working fine before the update, but now I see that the "Points" property return an empty list. Looking at the code, I see that there is a protected property "ItemsSourcePoints" that has the point list, but the "Points" property doesn't use it.

Is there a way to get the actual points? Is this by design or a bug?

Thanks.
Ülevaatamisel
I think this can be solved by changing the protected ActualPoints property to public. But this property should really only be exposed as a readonly collection or an IEnumerable<T>... The current implementation is a List<T> for performance reasons. Should we add another property or method that returns the actual points as IEnumerable<T>?
In ScatterSeries<T>, I suggest renaming the current ActualPoints to e.g. ActualPointsList and create a new ActualPoints property:
        /// <summary>
        /// Gets the actual points.
        /// </summary>
        /// <value>
        /// A read-only list of points.
        /// </value>
        public System.Collections.ObjectModel.ReadOnlyCollection<T> ActualPoints
        {
            get
            {
                return new System.Collections.ObjectModel.ReadOnlyCollection<T>(this.ActualPointsList);
            }
        }

        /// <summary>
        /// Gets the list of points that should be rendered.
        /// </summary>
        /// <value>A list of <see cref="DataPoint" />.</value>
        protected List<T> ActualPointsList
        {
            get
            {
                return this.ItemsSource != null ? this.ItemsSourcePoints : this.points;
            }
        }
Will this work?
Yes, I think that would be a very good solution.