Here, I will explain how to use a Chart Graph a Windows application.
Step 1: Form
Drag and drop a chart graph and a button from the ToolBox.
You can change the properties of this chart graph. The main property of this chart graph is "collection".
From this we set the Graph as a X-axis and Y-axis. Here I am making a graph of age and score.You can change the color and background image.
Step 2: Code
Click on the button and write the following code.
- Private void Chart_btn_Click(object sender, Event args)
- {
- this.chart1.Series["Age"].Points.AddXY("max",33);
- this.chart1.Series["Score"].Points.AddXY("max",93);
- this.chart1.Series["Age"].Points.AddXY("carl",20);
- this.chart1.Series["Score"].Points.AddXY("carl",70);
- this.chart1.Series["Age"].Points.AddXY("mark",50);
- this.chart1.Series["Score"].Points.AddXY("mark",56);
- this.chart1.Series["Age"].Points.AddXY("Alli",40);
- this.chart1.Series["Score"].Points.AddXY("Alli",30);
- }
Step 3: Run
Now run your application and click on the button.