1
votes

I am plotting multiple series of data from CSV files on the same MSChart. Although the TimeString values for two series may not coincide (one group of points was gathered after the other), I'm getting the data for both plots overlaid, with the timestamp on the chart coming from the last series loaded.

I want to find out how to show each series of data with absolute time, so the time components from each series are relatively correct when the plots are compared. If they overlap in time the XY plots can overlap. If they are from separate time periods the plots should be adjacent.

This is how I read the CSV data into my DataTables

DataTable[] seriesData;
...
private void BindData(int pen, string fname)
{
    try
    {
        if (System.IO.File.Exists(fname))
        {
            seriesData[pen - 1] = GetDataTable(fname);
            DataTableReader myReader = seriesData[pen - 1].CreateDataReader();
            chart1.Series[pen - 1].Points.DataBindXY(myReader, "TimeString", myReader, "VarValue");
            chart1.Series[pen - 1].ChartType = SeriesChartType.Line;
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show("Exception: " + ex.Message);
    }
}
1

1 Answers

0
votes

I can't confirm this, but I don't see your data.

Here is an example with simple test data drawn from a Random object R and its result:

Series S1 = chart1.Series[0];
Series S2 = chart1.Series[1];
S1.ChartType = SeriesChartType.Line;
S2.ChartType = SeriesChartType.Line;
S1.Color = Color.Red;
S2.Color = Color.Green;
S1.XValueType = ChartValueType.Time;
S2.XValueType = ChartValueType.Time;

for (int d = 100; d < 200; d++)
{
    DateTime dt = DateTime.Now.AddMinutes(d);
    S1.Points.AddXY(dt, 100 + R.Next(100));
}
for (int d = 150; d < 300; d++)
{
    DateTime dt = DateTime.Now.AddMinutes(d);
    S2.Points.AddXY(dt, 200 + R.Next(100));
}

How are you setting the XValueType ?

overlapping times