我试图在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]);
}
答案 0 :(得分:0)
您缺少图表区域本身。 在最后一行之前添加:
ChartArea ca = new ChartArea();
chartMensal[i].ChartAreas.Add(ca);
了解设计师如何创建图表。你也确定在这个论坛中找到了解决方案。