I could not figure out how to do this with a DataTable
since everything I found seems to be assuming you want to use columns for series, which makes no sense to me at all. So I ended up doing it the hard way. Every time I add a row to my DataTable
I also created an array of values. I then add a series as follows:
Series s = oneSecondChart.Series.Add(name);
s.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
for (int i = 0; i < data.Length; i++) {
oneSecondChart.Series[name].Points.AddY(data[i]);
}
I am quite irritated by having to use a loop to add the points, but I could not find a method that allows me to add an array of items--something that seems like it SHOULD be there. The AddY
method indicates that it takes an array, but it crashes at runtime.