3

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.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364

1 Answers1

2

You need to create a chart area. Just add this line in your code.

demo.ChartAreas.Add("newchartarea");
Ramesh Durai
  • 2,666
  • 9
  • 32
  • 55