问题
I have a Charting.DataPointCollection and want to get only a part of the data. In a List you can do it like list.GetRange(int index, int count);
but in DataPointCollection you don't have GetRange().
I had the idea of using something like that: DataPoints.Where(elem => DataPoints.IndexOf(elem) >= i && DataPoints.IndexOf(elem) <= j)
but now i have an IEnumerable instead of a DataPointCollection...
How can i get a DataPointCollection as a Part of another DataPointCollection?
回答1:
Try this instead of using IndexOf()
DataPoints.Skip(number).Take(number);
As for getting result as the DataPointCollection
, I haven't found any reasonable way of converting it directly. Only thing I came up with is create a new Series
and insert the data points one by one to its Points
collection in a loop.
来源:https://stackoverflow.com/questions/20327721/charting-datapointcollection-how-to-get-a-range