I've done bindings to mschart before using datasets but now I want to use in-memory data without setting up databases etc.
What I've done is created a list<> of a simple class
Created a list of that class and add it as the chart datasource then assign the fields
create a new entry, add it to the list<> then databind
When run I get an argument exception:
I'm guessing I'm overlooking something simple. Any ideas?
What I've done is created a list<> of a simple class
C#:
private class TrendEntry
{
public DateTime logTime;
public Single room_Temp;
public Single room_SP;
public Single oat;
public int heat_On;
}
Created a list of that class and add it as the chart datasource then assign the fields
C#:
private List<TrendEntry> TrendData = new List<TrendEntry>();
Chart.DataSource = TrendData;
Chart.Series[(int)SeriesID.ROOMTEMP].XValueMember = "logTime";
Chart.Series[(int)SeriesID.ROOMTEMP].YValueMembers = "room_Temp";
create a new entry, add it to the list<> then databind
C#:
TrendEntry trendPoint = new TrendEntry();
trendPoint.logTime = DateTime.Now;
trendPoint.room_Temp = room_Temp;
trendPoint.room_SP = room_SP;
trendPoint.oat = outside_Temp;
trendPoint.heat_On = (room_HeatingDemand ? 1 : 0);
TrendData.Add(trendPoint);
Chart.DataBind();
When run I get an argument exception:
C#:
Series data points do not support values of type HVACSim.HVACSimFrm+TrendEntry only values of these types can be used: Double, Decimal, Single, int, long, uint, ulong, String, DateTime, short, ushort.
I'm guessing I'm overlooking something simple. Any ideas?