public void CutByBefore(int xi, int yi, int offset, Color c, int type)
        {
            List <float> y1_x = new List <float>();
            List <float> y1_y = new List <float>();
            List <float> data = new List <float>();

            List <float> _x = new List <float>();
            List <float> _y = new List <float>();

            //i+offset < dp.data.Count
            for (int i = 0; i + offset < dp.dataNum; i++)
            {
                Double[,] d = new double[offset, 2];
                for (int j = 0; j < offset; j++)
                {
                    d[j, 0] = dp.data[i + j].data[xi];
                    d[j, 1] = dp.data[i + j].data[yi];
                }

                PCA pca = new PCA(d);
                data.Add((float)pca.a * dp.data[i + offset].data[xi] + (float)pca.b - dp.data[i + offset].data[yi]);
                _x.Add(dp.data[i + offset].data[xi]);
                _y.Add(dp.data[i + offset].data[yi]);

                Console.WriteLine(i.ToString());
            }
            timeGraphObj tgoj = new timeGraphObj();



            tgoj.SetData(_x, _y);
            timeGraph.SetDrawData(data, type, offset, c, tgoj);
            timeGraph.AddShown(type);
        }
        public int CutDataByYear(int xi, int yi, string y1_s, string y1_e, string y2_s, string y2_e, int offset, Color c, int type)
        {
            List <Data> y1 = dp.SearchData(y1_s, y1_e);
            List <Data> y2 = dp.SearchData(y2_s, y2_e);

            List <float> y1_x = new List <float>();
            List <float> y1_y = new List <float>();
            List <float> y2_x = new List <float>();
            List <float> y2_y = new List <float>();

            for (int i = 0; i < y1.Count; i++)
            {
                y1_x.Add(y1[i].data[xi]);
                y1_y.Add(y1[i].data[yi]);
            }
            for (int i = 0; i < y2.Count; i++)
            {
                y2_x.Add(y2[i].data[xi]);
                y2_y.Add(y2[i].data[yi]);
            }


            timeGraphObj tgoj = new timeGraphObj();

            tgoj.SetData(y1_x, y1_y);
            tgoj.CalculateRegression();
            List <float> tmpf = new List <float>();

            tmpf = tgoj.GetDiff(y2_x, y2_y);

            offset += y1.Count;



            timeGraph.SetDrawData(tmpf, type, offset, c, tgoj);
            timeGraph.AddShown(type);
            return(offset);
        }