Reputation: 31
Here is the Problem. I need to create multiple charts(number is not known previously). So, I am generating dynamic Chart. The problem is, chart appears but shows no data. It is just a blank white space.
private void Form1_Load(object sender, EventArgs e)
{
Chart demo = new Chart();
demo.Location = new Point(0, 0);
demo.Size=new Size(this.Width,this.Height);
demo.Series.Add("check");
DataPoint dp1 = new DataPoint(1, 1);
DataPoint dp2 = new DataPoint(2, 2);
DataPoint dp3 = new DataPoint(3, 3);
demo.Series["check"].Points.Add(dp1);
demo.Series["check"].Points.Add(dp2);
demo.Series["check"].Points.Add(dp3);
this.Controls.Add(demo);
demo.BringToFront();
demo.Visible = true;
}
Output is just a white chart with nothing on it.
Upvotes: 3
Views: 1373
Reputation: 2686
You need to create a chart area. Just add this line in your code.
demo.ChartAreas.Add("newchartarea");
Upvotes: 2