各位神仙大哥大姐
如图:想询问下 能不能在.NET环境下把这个图表画出来?整张图是代表电力系统在不同时间的电压值。外圈的1~24 是代表一天的24个小时(从0点到24点),横坐标的刻度(例如:0.0-1.0)分为10格,现在就是有每分钟的刻度坐标(比如:1:00---2.3;1:01---2.4; 1:02----2.4; 1:03-----2.5; 1:04---2.5;1:05----2.7等等),如何把这些坐标用类似如图的方式表示出来(黑点连成的线表示),.NET是不是有这样的控件或者代码能实现?
万分感谢 关注~ 大家帮帮忙.....
如图:想询问下 能不能在.NET环境下把这个图表画出来?整张图是代表电力系统在不同时间的电压值。外圈的1~24 是代表一天的24个小时(从0点到24点),横坐标的刻度(例如:0.0-1.0)分为10格,现在就是有每分钟的刻度坐标(比如:1:00---2.3;1:01---2.4; 1:02----2.4; 1:03-----2.5; 1:04---2.5;1:05----2.7等等),如何把这些坐标用类似如图的方式表示出来(黑点连成的线表示),.NET是不是有这样的控件或者代码能实现?
万分感谢 关注~ 大家帮帮忙.....
解决方案 »
- 急:treeview的父子结点被选中的问题,如何实现这样的功能?
- .net小程序
- |zyciis| 如何让VS2005发布网站的时候生成的DLL是一个而不是一大堆
- DropDownList的刷新问题
- 如何获得当前记录的自增长字段的值
- DataGrid绑定SQL语句select出来的数据问题
- ASP.NET代码中的汉字怎么变成这样了???
- 求一读取Email的正则表达式?字符串中有中文!在Email地址前总是多出二个字符?
- adsi创建活动目录中的用户、组.
- 请高手指教,为什么我使用VS.NET生成的DATAGRID在设计窗口中能看见数据,但在IE中看不到数据显示,为空白页面!急!!
- 开发用户注册页面的问题!
- 网站速度问题
可以实现建议看一下 System.Drawing命名空间下的内容
using System.Collections;
using System.Configuration;
using System.Data;using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.Data.SqlClient;public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//建立位图对象
Bitmap newBitmap = new Bitmap(680, 680, PixelFormat.Format32bppArgb);
//根据上面创建的位图对象创建绘图面
Graphics g = Graphics.FromImage(newBitmap);
//创建字体对象
Font textFont = new Font("Times New Roman", 14);
Font textFontsmall = new Font("Times New Roman", 12, FontStyle.Bold);
//创建RectangleF结构指定一个区域
RectangleF rectangle = new RectangleF(0, 0, 680, 680);
//使用指定的颜色填充上面RectangleF结构指定的矩形区域
g.FillRectangle(new SolidBrush(Color.White), rectangle);
g.SmoothingMode = SmoothingMode.AntiAlias;
//g.SmoothingMode = SmoothingMode.HighQuality;
//g.setColor(Color.BLUE);
//在上面填充的矩形区域中填充上面生成的随机数
g.DrawEllipse(new Pen(Color.Blue, 2), 40, 40, 600, 600);
g.DrawEllipse(new Pen(Color.Blue, 2), 100, 100, 480, 480);
g.DrawEllipse(new Pen(Color.Blue, 2), 160, 160, 360, 360);
g.DrawEllipse(new Pen(Color.Blue, 2), 220, 220, 240, 240); int d = 6;//同心圆间距
for (int i = 1; i <= 40; i++)
{ g.DrawEllipse(new Pen(Color.Blue), 40 + i * d, 40 + i * d, 600 - 2 * i * d, 600 - 2 * i * d); }
//画出30个同心圆
for (int j = 0; j <= 24; j++)
{
g.DrawPie(new Pen(Color.Blue, 2), 40, 40, 600, 600, 0, 15 * j);
}
//画24个扇形
g.FillEllipse(new SolidBrush(Color.White), 280, 280, 120, 120);
g.DrawEllipse(new Pen(Color.Blue, 2), 280, 280, 120, 120);
string data = "2009-08-06";
RectangleF rectangle2 = new RectangleF(295, 330, 100, 100); g.DrawString(data, textFont, new SolidBrush(Color.Blue), rectangle2);
//中央填充日期
string no0 = "0.0";
string no1 = "1.0";
string no2 = "2.0";
string no3 = "3.0";
string no4 = "4.0";
RectangleF rectangle3 = new RectangleF(270, 338, 50, 50);
g.DrawString(no0, textFontsmall, new SolidBrush(Color.Blue), rectangle3);
RectangleF rectangle5 = new RectangleF(210, 338, 50, 50);
g.DrawString(no1, textFontsmall, new SolidBrush(Color.Blue), rectangle5);
RectangleF rectangle7 = new RectangleF(150, 338, 50, 50);
g.DrawString(no2, textFontsmall, new SolidBrush(Color.Blue), rectangle7);
RectangleF rectangle9 = new RectangleF(90, 338, 50, 50);
g.DrawString(no3, textFontsmall, new SolidBrush(Color.Blue), rectangle9);
RectangleF rectangle11 = new RectangleF(40, 338, 50, 50);
g.DrawString(no4, textFontsmall, new SolidBrush(Color.Blue), rectangle11);
//左侧刻度
RectangleF rectangle4 = new RectangleF(390, 338, 50, 50);
g.DrawString(no0, textFontsmall, new SolidBrush(Color.Blue), rectangle4);
RectangleF rectangle6 = new RectangleF(450, 338, 50, 50);
g.DrawString(no1, textFontsmall, new SolidBrush(Color.Blue), rectangle6);
RectangleF rectangle8 = new RectangleF(510, 338, 50, 50);
g.DrawString(no2, textFontsmall, new SolidBrush(Color.Blue), rectangle8);
RectangleF rectangle10 = new RectangleF(570, 338, 50, 50);
g.DrawString(no3, textFontsmall, new SolidBrush(Color.Blue), rectangle10);
RectangleF rectangle12 = new RectangleF(615, 338, 50, 50);
g.DrawString(no4, textFontsmall, new SolidBrush(Color.Blue), rectangle12);
//右侧刻度
string time5 = "5"; string time6 = "6"; string time7 = "7"; string time8 = "8";
string time9 = "9"; string time10 = "10"; string time11 = "11"; string time12 = "12";
string time13 = "13"; string time14 = "14"; string time15 = "15"; string time16 = "16";
string time17 = "17"; string time18 = "18"; string time19 = "19"; string time20 = "20";
string time21 = "21"; string time22 = "22"; string time23 = "23"; string time24 = "24";
RectangleF rectangleTime24 = new RectangleF(20, 335, 50, 50);
g.DrawString(time24, textFontsmall, new SolidBrush(Color.Blue), rectangleTime24);
RectangleF rectangleTime6 = new RectangleF(335, 20, 50, 50);
g.DrawString(time6, textFontsmall, new SolidBrush(Color.Blue), rectangleTime6);
RectangleF rectangleTime12 = new RectangleF(640, 335, 50, 50);
g.DrawString(time12, textFontsmall, new SolidBrush(Color.Blue), rectangleTime12);
RectangleF rectangleTime18 = new RectangleF(330, 640, 50, 50);
g.DrawString(time18, textFontsmall, new SolidBrush(Color.Blue), rectangleTime18); RectangleF rectangleTime1 = new RectangleF(32, 250, 50, 50);
g.DrawString(time1, textFontsmall, new SolidBrush(Color.Blue), rectangleTime1);
RectangleF rectangleTime2 = new RectangleF(65, 175, 50, 50);
g.DrawString(time2, textFontsmall, new SolidBrush(Color.Blue), rectangleTime2);
RectangleF rectangleTime3 = new RectangleF(115, 110, 50, 50);
g.DrawString(time3, textFontsmall, new SolidBrush(Color.Blue), rectangleTime3);
RectangleF rectangleTime4 = new RectangleF(175, 65, 50, 50);
g.DrawString(time4, textFontsmall, new SolidBrush(Color.Blue), rectangleTime4);
RectangleF rectangleTime5 = new RectangleF(250, 30, 50, 50);
g.DrawString(time5, textFontsmall, new SolidBrush(Color.Blue), rectangleTime5); RectangleF rectangleTime7 = new RectangleF(415, 30, 50, 50);
g.DrawString(time7, textFontsmall, new SolidBrush(Color.Blue), rectangleTime7);
RectangleF rectangleTime8 = new RectangleF(490, 65, 50, 50);
g.DrawString(time8, textFontsmall, new SolidBrush(Color.Blue), rectangleTime8);
RectangleF rectangleTime9 = new RectangleF(555, 110, 50, 50);
g.DrawString(time9, textFontsmall, new SolidBrush(Color.Blue), rectangleTime9);
RectangleF rectangleTime10 = new RectangleF(605, 175, 50, 50);
g.DrawString(time10, textFontsmall, new SolidBrush(Color.Blue), rectangleTime10);
RectangleF rectangleTime11 = new RectangleF(635, 250, 50, 50);
g.DrawString(time11, textFontsmall, new SolidBrush(Color.Blue), rectangleTime11); RectangleF rectangleTime13 = new RectangleF(635, 415, 50, 50);
g.DrawString(time13, textFontsmall, new SolidBrush(Color.Blue), rectangleTime13);
RectangleF rectangleTime14 = new RectangleF(605, 490, 50, 50);
g.DrawString(time14, textFontsmall, new SolidBrush(Color.Blue), rectangleTime14);
RectangleF rectangleTime15 = new RectangleF(555, 555, 50, 50);
g.DrawString(time15, textFontsmall, new SolidBrush(Color.Blue), rectangleTime15);
RectangleF rectangleTime16 = new RectangleF(490, 605, 50, 50);
g.DrawString(time16, textFontsmall, new SolidBrush(Color.Blue), rectangleTime16);
RectangleF rectangleTime17 = new RectangleF(415, 635, 50, 50);
g.DrawString(time17, textFontsmall, new SolidBrush(Color.Blue), rectangleTime17); RectangleF rectangleTime19 = new RectangleF(250, 635, 50, 50);
g.DrawString(time19, textFontsmall, new SolidBrush(Color.Blue), rectangleTime19);
RectangleF rectangleTime20 = new RectangleF(175, 605, 50, 50);
g.DrawString(time20, textFontsmall, new SolidBrush(Color.Blue), rectangleTime20);
RectangleF rectangleTime21 = new RectangleF(115, 555, 50, 50);
g.DrawString(time21, textFontsmall, new SolidBrush(Color.Blue), rectangleTime21);
RectangleF rectangleTime22 = new RectangleF(65, 490, 50, 50);
g.DrawString(time22, textFontsmall, new SolidBrush(Color.Blue), rectangleTime22);
RectangleF rectangleTime23 = new RectangleF(32, 415, 50, 50);
g.DrawString(time23, textFontsmall, new SolidBrush(Color.Blue), rectangleTime23);
DateTime[] datatime = new DateTime[1440];
string[] timeToString = new string[1440];
double[] timee = new double[1440];
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["tttConnectionString"].ConnectionString.ToString());
SqlCommand cmd = new SqlCommand("select timee from testnum3 ORDER BY timee", cn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
for (int it = 0; it < ds.Tables[0].Rows.Count; it++)
{
datatime[it] = Convert.ToDateTime(ds.Tables[0].Rows[it][0]);
}
for (int jt = 0; jt < datatime.Length; jt++)
{
timeToString[jt] = datatime[jt].Hour + "." + datatime[jt].ToString("mm");
} for (int kt = 0; kt < timeToString.Length; kt++)
{
timee[kt] = Convert.ToDouble(timeToString[kt]);
} SqlCommand cmd2 = new SqlCommand("select num from testnum3 ORDER BY timee", cn);
SqlDataAdapter da2 = new SqlDataAdapter(cmd2);
DataSet ds2 = new DataSet();
da2.Fill(ds2);
double[] num = new double[1440];
for (int j = 0; j < timee.Length; j++)
{
num[j] = Convert.ToDouble(ds2.Tables[0].Rows[j][0]); } for (int k = 0; k <= 1438; k++)
{
int x1 = 340 + Convert.ToInt32(Math.Cos((180 + (Math.Floor(timee[k])* 60 + (timee[k] - Math.Floor(timee[k])) * 100) * 0.25) * Math.PI / 180) * (num[k] * 10 * 6 + 60));
int y1 = 340 + Convert.ToInt32(Math.Sin((180 + (Math.Floor(timee[k])* 60 + (timee[k] - Math.Floor(timee[k])) * 100) * 0.25) * Math.PI / 180) * (num[k] * 10 * 6 + 60));
int x2 = 340 + Convert.ToInt32(Math.Cos((180 + (Math.Floor(timee[k + 1])* 60 + (timee[k + 1] - Math.Floor(timee[k + 1])) * 100) * 0.25) * Math.PI / 180) * (num[k + 1] * 10 * 6 + 60));
int y2 = 340 + Convert.ToInt32(Math.Sin((180 + (Math.Floor(timee[k + 1])* 60 + (timee[k + 1] - Math.Floor(timee[k + 1])) * 100) * 0.25) * Math.PI / 180) * (num[k + 1] * 10 * 6 + 60));
g.DrawLine(new Pen(Color.Black), x1, y1, x2, y2);
} // 把创建的位图保存到指定的路径
// g.DrawLine(new Pen(Color.Black), x1, y1, x2, y2);
//g.DrawLine(new Pen(Color.Black), x2, y2, x3, y3);
//g.DrawLine(new Pen(Color.Black), x3, y3, x4, y4);
//g.DrawLine(new Pen(Color.Black), x4, y4, x1, y1);
//// // 方法一
//newBitmap.Save(Server.MapPath("~") + "\\VaImg.Jpeg", ImageFormat.Jpeg);
//
// 方法二
Response.ContentType = "image/jpeg";
newBitmap.Save(Response.OutputStream, ImageFormat.Jpeg); ///释放占用的资源
newBitmap.Dispose(); }
}