asp.net的產生曲線圖(1)

來源:互聯網
上載者:User
效果如下:

這裡是從Dataset裡的資料產生曲線圖.
我的Dataset是從表Sendrec裡讀取的資料,分別有Id,Sendid(訂單號),Sendtime(記錄時間),Sendnum(單位時間發送量/我這裡是五分鐘)幾個欄位

過程如下:
public void draw(Page page,DataSet ds,int Tnum){}
其中page是用來傳遞引用這個過程的頁面,這樣讓頁面是JPG方式直接向用戶端輸出產生的曲線圖.
ds就是取出來的資料集了
Tnum只是我這裡要用到的一個參數,不想讓這個類去接觸讀取過程,所以把訂單的總量直接取出後傳遞給它的.

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)
{
//取得記錄數量
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);
//繪製底色

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.