统计报表图(winform写的)
近来因项目需要,一定得做一个统计出来。而且要能显示各种图形。还是winform。我在网上找了好多资料,看得我头都大了。也问了一些朋友,最后自己憋了两天终于憋出来了。
不废话了,我写了一个简单的例子,供大家看看。效果图如下:
关键代码:
public FormPieChart() { InitializeComponent(); // IList <User > list = this.getAll(); this.AddTestData(list); this.InitChart(); }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
/// <summary>
/// 获取操作员统计数据
/// </summary>
/// <returns></returns>
private IList <User > getAll()
{
IList <User > list =new List<User>();
string conn = "user id=csyc;data source=csyc;password=csycpass";
string sql = "select operatorid as 操作员,count(*) 统计数目 from alarm group by operatorid";
OracleConnection connection = new OracleConnection(conn);
OracleCommand comm = new OracleCommand(sql, connection);
connection.Open();
OracleDataReader read = comm.ExecuteReader();
while (read.Read())
{
User user = new User();
user.Name = read["操作员"].ToString();
user.Count = Convert.ToInt32(read["统计数目"].ToString());
list.Add(user);
}
connection.Close();
return list ;
}
也算是小工告成了。。。哈哈