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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace winformchart { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void chart1_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { chart1.Series["Series1"].Points.Clear(); chart1.Series["Series1"].Points.Add(100); chart1.Series["Series1"].Points.Add(200); chart1.Series["Series1"].Points.Add(300); chart1.Series["Series1"].Points.Add(400); } private void button2_Click(object sender, EventArgs e) { chart2.Series["Series1"].Points.Clear(); chart2.Series["Series1"].Points.AddXY(10,100); chart2.Series["Series1"].Points.AddXY(20,200); chart2.Series["Series1"].Points.AddXY(30,300); chart2.Series["Series1"].Points.AddXY(40,400); chart2.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.SplineArea; } // binding for array/collection private void button3_Click(object sender, EventArgs e) { double[] scores = new double[] { 80, 90, 85, 70, 95 }; chart1.Series[0].Points.DataBindY(scores); List<string> x = new List<string> { "철수", "영희", "길동", "재동", "민희" }; List<double> y = new List<double> { 80, 95, 85, 70, 95 }; chart2.Series[0].Points.DataBindXY(x, y); // data binding for object collections List<Worker> workers = new List<Worker>(); workers.Add(new Worker("철수", 80)); workers.Add(new Worker("영희", 90)); workers.Add(new Worker("길동", 85)); chart3.Series[0].Points.DataBind(workers, "Name", "Grade", null); } } class Worker { public string Name { get; set; } public double Grade { get; set; } public Worker(string name, double Grade) { this.Name = name; this.Grade = Grade; } } } | cs |
'C#' 카테고리의 다른 글
c# winform timer (0) | 2021.11.07 |
---|---|
c# winform backgroundworker 스레드 중단/재개하기 코드 (1) | 2021.11.06 |
c# winform listview (0) | 2021.11.05 |
c# winform drag & drop (0) | 2021.11.05 |
c# winform background worker 사용하기 (0) | 2021.11.05 |