ZedGraph 을 사용한 그래프 그리기
private void CreateZedgraph() //그래프 그리기 함수 정의
{
try
{
GraphPane mypane = zgc.GraphPane;
mypane.CurveList.Clear(); //기존의 그래프 삭제
mypane.Title.Text = "적합도 분포 산출";
mypane.XAxis.Title.Text = "시간";
mypane.YAxis.Title.Text = "적합도";
PointPairList G1 = new PointPairList();
PointPairList G2 = new PointPairList();
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
G1.Add(Convert.ToDouble(dataGridView1.Rows[i].Cells[6].Value), Convert.ToDouble(dataGridView1.Rows[i].Cells[2].Value));
G2.Add(Convert.ToDouble(dataGridView1.Rows[i].Cells[6].Value), Convert.ToDouble(dataGridView1.Rows[i].Cells[5].Value));
}
LineItem mycurve = mypane.AddCurve("G1", G1, Color.Green);
LineItem mycurve2 = mypane.AddCurve("G2", G2, Color.Blue);
//mycurve.Line.Fill = new Fill(Color.White, Color.Green, 45F);
//mycurve.Symbol.Fill = new Fill(Color.White);
//mycurve2.Line.Fill = new Fill(Color.White, Color.Blue, 45F);
//mycurve2.Symbol.Fill = new Fill(Color.White);
mypane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F);
mypane.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45F);
zgc.AxisChange();
zgc.Refresh();
}
catch
{
MessageBox.Show("그래프를 구현할수 없습니다", "오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}