在图表中显示报告

时间:2014-02-10 03:05:08

标签: c# charts

嗨我想在我的C#aplication(winform)中制作图表 我的目标很简单我想在图表中显示有多少人选择答案,B答案等 像这样的事 Chart
在该聊天中使用35值' y,我想根据总答案总数(答案A +答案B = 15 + 20)使其成为恐龙。

我已经尝试过这样的事了     //(方法A)

this.myChart.Series["Answer"].Points.AddY("Answer A");
this.myChart.Series["Answer"].Points.AddY("Answer A");
this.myChart.Series["Answer"].Points.AddY("Answer B");

//AND (method B)  
 this.myChart.Series["Answer"].Points.AddXY("Answer A", 1);
 this.myChart.Series["Answer"].Points.AddXY("Answer B", 1);
 this.myChart.Series["Answer"].Points.AddXY("Answer B", 2);
 this.myChart.Series["Answer"].Points.AddXY("Answer B", 3);
 this.myChart.Series["Answer"].Points.AddXY("Answer B", 4);
 this.myChart.Series["Answer"].Points.AddXY("Answer A", 2);

//结果方法B
   enter image description here

但结果并非如我所愿 anyidea怎么做?

1 个答案:

答案 0 :(得分:1)

int sumOfAnswerA = // get the sum of ppl choose A from your data
int sumOfAnswerB = // get the sum of ppl choose B from your data.

现在您可以在图表中设置点

this.myChart.Series["Answer"].Points.AddXY("Answer A", sumOfAnswerA );
this.myChart.Series["Answer"].Points.AddXY("Answer B", sumOfAnswerB );