Skip to content

Instantly share code, notes, and snippets.

@Larry57
Created September 29, 2016 08:49
Show Gist options
  • Save Larry57/722121c7369727d16c2e71967d18764a to your computer and use it in GitHub Desktop.
Save Larry57/722121c7369727d16c2e71967d18764a to your computer and use it in GitHub Desktop.
Create a ZedGraph PointList that use a object collection as a DataSource
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