The trick is understanding how to convert a DateTime value to a double so you can assign it to the cursor's YPosition property. The DateTime/double conversion factor that the Measurement Studio graphs use is a double value of 0.0 is equivalent to DateTime.MinValue and a double interval of 1.0 is equivalent to 1 second. The NationalInstruments.DataConverter class will convert from/to double and DateTime and TimeSpan with this conversion factor. For example, here's how you can convert a DateTime to a double and then set the cursor to this value:
xAxis1.Range = new Range(0, 10);
yAxis1.Range = new Range(DateTime.Today, TimeSpan.FromDays(1));
yAxis1.MajorDivisions.LabelFormat = new FormatString(FormatStringMode.DateTime, "h:mm");
double xPosition = 5.0;
double yPosition = (double)DataConverter.Convert(DateTime.Now, typeof(double));
xyCursor1.MoveCursor(xPosition, yPosition);
- Elton