I'm trying to plot XY data that looks a little like this:
x = (1/1/2000 10:01:23, 1/1/2000 10:02:50, 1/1/2000 10:04:11)
Y = (1,2,3)
I also have a starting time, a T=0, e.g. 1/1/2000 10:00:00.
What I want to plot then is:
X = (00:01:23, 00:02:50, 00:04:11) 'for purpose of question, a random interval
Y = (1,2,3)
I.e. the ELAPSED time calculated by doing time(x) - starttime.
However, you cannot chart the data type timespan: "Series data points do not support values of type System.TimeSpan only values of these types can be used: Double, Decimal, Single, int, long, uint, ulong, String, DateTime, short, ushort."
How do I call: Chart.Series(0).Points.AddXY(ElapsedTime, YValue) when i can't send a timespan? If i convert to a datetime I get 1/1/0001 12:01:23 or similar.
The exact relevant code is:
Dim a As DateTime = Convert.ToDateTime(DateTimePicker.Text) 'this is the starttime
Dim b As DateTime = ParseTimeStamp(ReferenceNumber) 'returns a datetime
Dim YValue as integer = 123
ElapsedTime = ??? 'some code that I can't work out to get elapsed time in chart friendly manner
Chart.Series(0).Points.AddXY(ElapsedTime,YValue)
Thanks.
EDIT: Found a solution for anyone also looking for a solution.
Dim a As DateTime = Convert.ToDateTime(StartTime.Text) 'a starting time
Dim b As DateTime = ParseTimeStamp(RefNumber) 'time you want to compare
Dim c As TimeSpan = b.Subtract(a)
Dim d As DateTime = Convert.ToDateTime(c.ToString)
MudLineChart.ChartAreas(0).AxisX.LabelStyle.Format = "HH:mm"
MudLineChart.Series(0).Points.AddXY(d.ToOADate(), YValue)
you need to format the series XValueType to time.