This project is read-only.

Plot axis flickering

Aug 6, 2014 at 10:00 PM
Edited Aug 6, 2014 at 10:06 PM
Dear Folks:
The following function is receiving the new data from external about every 30 miliseconds:

public void RedrawLinePlot(int nColorChannels)
            int startIndex = _initialChildrenCount;

            _nColorChannels = nColorChannels;

            if ((_nColorChannels > 0) && (_dataX != null) && (_dataY != null))
                CompositeDataSource[] dsCh = new CompositeDataSource[_nColorChannels];

                for (int i = 0; i < _maxChannels; i++)    // color reset
                    ((LineGraph)plotter.Children.ElementAt(startIndex + i)).LinePen = new Pen(new SolidColorBrush(Colors.Transparent), 1);

                LineProfileColorSetup();    // color setup

                for (int i = 0; i < _nColorChannels; i++)
                    if (_dataX[i].Length == _dataY[i].Length)
                        EnumerableDataSource<double> xOneCh = new EnumerableDataSource<double>(_dataX[i]);
                        xOneCh.SetXMapping(xVal => xVal);
                        EnumerableDataSource<double> yOneCh = new EnumerableDataSource<double>(_dataY[i]);
                        yOneCh.SetYMapping(yVal => yVal);
                        CompositeDataSource ds = new CompositeDataSource(xOneCh, yOneCh);

                        ((LineGraph)plotter.Children.ElementAt(startIndex+i)).DataSource = ds;

                        ((LineGraph)plotter.Children.ElementAt(startIndex+i)).LinePen = new Pen(new SolidColorBrush(_lineprofileColor[i]), 1);

The x and y data are updated every time when this function got input from external. The x data never change, simple same array kept being sent to this function. The y data changes but within a fixed range.

However, the axis of the plot is really flickering. I commented out the FitToView(), the flickering stops, but also the line profile stops updating.

I am wondering how I can get rid of the flickering? Thanks a million! Best regards.
Aug 7, 2014 at 6:14 AM
Edited Aug 7, 2014 at 6:20 AM

When ever you get the new data call
For x axis fix the start and end time use xais.SetConversion(....) to fix the x axis, here endtime = DateTime.Now + some buffer time. When ever DateTime.Now crosses the end time again change the end time and call the SetConverion again.

search around the ddd discussions. some where code is available.

Aug 7, 2014 at 3:07 PM
Thanks Ravi. How ever I don't quite understand why the axis flickering should have anything to do with DateTime.Now and endtime? Care to explain a little more? Thanks.