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

首頁 > 開發 > 綜合 > 正文

C#畫折線圖

2024-07-21 02:26:38
字體:
來源:轉載
供稿:網友

using system;
using system.data;
using system.configuration;
using system.collections;
using system.web;
using system.web.security;
using system.web.ui;
using system.web.ui.webcontrols;
using system.web.ui.webcontrols.webparts;
using system.web.ui.htmlcontrols;
using system.drawing;
using system.drawing.imaging;
public partial class default5 : system.web.ui.page
{
    protected void page_load(object sender, eventargs e)
    {
        this.pic();


    }
    private void pic()
    {
        //測試數據
        datatable table = new datatable("data");
        datarow dr;
        datacolumn dc = new datacolumn("id",type.gettype("system.int32"));
        datacolumn dc2 = new datacolumn("num",type.gettype("system.int32"));
        datacolumn dc3 = new datacolumn("name", type.gettype("system.string"));
        table.columns.add(dc);
        table.columns.add(dc2);
        table.columns.add(dc3);
        random rnd=new random();
        for (int n = 0; n < 61; n++)
        {
            dr = table.newrow();
            dr[0] = n;
            dr[1] = rnd.next(10, 140);
            dr[2] = n.tostring();
            table.rows.add(dr);
        }
        //畫圖參數
        int bg_width = 450;
        int bg_height = 180;
        int pic_width = 450;
        int pic_height = 180;
        int pic_x = 6;
        int pic_h = 1;
        int pic_tr=5;
        int pic_td = 12;
        rectangle rec = new rectangle(50, 15, 360, 150);
        pen pic_bolder = new pen(color.black, 1);
        pen pic_line = new pen(color.gray, 1);
        pen pic_data = new pen(color.red,2);
        solidbrush brusth = new solidbrush(color.blue);
        point[] datapt = new point[table.rows.count];
        int x;
        int y;
        for (int n = 0; n < table.rows.count; n++)
        {
            dr=table.rows[n];
            x=(int)dr[0] * pic_x + rec.x;
            y=(int)dr[1] * pic_h + rec.y;
            datapt[n] = new point(x,y);
        }
        bitmap bg = new bitmap(bg_width, bg_height, pixelformat.format24bpprgb);
        graphics ph = graphics.fromimage(bg);
        ph.clear(color.white);      
        ph.drawrectangle(pic_bolder, rec);
        //畫折線
        ph.drawcurve(pic_data, datapt);
        //rec.
        point spoint=new point();
        point epoint=new point();
        //畫橫線
        for (int n = 1; n < pic_tr; n++)
        {
           //cell[0] = new point(rec.x);
            spoint.x = 0 + rec.x;
            spoint.y = n * 30 + rec.y;
            epoint.x = rec.width + rec.x;
            epoint.y = n * 30 + rec.y;
            ph.drawline(pic_line,spoint,epoint);
        }
        //畫豎線
        for (int n = 1; n < pic_td; n++)
        {
            spoint.x = n * 30 +rec.x;
            spoint.y = rec.y;
            epoint.x = n * 30 + rec.x;
            epoint.y = rec.height+ rec.y;
            ph.drawline(pic_line, spoint, epoint);
        }
        //畫標題
        string title = "畫折線測試";       
        solidbrush brush=new solidbrush(color.royalblue);
        ph.drawstring(title, new font("franklin gothic demi", 12, fontstyle.italic), brush, new point(200, 0));
        ph.save();
        bg.save(response.outputstream, imageformat.gif);
    }
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 荆门市| 甘泉县| 龙里县| 通榆县| 三明市| 邯郸市| 出国| 湘阴县| 景德镇市| 德清县| 普宁市| 尼木县| 讷河市| 社旗县| 金平| 江华| 温宿县| 呈贡县| 邹平县| 镇平县| 讷河市| 吴川市| 茂名市| 榕江县| 芮城县| 许昌市| 佛山市| 应用必备| 罗山县| 云浮市| 即墨市| 汨罗市| 巧家县| 凤冈县| 白水县| 监利县| 方城县| 新和县| 盖州市| 克什克腾旗| 哈巴河县|