Exemplo n.º 1
0
        public ScatterSeries Correlate(TimeSeries ts2)
        {
            ScatterSeries ss = new ScatterSeries()
            {
                MarkerSize = .8, MarkerStroke = OxyColors.Blue, MarkerFill = OxyColors.Blue
            };
            bool axis1Direction = this.domain[1] - this.domain[0] > 0;
            bool axis2Direction = ts2.domain[1] - ts2.domain[0] > 0;
            int  i = this.Count() - 1;
            int  j = ts2.Count() - 1;
            List <IDataPoint> newPoints = new List <IDataPoint>();

            while (i >= 0 && j >= 0)
            {
                double domaini = this.domain[i];
                double domainj = ts2.domain[j];
                if (domaini != domainj)
                {
                    if (domaini > domainj)
                    {
                        if (axis1Direction)
                        {
                            i--;
                        }
                        else
                        {
                            j--;
                        }
                    }
                    else
                    {
                        if (axis2Direction)
                        {
                            j--;
                        }
                        else
                        {
                            i--;
                        }
                    }
                    continue;
                }
                else
                {
                    newPoints.Add(new DataPoint(this.range[i], ts2.range[j]));
                    i--;
                    j--;
                }
            }
            ss.Points = newPoints;
            return(ss);
        }