Real Time Performance

Dec 29, 2012 at 3:37 PM

I do not know what happen to new version D3, but the real time performance become bad. I use the old version DynamicDataDisplay libraby in Stable folder It is OK, but when I use DynamicDataDisplay libraby in Nightly floder. The horizontal axis flicks very heavy.Could some one can give me an explain?  code as follow.

public partial class Window1 : Window
    {
        double phase = 0;

        readonly double[] animatedX = new double[1000];
        readonly double[] animatedY = new double[1000];
        EnumerableDataSource<double> animatedDataSource = null;
        EnumerableDataSource<double> xSrc = null;

        DispatcherTimer timer = new DispatcherTimer
        {
            Interval = TimeSpan.FromMilliseconds(100)
        };

        public Window1()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(Window1_Loaded);
        }

        void Window1_Loaded(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < animatedX.Length; i++)
            {
                animatedX[i] = 2 * Math.PI * i / animatedX.Length+phase;
                animatedY[i] = Math.Sin(animatedX[i]);
            }
            xSrc = new EnumerableDataSource<double>(animatedX);
            xSrc.SetXMapping(x => x);
            animatedDataSource = new EnumerableDataSource<double>(animatedY);
            animatedDataSource.SetYMapping(y => y);

            // Adding graph to plotter
            CompositeDataSource ds=new CompositeDataSource(xSrc, animatedDataSource);
            plotter.AddLineGraph(ds,
                new Pen(Brushes.Magenta, 3),
                new PenDescription("Sin(x + phase)"));

            timer.Tick += new EventHandler(timer_Tick);
            timer.Start();
        }

        void timer_Tick(object sender, EventArgs e)
        {
            phase += 0.05;
            for (int i = 0; i < animatedX.Length; i++)
            {
                animatedX[i] = 2 * Math.PI * i / animatedX.Length + phase;
                animatedY[i] = Math.Sin(animatedX[i] + phase);
            }
            animatedDataSource.RaiseDataChanged();
        }
    }