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