asp.net 曲线图
public void draw(DataTable dt)
{
//取得记录数量
int count = dt.Rows.Count;
//记算图表宽度
int wd = 80 + 20 * (count - 1);
//设置最小宽度为800
if (wd < 600) wd = 600;
//生成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);
//定义横坐标间隔,(最佳值是总宽度-留空宽度[左右侧都需要])/(记录数量-1)
int xSpace = (wd - 100) / (count - 1);
//定义纵坐标间隔,不能随便修改,跟高度和横坐标线的条数有关,最佳值=(绘图的高度-上面留空-下面留空)
int ySpace = 30;
//纵坐标最大值和间隔值
int yMaxValue = 30;
//绘制底色
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(new Rectangle(0, 0, img.Width, img.Height), Color.Blue, Color.Blue, 1.2F, true);
//绘制大标题
g.DrawString("测试曲线图", Bfont, brush, 40, 5); //绘制信息简报
string info = " 曲线图生成时间:" + DateTime.Now.ToString();
g.DrawString(info, Tfont, Bluebrush, 40, 25);
//绘制图片边框
g.DrawRectangle(Bp, 0, 0, img.Width - 1, img.Height - 1); //绘制竖坐标轴
g.DrawLine(Bp, 40, 55, 40, 360);
//绘制横坐标轴 x2的60是右侧空出部分
g.DrawLine(Bp, 40, 360, 60 + xSpace * (count - 1), 360); //绘制竖坐标标题
g.DrawString("测试值", Tfont, brush, 5, 40);
//绘制横坐标标题
g.DrawString("测试时间", Tfont, brush, 40, 385); //绘制竖坐标线
for (int i = 0; i < count; i++)
{
g.DrawLine(Sp, 40 + xSpace * i, 60, 40 + xSpace * i, 360);
}
//绘制时间轴坐标标签
for (int i = 0; i < count; i++)
{
string st = Convert.ToDateTime(dt.Rows[i]["AddTime"]).ToString("MM:dd");
g.DrawString(st, font, brush, 30 + xSpace * i, 370);
} //绘制横坐标线
for (int i = 0; i < 10; i++)
{
g.DrawLine(Sp, 40, 60 + ySpace * i, 40 + xSpace * (count - 1), 60 + ySpace * i);
//横坐标轴的值间隔是最大值除以间隔数
int s = yMaxValue - i * (yMaxValue / 10);
//绘制发送量轴坐标标签
g.DrawString(s.ToString(), font, brush, 10, 60 + ySpace * i);
} //定义纵坐标单位数值=纵坐标最大值/标量最大值(300/30)
int yAveValue = 10;
//定义曲线转折点
Point[] p = new Point[count];
for (int i = 0; i < count; i++)
{
p[i].X = 40 + xSpace * i;
p[i].Y = 360 - Convert.ToInt32(dt.Rows[i]["Number"]) * yAveValue;
}
//绘制折线图
//g.DrawLines(Rp, p);
//绘制曲线图
//g.DrawCurve(Rp, p);
//绘制自定义张力的曲线图(0.5F是张力值,默认就是这个值)
g.DrawCurve(Rp, p,0.5F); //当需要在一个图里绘制多条曲线的时候,就多定义个point数组,然后画出来就可以了。 for (int i = 0; i < count; i++)
{
//绘制发送记录点的发送量
g.DrawString(dt.Rows[i]["RoleName"].ToString(), font, Bluebrush, p[i].X, p[i].Y - 10);
//绘制发送记录点
g.DrawRectangle(Rp, p[i].X - 1, p[i].Y - 1, 2, 2);
} //保存绘制的图片
MemoryStream stream = new MemoryStream();
img.Save(stream, ImageFormat.Jpeg);
//图片输出
Response.Clear();
Response.ContentType = "image/jpeg";
Response.BinaryWrite(stream.ToArray());
}
asp.net 曲线图的更多相关文章
- asp.net曲线图
highcharts的曲线图控件真的很强大,自己研究了下,做了一个简单的,给自己留个备忘,希望能帮到需要的朋友 Dome下载:http://files.cnblogs.com/linyijia/asp ...
- Asp.net之MsChart控件动态绑定温度曲线图
<div> <div style="position: absolute; z-index: 200; background-color: #FFFFFF; height: ...
- Asp.net mvc4 + HighCharts + 曲线图
前端代码: @{ Layout = null;}<!DOCTYPE html><html><head> <title></title> &l ...
- ASP.NET Core 性能对比评测(ASP.NET,Python,Java,NodeJS)
前言 性能是我们日常生活中经常接触到的一个词语,更好的性能意味着能给我们带来更好的用户体检.比如我们在购买手机.显卡.CPU等的时候,可能会更加的关注于这样指标,所以本篇就来做一个性能评测. 性能也一 ...
- [转]ASP.NET MVC Json()处理大数据异常解决方法 json maxjsonlength
本文转自:http://blog.csdn.net/blacksource/article/details/18797055 先对项目做个简单介绍: 整个项目采用微软的ASP.NET MVC3进行开发 ...
- 比较不错的JS 曲线图
fashion chart falsh文件支持,无需考虑兼容 Highcharts(纯JS,很漂亮 效果很好) Highcharts是一个制作图表的纯Javascript类库,主要特性如下: 兼容 ...
- (转)ASP.NET Core 性能对比评测(ASP.NET,Python,Java,NodeJS)
转:https://www.cnblogs.com/savorboard/archive/2016/10/17/dotnet-benchmarks.html 前言 性能是我们日常生活中经常接触到的一个 ...
- asp.net(mvc) 框架
1.NFine mvc+ef 2.Grove orm架构 3.NHibernate orm 4.NBear 5.petshop 6.Membership 7.Brnshop 网上商城 8.cms快速开 ...
- ASP.NET统计图表控件
近来客户需要将前段时间开发的统计信息用图表展示出来,还要多个图表类型,例如:柱状图.饼图.曲线图.三维图等等.在网上google了一下,发现了三个(也许更多)可以使用的控件.下面我们一起看看这三个控件 ...
随机推荐
- PHP简单封装MysqlHelper类
MysqlHelper.class.php 1: <?php 2: 3: /** 4: * Mysql数据帮助类 5: */ 6: class MysqlHelper 7: { 8: func ...
- <a>标签跳转传值。
<a href="public_html/app/Tpl/song_1/inc/{url r="deal#support" p="id=$deal_inf ...
- Linux下查看nginx安装目录
输入命令行: ps -ef | grep nginx master process后边的目录即是.
- mysql:You can't specify target table 'bpm_tksign_data' for update in FROM clause
UPDATE bpm_tksign_data WHERE actinstid ' AND nodeid = 'SignTask1' AND batch = ( SELECT max(a.batch) ...
- Interleaving String leetcode
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example,Given:s1 = ...
- linux下VMware安装出现的问题解决
linux下VMware安装出现的问题解决 linux下VMware安装出现的问题解决 报错信息 问题1liboverlay-scrollbar.so和libunity-gtk-module.so加载 ...
- putty如何使用
使用putty连接管理centos 1 双击putty.exe2 和linux命令行一样了 使用psftp上传和下载 cd d:/psftppsftp open 10.0.0.9 输入用户密码root ...
- ext grid 子表格
Ext.define('app.view.main.biz.customer.receipt.followup.FollowUpActionPanel', { extend: 'Ext.grid.Pa ...
- iOS开源App整理
http://duxinfeng.com/2015/07/14/iOS%E5%BC%80%E6%BA%90App%E6%95%B4%E7%90%86/ http://blog.csdn.net/dux ...
- rabbitmq使用
1. 用户管理 用户管理包括增加用户,删除用户,查看用户列表,修改用户密码. 相应的命令 (1) 新增一个用户 rabbitmqctl add_user Username Password (2 ...