11-13-2012 10:58 PM
Sir,
I am using wpf graph control in my application. My intention is to plot the data, which consists of Timestamp as X-value and corresponding some float value as Y-value...How can i specify this kind of data to wpf graph?? I have tried the following but this is not correclty displaying the time.
I converted timestamp to double value using ToOADate() method and the X-axis i specified as ni:DateTimeAxis..I have supplied the double Point array as a datasource to the graph..But this is not correctly displaying the time...Can this be sorted out??
11-14-2012 09:34 AM
The WPF graph has native support for DateTime and PrecisionDateTime values, so you do not need to convert your data to double values first. Simply use a data type that can supply time values, such as AnalogWaveform<TData>. For example:
// XAML
<ni:Graph Name="graph">
<ni:Graph.Axes>
<ni:AxisDateTime Orientation="Horizontal" />
</ni:Graph.Axes>
</ni:Graph>
// code
double[] sampleValues = ...;
WaveformTiming timeValues = WaveformTiming.Create...;
var waveform = AnalogWaveform<double>.FromArray1D( sampleValues );
waveform.Timing = timeValues;
graph.DataSource = waveform;