常用的图形报表组件
Highcharts : 纯javascript编写的 支持所有主浏览器,支持图片缩放显示,开源
水晶报表: 商务智能(BI)软件实现了与绝大对数流行开发工具的集成和接口
JqChart: 由html5和jquery 编写 支持手持设备,具备实时绘制功能
MSChart: vs 自带
XtraReports: 适用于Windows和ASP.NET
private void showdata()
{
string sql = string.Format("select chvCityName,DATEPART(month,dtmMeasure) as 'Month' ,AVG(fltTemperature) as 'AvgTemp' from TblTenmperature where chvCityName='重庆' or chvCityName='北京' group by chvCityName,DATEPART(month,dtmMeasure) order by Month desc");
DataSet ds = SqlHelper.ExecuteDataSet(sql, null);
this.Chart1.Series.Clear();
this.Chart1.Series.Add("重庆");
this.Chart1.Series.Add("北京");
//图表类型
this.Chart1.Series["重庆"].ChartType = SeriesChartType.Line;
this.Chart1.Series["北京"].ChartType = SeriesChartType.Line;
this.Chart1.BackColor = Color.Azure;
//边框
this.Chart1.BorderlineColor = Color.Green;
this.Chart1.BorderlineWidth = 5;
this.Chart1.BorderlineDashStyle = ChartDashStyle.Solid;
this.Chart1.Titles.Add("中国城市月平均气温走势图");
foreach (DataRow item in ds.Tables[0].Rows)
{
DataPoint point=new DataPoint (Convert.ToDouble(item["Month"]),Convert.ToDouble(item["AvgTemp"]));
point.AxisLabel = string.Format("{0}月",item["Month"]);
point.Label = string.Format("{0}°", item["AvgTemp"]);
point.LabelToolTip = string.Format("{0}月平均气温:{1}摄氏度", item["Month"], item["AvgTemp"]);
this.Chart1.Series[item["chvCityName"].ToString()].Points.Add(point);
// this.Chart1.Legends.Add(item["AvgTemp"].ToString());
// point.LegendText=item["AvgTemp"].ToString();
}
}