views:

1243

answers:

0

I'm using the MS Chart Control in a Winforms app I'm writing. The X-axis component of the scatter plot I'm displaying is Int64 data, which ultimately represents a UTC time. I'd like to take that Int64 data and essentially do a DataTime.FromFileTimeUTC(theTime).ToString() on it to show the end-user X-axis labels that are meaningful.

Currently, I'm creating another column in the in-memory DataTable to hold the DateTime equivalent of that Int64 like so:

dataTable.Columns.Add("mytimestamp");
foreach (DataRow dr in dataTable.Rows)
{
   dr["mytimestamp"] = DateTime.FromFileTimeUTC(Convert.ToInt64(dr["theint64val"].ToString()));
}

And then using the "mytimestamp" column as the x-axis value. This works fine and I can show the x-axis labels as datetime values.

But, I'd rather not go through the trouble of creating the column and essentially duplicating the other column's data but didn't see any way to format the x-axis labels. Might have missed this, I supposed. I saw the AxisViewChanged event in the documentation and saw how I might set the chart title with that data but not the x-axis labels themselves.

Any ideas?