티스토리 뷰
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();
}
}