0

我正在尝试在 flowlayoutpanel 中添加图表作为控件,但是在执行所有图表后显示为空白如何解决这个问题?这是我的代码

flowLayoutPanel1.Controls.Clear();
System.Windows.Forms.DataVisualization.Charting.Series Series = new Series();
Chart[] chartMensal = new Chart[12];
for (int i = 1; i <= 12; i++)
{
  string[] seriesArray = { "Total Contrato", "Total Vendas", "Total Despeses" };
  Double[] pointsArray = { 1000, 1500, 500 };

  chartMensal[i] = new Chart();
  chartMensal[i].Width = this.Width - 100;
  chartMensal[i].Height = 200;

  chartMensal[i].Titles.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).ToUpper());
  chartMensal[i].Palette = ChartColorPalette.Fire;
  chartMensal[i].Series.Clear();
  Series.Points.Clear();

  for (int t = 0; t < seriesArray.Length; t++)
  {
    Series.Points.Add(pointsArray[t]);
    Series = chartMensal[i].Series.Add(seriesArray[t]);
  }

  chartMensal[i].Visible = true;
  flowLayoutPanel1.Controls.Add(chartMensal[i]);
}
4

1 回答 1

0

您缺少图表区域本身。在最后一行之前添加:

                ChartArea ca = new ChartArea();
            chartMensal[i].ChartAreas.Add(ca);

看看设计师是如何创建图表的。您肯定也可以在此论坛中找到解决方案。

于 2013-02-19T14:44:38.063 回答