0

How to fast Feed large number of data to OxyPlot?

ShannonZ 7 year бұрын 0

I have about 100k ponits(TComplex[100k] ) to draw. 


 [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public struct TComplex
    {
        public float Re;
        public float Im;
    } // end TComplex


The data(along side with a recording time) was returned by an older hardware API to control the machine to start scan. 


I want to draw the real part, imaginary part and the amplitude(calculated using Re and Im) of the TComplex[100k]. To feed data  to PlotMode, I create a new class "measurement" to contain Re, Im, and Abs:

 public class Measurement
    {
        public double tau { get; set; }  // recording time(ms), xlabel
        public double Re{ get; set; }  // ylabel
        public double Im { get; set; } // ylabel
        public double Abs { get; set; } // ylabel

    }


Then in the viewModel part, the scanning data was feeding to  

public Collection<Measurement> Measurements { get; private set; }

by a for loop:

  for (int i = 0; i < N; i++)
            {
                dy += (r.NextDouble() * 2) - 1;
                y += dy;
                this.Measurements.Add(new Measurement
                                     {
                                         Time =tau[i],
                                         Re = ...,
                                         Im = ...,
                                         Abs = ...
                                     });
                
            }
        }


The data was displayed correctly but the for-loop was extremly slow when the scale of scanning data became huge. Is there any fast way to implement this? I just want to implement the matlab routine 

plot(x,Re,x,Im,x,Abs) using OxyPlot.