Created
September 29, 2016 08:49
-
-
Save Larry57/722121c7369727d16c2e71967d18764a to your computer and use it in GitHub Desktop.
Create a ZedGraph PointList that use a object collection as a DataSource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GenericPointList<T> : IPointList { | |
List<T> innerList; | |
Func<T, double> ySelector; | |
Func<T, double> xSelector; | |
public GenericPointList(List<T> list, Func<T, double> xSelector, Func<T, double> ySelector) { | |
innerList = list; | |
this.xSelector = xSelector; | |
this.ySelector = ySelector; | |
} | |
public PointPair this[int index] { | |
get { | |
return new PointPair(xSelector(innerList[index]), ySelector(innerList[index])); | |
} | |
} | |
public int Count { | |
get { | |
return innerList.Count; | |
} | |
} | |
public object Clone() { | |
return this; | |
} | |
} | |
// Usage example: | |
FlameTemperatureSerie.Points = new GenericPointList<CalcResult>( | |
myList, | |
t => (double)new XDate(t.myXTimeStamp), | |
t => t.MyYValue | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment