-
C# Chart그리기-1C#/WindowForm 2022. 6. 1. 18:39
차트 디자인 윈폼의 Chart를 사용하여 차트를 만들어보자
namespace _039_Chart { public partial class Form1 : Form { public Form1() { InitializeComponent(); this.Text = "Using Chart Contorl"; } private void Form1_Load(object sender, EventArgs e) { Random r = new Random(); chart1.Titles.Add("중간고사 성적"); for (int i = 0; i < 10; i++) { chart1.Series["Series1"].Points.Add(r.Next(100)); } chart1.Series[0].LegendText = "비주얼프로그래밍"; chart1.Series[0].ChartType = SeriesChartType.Line; } } }
this.Text로 윈도우 창의 이름을 Using Chart Contorl로 설정한다
차트의 나타낼 데이터는 랜덤숫자로 설정해뒀다.
chart1.Titles.Add로 차트의 제목을 설정해준다.
Series1을 랜덤한 100까지의 숫자로 10번 채워준다.
LegendText는 차트에 표시하는 이름이고 ChartType은 차트의 타입을 설정한다 지금 선택한 것은 줄 차트이다.
실행결과 실행결과이다.
'C# > WindowForm' 카테고리의 다른 글
C# 그래프 그리기 (0) 2022.06.01 C# Chart 그리기- 2 (0) 2022.06.01 ACCESS를 사용한 DB연결 -3 (PhoneBook) (0) 2022.05.18 dataTimePicker (0) 2022.04.06 Timer 사용 (0) 2022.04.06