WPF Realtime or continous Charts

Jun 23 2011 11:42 AM

The Problem

I am creating a C# WPF  application to create a simple line chart that plots points as the data arrives from a stream reader. It will update about once a second. I cannot get the graph to display until all of the data has been processed. In XAML I create a window, grid and then a canvas.

My code uses an Observable collection to collect the data points. Each time I add a point the collection changed event is fired and I create a polyline from the collection. I clear the canvas children property and add the polyline.

 void Obdatapoints_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)

        {   GraphCanvas.Children.Clear();

            pl = CreateNewPolyLine(Obdatapoints);

           GraphCanvas.Children.Add(pl);

        }           

        I thought adding the children would cause the screen to redraw. It does not. It does draw only after all of the points are received.

How can I get the screen to redraw on each collection changed?

Alternatively,  It has been suggested to me that I use the native WPF chart control to do this task. I have not found any documentation that shows how to use the control for a chart that is continuously updated. I will have about 1260 updates once each second or so. Will the WPF chart control support continuous updating and display the chart after each update.


Answers (1)