The namespace I'm looking at is System.Windows.Forms.DataVisualization.Charting
in .NET Framework 3.5.
I've constructed a Chart
with name chart1
and added a Series
called mySeries
to that chart.
Within the Data section of that series in the designer, I have:
IsXValueIndexed --> False
Name --> mySeries
Points --> (Collection)
XValueType --> DateTime
YValuesPerPoint --> 1
YValueType --> Int32
When I try to add DataPoint
s to the series like this, it seems like I cannot add them with the x and y values of the appropriate type:
public void InitializeChart()
{
Series theSeries = chart1.Series["mySeries"];
// MyData is of type List<MyDatum> and MyDatum has two members --
// one of type DateTime and another of type int
foreach (MyDatum datum in MyData)
{
// I'd like to construct a DataPoint with the appropriate types,
// but the compiler wants me to supply doubles to dp
DataPoint dp = new DataPoint(mySeries);
dp.XValue = datum.TimeStamp;
dp.YValue = datum.MyInteger;
radiosConnectedSeries.Points.Add(dp);
}
}
What am I missing? Thanks as always!
DateTime.ToOADate() will return the timestamp as a double that can be used as x value