Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

WPF Graph - AxisDateTime with AbsoluteTimeStamp

Solved!
Go to solution

Hello,

 

I am trying to plot a few Observable Collection to Graph with AxisDateTime.

 

Graph:

<ni:Graph x:Name="Graphs_HPT_Temperature" PreferIndexData="False" RenderMode="Raster" Margin="10,10,10,10" Interactions="">
            <ni:Graph.Axes>
                <ni:AxisDateTime Location="Near" Label="Time (s)" Orientation="Horizontal">
                    <ni:AxisDateTime.MajorDivisions>
                        <ni:RangeLabeledDivisions TickMark="Rectangle"/>
                    </ni:AxisDateTime.MajorDivisions>
                </ni:AxisDateTime>
                <ni:AxisDouble Label="Temperature (°C)" Orientation="Vertical" Range="0, 100, System.Double"/>
            </ni:Graph.Axes>
            <ni:Graph.Plots>
                <ni:Plot Label="Temp 1">
                    <ni:PlotRendererGroup>
                        <ni:LinePlotRenderer Stroke="IndianRed"/>
                        <ni:PointPlotRenderer Stroke="Black" Fill="IndianRed"/>
                    </ni:PlotRendererGroup>
                </ni:Plot>
                <ni:Plot Label="Temp 2">
                    <ni:PlotRendererGroup>
                        <ni:LinePlotRenderer Stroke="DimGray" />
                        <ni:PointPlotRenderer Stroke="Black" Fill="DimGray"/>
                    </ni:PlotRendererGroup>
                </ni:Plot>
                <ni:Plot Label="Temp 3">
                    <ni:PlotRendererGroup>
                        <ni:LinePlotRenderer Stroke="Blue" />
                        <ni:PointPlotRenderer Stroke="Blue" Fill="LimeGreen"/>
                    </ni:PlotRendererGroup>
                </ni:Plot>
            </ni:Graph.Plots>
        </ni:Graph>

I am defining source of data like this (all three data sources - randValues, randValues2 and randValues3 - are ObservableCollection<double> :

Graphs_HPT_Temperature.Data[0] = randValues;
Graphs_HPT_Temperature.Data[1] = randValues2;
Graphs_HPT_Temperature.Data[2] = randValues3;

ObservableCollections are filled with data every second. The following picture describes my problem, when I am using AxisDateTime, the showing date is relative (starting from 1.1.0001) and not absolute. How can I get the absolute date (timestamp) on my AxisDateTime?

ni_picture.PNG

I know I can use Waveform structure for these, but when the ObservableCollection contains more than 1000 samples, I need to delete first sample of the collection. Unfortunately, Waveform contains only Append function.

 

Thanks for your answer.

0 Kudos
Message 1 of 2
(2,657 Views)
Solution
Accepted by topic author stysda

I would suggest using a ChartCollectionAnalogWaveform<double>, or a ChartCollection<DateTime, double>, instead of a WPF observable collection. The Capacity on the chart collection determines the sample history, so if you append more than that number of samples they will automatically be removed from the collection (no manual removes required).

~ Paul H
Message 2 of 2
(2,632 Views)