国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net 生成曲線圖實現(xiàn)代碼

2024-07-10 12:39:16
字體:
來源:轉載
供稿:網友
我的Dataset是從表Sendrec里讀取的數(shù)據(jù),分別有Id,Sendid(訂單號),Sendtime(記錄時間),Sendnum(單位時間發(fā)送量/我這里是五分鐘)幾個字段
過程如下:
public void draw(Page page,DataSet ds,int Tnum){}
其中page是用來傳遞引用這個過程的頁面,這樣讓頁面是JPG方式直接向客戶端輸出生成的曲線圖.
ds就是取出來的數(shù)據(jù)集了
Tnum只是我這里要用到的一個參數(shù),不想讓這個類去接觸讀取過程,所以把訂單的總量直接取出后傳遞給它的.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing;
using System.IO;
public class imgdraw
{
public imgdraw()
{
}
public void draw(Page page,DataSet ds,int Tnum)
{
//取得記錄數(shù)量
int count = ds.Tables[0].Rows.Count;
//記算圖表寬度
int wd = 80 + 20 * (count - 1);
//設置最小寬度為800
if (wd < 800) wd = 800;
//生成Bitmap對像
Bitmap img=new Bitmap(wd,400);
//生成繪圖對像
Graphics g = Graphics.FromImage(img);
//定義黑色畫筆
Pen Bp = new Pen(Color.Black);
//定義紅色畫筆
Pen Rp = new Pen(Color.Red);
//定義銀灰色畫筆
Pen Sp = new Pen(Color.Silver);
//定義大標題字體
Font Bfont = new Font("Arial", 12, FontStyle.Bold);
//定義一般字體
Font font = new Font("Arial", 6);
//定義大點的字體
Font Tfont = new Font("Arial", 9);
//繪制底色
g.DrawRectangle(new Pen(Color.White, 400), 0, 0, img.Width, img.Height);
//定義黑色過渡型筆刷
LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0,img.Width, img.Height), Color.Black, Color.Black, 1.2F, true);
//定義藍色過渡型筆刷
LinearGradientBrush Bluebrush = new LinearGradientBrush(newRectangle(0, 0, img.Width, img.Height), Color.Blue, Color.Blue, 1.2F,true);
//繪制大標題
g.DrawString(ds.Tables[0].Rows[0]["sendid"].ToString() + "號訂單發(fā)送情況曲線圖", Bfont, brush, 40, 5);
//取得當前發(fā)送量
int nums=0;
for (int i = 0; i < count; i++)
{
nums+=Convert.ToInt32(ds.Tables[0].Rows[i]["sendnum"]);
}
//繪制信息簡報
string info="訂單發(fā)送時間:"+ds.Tables[0].Rows[0]["sendtime"].ToString()+" 曲線圖生成時間:"+DateTime.Now.ToString()+" 訂單總量:"+Tnum.ToString()+" 當前發(fā)送總量:"+nums.ToString();
g.DrawString(info, Tfont, Bluebrush, 40, 25);
//繪制圖片邊框
g.DrawRectangle(Bp, 0, 0, img.Width - 1, img.Height - 1);
//繪制豎坐標線
for (int i = 0; i < count; i++)
{
g.DrawLine(Sp, 40+20 * i, 60, 40+20 * i, 360);
}
//繪制時間軸坐標標簽
for (int i = 0; i < count; i+=2)
{
string st = Convert.ToDateTime(ds.Tables[0].Rows[i]["sendtime"]).ToString("hh:mm");
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 屯昌县| 饶平县| 兴文县| 米泉市| 高平市| 万宁市| 灵武市| 彭州市| 奉化市| 全椒县| 美姑县| 宜君县| 红安县| 翁牛特旗| 山东| 剑阁县| 莱阳市| 镇康县| 凤阳县| 江华| 逊克县| 长垣县| 鹤峰县| 左贡县| 紫阳县| 美姑县| 那坡县| 徐水县| 苏尼特右旗| 乌拉特后旗| 崇阳县| 惠来县| 吴堡县| 文成县| 东台市| 东台市| 桃园市| 临桂县| 长乐市| 东城区| 文成县|