ASP.NET 画趋势图,且每个节点可以点击查询,急................ ASP.NET + C# 画趋势图,每个月一个节点,且每个节点可以点击查询相应的数据,请问各位大侠该怎么做?如果背景颜色能随纵坐标由绿变红渐变就更好了.小弟先谢过各位了。急。。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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); }} http://download.csdn.net/down/418908/cumttoneu to zzxap,先谢过高手。还有一个重要的问题就是趋势图上的每一个节点要可以点击(从数据库查询相应的数据),比如1到12月每月有一个节点,每个月的节点连接起来构成一个趋势线,当点击某个节点时查询相应月的数据,请问怎样才能做到节点可以点击,能给帮我想一下解决方案吗,非常感谢! http://aspspider.ws/Chartlet/Demo.aspx 这里有个图表控件 .. 那要画热区显示用owc,zedgraph都可显示或FLASH编写代码实现连接参考参考 FusionChartsFreeCSDN也有下载:http://search.download.csdn.net/search/FusionChartsFree 我想在页面中输出GDI绘出的图像,怎么做 如何把.net2.0做的网站变成.net1.1的网站 弹出一个窗口,就像csdn提示节帖时候会弹出的那个!求教.. 诚征意见,地图数据存储 一个非常奇怪的问题!!!急 在线客服系统制作的思路? 问一个简单的日期格式化的问题 我页面上已经放了五个label,不过从数据库取出来的数据可以是五个也可能是小于五个(在线等,解决马上结帐,谢谢..... 求助:关于Datagrid分页和IsPostback属性 二级目录下网站301跳转问题 Ajax.net 的提示框问题 AJAX 页面 session问题
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);
}
}
这里有个图表控件 ..
用owc,zedgraph都可显示或FLASH编写代码实现连接
参考
参考
CSDN也有下载:
http://search.download.csdn.net/search/FusionChartsFree