饼图创建

时间:2014-05-24 22:13:40

标签: c# winforms charts mschart

为什么下面的代码不能创建饼图?如何显示以百分比表示的值?

string[] seriesArray1 = new string[dataGridView1.Rows.Count];
double[] pointsArray1 = new double[dataGridView1.Rows.Count];

for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
   seriesArray1[i] = dataGridView1.Rows[i].Cells[0].Value.ToString();
   pointsArray1[i] = Convert.ToDouble(dataGridView1.Rows[i].Cells[1].Value);
}

chart1.Titles.Add("Probability");

for (int i = 0; i < seriesArray1.Length; i++)
{
   Series series = chart1.Series.Add(seriesArray1[i]);
   series.ChartType = SeriesChartType.Pie;
   series.IsValueShownAsLabel = true;
   series.Points.Add(pointsArray1[i]);
}

0 个答案:

没有答案