티스토리 뷰

카테고리 없음

zed그래프 생성하기

뽀로로친구에디 2019. 1. 23. 11:30

  private void checkBox8_CheckedChanged(object sender, EventArgs e)  //그래프 전압

        {

            ysin = Convert.ToInt32(this.tb_volt_min.Text);

            ycos = Convert.ToInt32(this.tb_volt_max.Text);

            z1.GraphPane.CurveList.Clear();

            z1.GraphPane.GraphObjList.Clear();

            CreateGraph(ysin, ycos);


            


        }


        


        private void CreateGraph(int ysin, int ycos)

        {

            GraphPane myPane = z1.GraphPane;


            myPane.Title.Text = "ZedGraph Test";

            myPane.XAxis.Title.Text = "theta (angle)";

            myPane.YAxis.Title.Text = "Sin (theta)";


            PointPairList Sin = new PointPairList();

            PointPairList Cos = new PointPairList();

            PointPairList companyAPairList = new PointPairList();

            PointPairList companyBPairList = new PointPairList();


            int companyAData = 1;

            int companyBData = -1;


            for (int i = 0; i < 36; i += 1)

            {

                double x = (double)i * 1.0;// 좌표 섲렁

                double y_sin = Math.Sin((double)i * Math.PI / ysin); // sin 그래프의 값 얻는다

                double y_cos = Math.Cos((double)i * Math.PI / ycos); // cos 그래프의 값 얻는다.

                companyAPairList.Add(i + 1, companyAData);

                companyBPairList.Add(i + 1, companyBData);

                Sin.Add(x, y_sin);

                Cos.Add(x, y_cos);

            }



            myPane.XAxis.MajorGrid.IsVisible = true;

            myPane.YAxis.MajorGrid.IsVisible = true;


            LineItem companyACurve = myPane.AddCurve("Company A", companyAPairList, Color.Red, SymbolType.Circle);

            LineItem companyBCurve = myPane.AddCurve("Company B", companyBPairList, Color.Blue, SymbolType.Diamond);

            LineItem SinCurve = myPane.AddCurve("Sin (theta)", Sin, Color.BlueViolet, SymbolType.Plus);

            LineItem CosCurve = myPane.AddCurve("Sin (theta)", Cos, Color.Green, SymbolType.Plus);


            //  myPane.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45F); //맵 색보정



            z1.AxisChange();

            z1.Invalidate();

        }


    }



댓글
최근에 달린 댓글
글 보관함
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
Total
Today
Yesterday
    뽀로로친구에디
    최근에 올라온 글