真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

ASP.NET畫直方圖

 最近做直方圖,找到了這篇文章,以此為例畫一般的直方圖可以實(shí)現(xiàn)了。
using System;  using System.Collections;  using System.ComponentModel;  using System.Data;  using System.Drawing;  using System.Web;  using System.Web.SessionState;  using System.Web.UI;  using System.Web.UI.WebControls;  using System.Web.UI.HtmlControls;  using System.Drawing.Imaging;  using System.Drawing.Drawing2D;    namespace commonu  {  /**////   /// WebForm2 的摘要說(shuō)明。  ///   public class WebForm2 : System.Web.UI.Page  {  private void Page_Load(object sender, System.EventArgs e)  {    /**//*自寫編碼*/  int ImgWidth=600; //1.[總寬度] ***圖寬度   int ImgHeight=300; //2.[總高度] ***圖高度   int ItemNum=1; //3.[項(xiàng)目數(shù)量] ***圖表劃分的塊   int ChildNum=6; //4.[塊數(shù)] ***大塊中劃分的子項(xiàng)的數(shù)量  float ChildRate=0.6f; //5.[各塊總占空間比率]  //int ChildSpace=15; //6.[各塊間的間距]  int ChartLeft=80; //7.[圖表左邊距] ***圖表距圖的左邊距離  int ChartRight=50; //8.[圖表右邊距] ***圖表距圖的右邊距離  int ChartTop=50; //9.[圖表頂邊距] ***圖表距圖頂邊距離  int ChartBottom=50; //10.[圖表底邊距] ***圖表距圖底邊距離  int YMaxValue=5000; //11.[縱坐標(biāo)標(biāo)尺最大值] ***縱坐標(biāo)標(biāo)尺的最大值  int YItemNum=10; //12.[縱坐標(biāo)標(biāo)尺段數(shù)] ***縱坐標(biāo)標(biāo)尺的段數(shù)  int YTop=15; //13.[距縱軸頂端間隔]  int YStrStart=35; //14.[縱坐標(biāo)標(biāo)尺文字起始X坐標(biāo)]  int XRight=15; //15.[距橫軸右端間隔]  int XStrStart=20; //16.[橫坐標(biāo)標(biāo)尺文字起始Y坐標(biāo)]    //[圖表總寬度]=[總寬度]-[圖表左邊距]-[圖表右邊距]-[距橫軸右端間隔]  int chartwidth=ImgWidth-ChartLeft-ChartRight-XRight;  //[項(xiàng)目寬度]=[圖表總寬度]/[項(xiàng)目數(shù)量]  int itemwidth=chartwidth/ItemNum;  //[各塊總占空間比率的實(shí)際寬度]=[項(xiàng)目寬度]*[各塊總占空間比率]  int factwidth=Convert.ToInt32(Math.Floor(itemwidth*ChildRate));  //[各塊矩形寬度]=[各塊總占空間比率的實(shí)際寬度]/[塊數(shù)]  int rectanglewidth=factwidth/ChildNum;  //[各塊間的間距]=([項(xiàng)目寬度]-[各塊總占空間比率的實(shí)際寬度])/([塊數(shù)]+1)  int childspace=Convert.ToInt32(Math.Floor((itemwidth-factwidth)/(ChildNum+1)));    Graphics objGps;//建立畫板對(duì)象  Bitmap objBitMap = new Bitmap(ImgWidth,ImgHeight);//建立位圖對(duì)象  objGps = Graphics.FromImage(objBitMap);//根據(jù)位圖對(duì)象建立畫板對(duì)象  objGps.Clear(Color.White);//設(shè)置畫板對(duì)象的背景色    int[] arrValues={0,0,0,0,0,0};//數(shù)據(jù)數(shù)組  //arrValues[0]=500;  arrValues[0]=Convert.ToInt32(Math.Floor((ImgHeight-ChartBottom-ChartTop-YTop)*500/YMaxValue)); //處理顯示數(shù)據(jù),進(jìn)行圖表數(shù)值對(duì)應(yīng)  arrValues[1]=Convert.ToInt32(Math.Floor((ImgHeight-ChartBottom-ChartTop-YTop)*700/YMaxValue));  arrValues[2]=Convert.ToInt32(Math.Floor((ImgHeight-ChartBottom-ChartTop-YTop)*900/YMaxValue));  arrValues[3]=Convert.ToInt32(Math.Floor((ImgHeight-ChartBottom-ChartTop-YTop)*1000/YMaxValue));  arrValues[4]=Convert.ToInt32(Math.Floor((ImgHeight-ChartBottom-ChartTop-YTop)*1400/YMaxValue));  arrValues[5]=Convert.ToInt32(Math.Floor((ImgHeight-ChartBottom-ChartTop-YTop)*2200/YMaxValue));  string[] arrValueNames={"0","0","0","0","0","0","0","0","0","0"};//月份    arrValueNames[0] = "一月";  arrValueNames[1]="二月";  arrValueNames[2] = "三月";  arrValueNames[3]="四月";  arrValueNames[4]="五月";  arrValueNames[5]="六月";  arrValueNames[6] = "七月";  arrValueNames[7]="八月";  arrValueNames[8]="九月";  arrValueNames[9]="十月";    //得出矩形寬度,和畫圖X軸位置    //[項(xiàng)目寬度]=[總寬度]/[項(xiàng)目數(shù)量]  //======[各塊總占空間比率]=([各塊矩形寬度]+[各塊間的間距])/[項(xiàng)目寬度]  //[各塊總占空間比率的實(shí)際寬度]=[項(xiàng)目寬度]*[各塊總占空間比率]  //[各塊矩形寬度]=([各塊總占空間比率的實(shí)際寬度]-[各塊間的間距]*([塊數(shù)]))/[塊數(shù)]  //[一邊空余空間寬度]=([項(xiàng)目寬度]-[各塊所占空間比率的總寬度])/2     System.Drawing.Point[] pi=new Point[arrValues.Length]; //定義折線點(diǎn)的對(duì)象數(shù)組  System.Drawing.Point[] pit=new Point[3]; //定義坐標(biāo)三角點(diǎn)的對(duì)象數(shù)組  System.Drawing.Pen pe=new Pen(new SolidBrush(GetColor(7)),1f); //定義畫直線的對(duì)象  //畫縱軸  objGps.DrawLine(pe,new Point(ChartLeft,ImgHeight-ChartBottom),new Point(ChartLeft,ChartTop));  //畫縱軸終點(diǎn)箭頭  pit[0].X=ImgWidth-ChartRight; //確定三角形三點(diǎn)的位置  pit[0].Y=ImgHeight-ChartBottom-4;  pit[1].X=ImgWidth-ChartRight;  pit[1].Y=ImgHeight-ChartBottom+4;  pit[2].X=ImgWidth-ChartRight+10;  pit[2].Y=ImgHeight-ChartBottom;  objGps.FillPolygon(new SolidBrush(GetColor(7)),pit);  //畫縱軸標(biāo)尺和標(biāo)尺描述  for(int i=1;i<=YItemNum;i++)  {  //畫標(biāo)尺  objGps.DrawLine(pe,new PointF(ChartLeft,ImgHeight-ChartBottom-(ImgHeight-ChartBottom-ChartTop-YTop)/YItemNum*i),new PointF(ChartLeft-5,ImgHeight-ChartBottom-(ImgHeight-ChartBottom-ChartTop-YTop)/YItemNum*i));  //畫描述  objGps.DrawString(arrValueNames[i-1].ToString(),new Font("宋體",10),Brushes.Black,new Point(YStrStart,ImgHeight-ChartBottom-(ImgHeight-ChartBottom-ChartTop-YTop)/YItemNum*i-5));  }  //畫橫軸  objGps.DrawLine(pe,new Point(ChartLeft,ImgHeight-ChartBottom),new Point(ImgWidth-ChartRight,ImgHeight-ChartBottom));  //畫橫軸終點(diǎn)箭頭  pit[0].X=ChartLeft-4; //確定三角形三點(diǎn)的位置  pit[0].Y=ChartTop;  pit[1].X=ChartLeft+4;  pit[1].Y=ChartTop;  pit[2].X=ChartLeft;  pit[2].Y=ChartTop-10;  objGps.FillPolygon(new SolidBrush(GetColor(7)),pit);  //畫橫軸標(biāo)尺和標(biāo)尺描述  for(int i=1;i<=ItemNum;i++)  {  objGps.DrawLine(pe,new PointF(ChartLeft+itemwidth*i,ImgHeight-ChartBottom),new PointF(ChartLeft+itemwidth*i,ImgHeight-ChartBottom+5));  objGps.DrawString(arrValueNames[i-1].ToString(),new Font("宋體",10),Brushes.Black,new Point(ChartLeft+childspace+itemwidth*(i-1),ImgHeight-ChartBottom+XStrStart));  }    for(int j = 0;j0)  {  objGps.DrawLine(pe,pi[j-1],pi[j]);  }  }    objBitMap.Save(Response.OutputStream,ImageFormat.Gif);//該位圖對(duì)象以"GIF"格式輸出  }  /**//// 系統(tǒng)定義的顏色,有效值0到7,分別為(Blue,Yellow,Red,Orange,Purple,Brown,Pink,Black)  ///   public static Color GetColor(int itemIndex)  {  Color objColor = new Color();  switch(itemIndex)  {  case 0:  objColor = Color.Blue;  break;  case 1:  objColor = Color.Yellow;  break;  case 2:  objColor = Color.Red;  break;  case 3:  objColor = Color.Orange;  break;  case 4:  objColor = Color.Purple;  break;  case 5:  objColor = Color.Brown;  break;  case 6:  objColor = Color.Pink;  break;  default:  objColor = Color.Black;  break;  }  return objColor;  }  /**//// 自定義顏色紅色分量值,有效值0到255  /// 自定義顏色綠色分量值,有效值0到255  /// 自定義顏色藍(lán)色分量值,有效值0到255  ///   public static Color GetColor(int red,int green,int blue)  {  Color objColor = new Color();  objColor = Color.FromArgb(red,green,blue);  return objColor;  }  

你還可能感興趣:使用AspNetPager控件分頁(yè)

新聞標(biāo)題:ASP.NET畫直方圖
網(wǎng)址分享:http://weahome.cn/article/pshocj.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部