ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Measurement Studio Graph to plot with time scale

I want to plot the graph of the data stored in database. There are 4 parameters and time parameter stored in the database. I want to plot these 4 parameters w.r.t time. All the four parameters are double in data type and time stored in the format hh:mm:ss AM e.g 02:12:55 AM. i am able to plot all the four parameter values but i am not able to assign X axis as time datatype as scatter.plotXY(Double,Double) datatype is required.

 

Pl help 

 

Thanks  

0 Kudos
Message 1 of 2
(5,517 Views)

Hello - 

 

I think you would actually find a Waveform Graph better suited to your needs - in conjunction with the AnalogWaveform data type.  The following sample code may be of some use to you.

 

// create some arbitrary data
double[,] data = { {1d, 2d, 3d, 4d, 5d},
                   {2d, 3d, 4d, 5d, 6d},
                   {3d, 4d, 5d, 6d, 7d},
                   {4d, 5d, 6d, 7d, 8d}};
string[] strTimes = { "02:12:53 AM",
                      "02:12:54 AM",
                      "02:12:57 AM",
                      "02:13:01 AM",
                      "02:13:02 AM"};
DateTime[] times = new DateTime[5];
AnalogWaveform[] waves;
WaveformTiming timing;

// parse out DateTimes from the string times 
for (int i = 0; i < times.Length; i++)
    Debug.Assert(DateTime.TryParse(strTimes[i], out times[i]));

// create the analog waveform array
waves = AnalogWaveform.FromArray2D(data);
// create the analog waveform timing information, irregular because the times don't have a regular interval 
timing = WaveformTiming.CreateWithIrregularInterval(times);
// associate each analog waveform with the timing information
foreach (AnalogWaveform wave in waves)
    wave.Timing = timing;

// configure the x axis to display time
waveformGraph1.XAxes[0].MajorDivisions.LabelFormat = new FormatString(FormatStringMode.DateTime, "hh:mm:ss tt");
waveformGraph1.PlotWaveforms(waves, new AnalogWaveformPlotOptions(AnalogWaveformPlotDisplayMode.Time, AnalogWaveformPlotScaleMode.Raw));

 

NickB05-08-11_01_52.png 

 

NickB

National Instruments 

0 Kudos
Message 2 of 2
(5,506 Views)