第八章 圖形化報表

成都創新互聯主營靖安網站建設的網絡公司,主營網站建設方案,成都APP應用開發,靖安h5小程序定制開發搭建,靖安網站營銷推廣歡迎靖安等地區企業咨詢
1.Highcharts
2.水晶報表
3.jqchart
4.MSChart:
例如:
//檢索重慶市月平均氣溫
string sql = @"select DATEPART (month,dtmMeasure) as 'Month',AVG (fltTemperature ) as 'AvgTemp' from TblTemperature
where chvCityName ='重慶' group by DATEPART (month,dtmMeasure) order by Month desc";
DataSet ds = SqlHelper.Select(CommandType.Text, sql, null);
//設置圖表背景顏色
this.Chart1.BackColor = Color.LightPink;
//設置圖表邊框樣式
this.Chart1.BorderlineColor = Color.Green;
//邊框線寬度
this.Chart1.BorderlineWidth = 5;
//圖表邊框西安為細線
this.Chart1.BorderlineDashStyle = ChartDashStyle.Solid;
//標題
this.Chart1.Titles.Add("重慶市月平均氣溫走勢圖");
//設置圖表X,Y軸綁定的列
this.Chart1.Series[0].XValueMember = "Month";
this.Chart1.Series[0].YValueMembers = "AvgTemp";
//設置每個數據點標簽上顯示的值為數據點的值
this.Chart1.Series[0].IsValueShownAsLabel = true;
//設置數據點標簽的文本格式]
this.Chart1.Series[0].LabelFormat = "{0}℃";
//綁定數據源
this.Chart1.DataSource = ds;
this.Chart1.DataBind();//折線圖
//檢索重慶市月平均氣溫
string sql = @"select chvCityName, DATEPART (month,dtmMeasure) as 'Month',AVG (fltTemperature )
as 'AvgTemp' from TblTemperature
where chvCityName ='重慶' or chvCityName ='北京'
group by chvCityName,DATEPART (month,dtmMeasure) order by Month desc";
DataSet ds = SqlHelper.Select(CommandType.Text, sql, null);
//為圖表添加2個序列
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.Pink;
//設置圖表邊框樣式
this.Chart1.BorderlineColor = Color.Green;
//邊框線寬度
this.Chart1.BorderlineWidth = 5;
//圖表邊框西安為細線
this.Chart1.BorderlineDashStyle = ChartDashStyle.Solid;
//標題
this.Chart1.Titles.Add("中國城市月平均氣溫走勢圖");
//圖例
this.Chart1.Legends.Add("");
foreach (DataRow row in ds.Tables [0].Rows )
{
//定義數據點
DataPoint point = new DataPoint(Convert.ToDouble(row["Month"]), Convert.ToDouble(row["AvgTemp"]));
//設置每個數據點在X軸的標簽文本
point.AxisLabel = string.Format("{0}月", row["Month"]);
//設置每個數據點的標簽文本
point.Label = string.Format("{0}℃", row["AvgTemp"]);
//設置鼠標懸浮至數據點的提示文本
point.LabelToolTip = string.Format("{0}月平均氣溫:{1}攝氏度", row["Month"], row["AvgTemp"]);
this.Chart1.Series[row["chvCityName"].ToString()].Points.Add(point);
}//餅圖
//檢索重慶市月平均氣溫
string sql = @"select (case
when intScore<60 then '不及格'
when intScore<80 then '及格'
when intScore<90 then '良'
when intScore<=100 then '優秀' end) as Grade,
count(*) as 'Count' from scoreinfo
group by(case
when intScore<60 then '不及格'
when intScore<80 then '及格'
when intScore<90 then '良'
when intScore<=100 then '優秀' end)";
DataSet ds = SqlHelper1.Select(CommandType.Text, sql, null);
//為圖表添加序列
this.Chart1.Series.Clear();
this.Chart1.Series.Add("Score");
//設置序列的圖表類型
this.Chart1.Series["Score"].ChartType = SeriesChartType.Pie;
//設置背景顏色
this.Chart1.BackColor = Color.Pink;
//設置圖表邊框樣式
this.Chart1.BorderlineColor = Color.Purple;
this.Chart1.BorderlineWidth = 5;
this.Chart1.BorderlineDashStyle = ChartDashStyle.Solid;
this.Chart1.Titles.Add("C#成績統計圖");
//文本顏色
this.Chart1.Series["Score"].LabelForeColor = Color.Gray;
//字體大小,樣式
this.Chart1.Series["Score"].Font = new Font("宋體", 14);
//計算總人數
int total = 0;
foreach (DataRow row in ds.Tables[0].Rows)
{
total += Convert.ToInt32(row["Count"]);
}
foreach (DataRow row in ds.Tables[0].Rows)
{
//定義數據點
DataPoint point = new DataPoint();
//總人數
point.YValues = new double[] { Convert.ToDouble(row["Count"]) };
//設置每一個數據點標簽的文本值為百分比
point.Label = string.Format("{0:f2}%", Convert.ToDouble(row["Count"]) / total * 100);
//設置圖例
this.Chart1.Legends.Add(row["Grade"].ToString());
point.LegendText = row["Grade"].ToString();
//將數據點添加到序列中
this.Chart1.Series["Score"].Points.Add(point);
}
//將數據點標簽顯示到圖示外側
Chart1.Series["Score"]["PieLabelStyle"] = "Outside";
//將第一個數據點展開
Chart1.Series["Score"].Points[0]["Exploded"] = "true";//柱狀圖
//檢索重慶市月平均氣溫
string sql = @"select (case
when intScore<60 then '不及格'
when intScore<80 then '及格'
when intScore<90 then '良'
when intScore<=100 then '優秀' end) as Grade,
count(*) as 'Count' from scoreinfo
group by(case
when intScore<60 then '不及格'
when intScore<80 then '及格'
when intScore<90 then '良'
when intScore<=100 then '優秀' end)";
DataSet ds = SqlHelper1.Select(CommandType.Text, sql, null);
//為圖表添加序列
this.Chart1.Series.Clear();
this.Chart1.Series.Add("Score");
//設置序列的圖表類型
this.Chart1.Series["Score"].ChartType = SeriesChartType.Column;
//設置背景顏色
this.Chart1.BackColor = Color.Pink;
//設置圖表邊框樣式
this.Chart1.BorderlineColor = Color.Purple;
this.Chart1.BorderlineWidth = 5;
this.Chart1.BorderlineDashStyle = ChartDashStyle.Solid;
this.Chart1.Titles.Add("C#成績統計圖");
//文本顏色
this.Chart1.Series["Score"].LabelForeColor = Color.Gray;
//字體大小,樣式
this.Chart1.Series["Score"].Font = new Font("宋體", 14);
//計算總人數
int total = 0;
foreach (DataRow row in ds.Tables[0].Rows)
{
total += Convert.ToInt32(row["Count"]);
}
foreach (DataRow row in ds.Tables[0].Rows)
{
//定義數據點
DataPoint point = new DataPoint();
//總人數
point.YValues = new double[] { Convert.ToDouble(row["Count"]) };
//設置每一個數據點標簽的文本值為百分比
point.Label = string.Format("{0}人", Convert.ToDouble(row["Count"]));
point.AxisLabel = row["Grade"].ToString();
//將數據點添加到序列中
this.Chart1.Series["Score"].Points.Add(point);
//設置數據點被點擊后的回發值,該值可以在Click事件的ImageMapEventArgs參數中獲取
point.PostBackValue = string.Format("{0}|{1}", row["Grade"], row["Count"]);
}
//將數據點標簽顯示到圖示外側
Chart1.Series["Score"]["PieLabelStyle"] = "Outside";
//將第一個數據點展開
Chart1.Series["Score"].Points[0]["Exploded"] = "true";5.XtraReports
名稱欄目:第八章圖形化報表
文章源于:http://www.yijiale78.com/article36/ghdgpg.html
成都網站建設公司_創新互聯,為您提供建站公司、外貿網站建設、面包屑導航、靜態網站、品牌網站制作、App設計
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯