示例#1
0
        public ScatterSeries Correlate2(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, j;

            if (axis1Direction)
            {
                i = this.Count() - 1;
            }
            else
            {
                i = 0;
            }
            if (axis2Direction)
            {
                j = ts2.Count() - 1;
            }
            else
            {
                j = 0;
            }

            List <IDataPoint> newPoints = new List <IDataPoint>();

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