示例#1
0
        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);
        }
示例#2
0
        public void SetDrawData(List <float> d, int t, int o, Color c, timeGraphObj _obj)
        {
            float per_width  = (endX - startX) / (float)total;
            int   per_length = (endY - startY) / 2;

            //float max = timeGraphObj.GetMax(d);
            float max = max_value;

            List <Point> tmpP = new List <Point>();

            for (int i = 0; i < d.Count; i++)
            {
                tmpP.Add(new Point((int)(startX + per_width * (i + o)), (int)((endY + startY) / 2 - per_length * (d[i] / max))));
            }


            Data _data = new Data(t, o, per_width, tmpP, d, c, _obj);

            draw_data.Add(_data);



            /*
             * float per_width = (endX - startX) / (float)data.Count;
             * data_point.Clear();
             * int per_length = (endY - startY) / 2;
             *
             * for (int i = 0; i < data.Count; i++)
             *  data_point.Add(new Point((int)(startX + per_width * i), (int)((endY + startY) / 2 - per_length * (data[i] / max))));
             *
             */
        }
示例#3
0
 public Data(int t, int o, float per, List <Point> _p, List <float> d, Color c, timeGraphObj _obj)
 {
     type      = t;
     offset    = o;
     perWidth  = per;
     p         = new List <Point>();
     p         = _p;
     _data     = new List <float>();
     _data     = d;
     dataColor = c;
     obj       = _obj;
 }
示例#4
0
        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);
        }