我创建了一个web网站(语言选的是C#),我在网页中画一个折线图,但是折线图在网页中没有显示,请问我该怎么解决,谢谢!!!
我的网页代码如下:
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.Drawing2D;
using System.Data.SqlClient;public partial class Admin_jjz_graphics : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.CreateImage();
} private void CreateImage()
{
int height = 440, width = 600;
Bitmap image = new Bitmap(width, height);
Graphics g = Graphics.FromImage(image); try
{
//清空图片背景色
g.Clear(Color.White); Font font = new System.Drawing.Font("Arial", 9, FontStyle.Regular);
Font font1 = new System.Drawing.Font("宋体", 20, FontStyle.Regular);
Font font2 = new System.Drawing.Font("Arial", 8, FontStyle.Regular);
LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Blue, Color.Blue, 1.2f, true);
g.FillRectangle(Brushes.AliceBlue, 0, 0, width, height);
Brush brush1 = new SolidBrush(Color.Blue);
Brush brush2 = new SolidBrush(Color.SaddleBrown); g.DrawString("1997年-2006年出生人口的男女比例", font1, brush1, new PointF(100, 30));
//画图片的边框线
g.DrawRectangle(new Pen(Color.Blue), 0, 0, image.Width - 1, image.Height - 1); Pen mypen = new Pen(brush, 1);
Pen mypen2 = new Pen(Color.Red, 2);
//绘制线条
//绘制纵向线条
int x = 60;
for (int i = 0; i < 10; i++)
{
g.DrawLine(mypen, x, 80, x, 340);
x = x + 50;
}
Pen mypen1 = new Pen(Color.Blue, 2);
g.DrawLine(mypen1, x - 500, 80, x - 500, 340); //绘制横向线条
int y = 106;
for (int i = 0; i < 9; i++)
{
g.DrawLine(mypen, 60, y, 560, y);
y = y + 26;
}
g.DrawLine(mypen1, 60, y, 560, y);
}
finally
{
g.Dispose();
image.Dispose();
}
}
}
我的网页代码如下:
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.Drawing2D;
using System.Data.SqlClient;public partial class Admin_jjz_graphics : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.CreateImage();
} private void CreateImage()
{
int height = 440, width = 600;
Bitmap image = new Bitmap(width, height);
Graphics g = Graphics.FromImage(image); try
{
//清空图片背景色
g.Clear(Color.White); Font font = new System.Drawing.Font("Arial", 9, FontStyle.Regular);
Font font1 = new System.Drawing.Font("宋体", 20, FontStyle.Regular);
Font font2 = new System.Drawing.Font("Arial", 8, FontStyle.Regular);
LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Blue, Color.Blue, 1.2f, true);
g.FillRectangle(Brushes.AliceBlue, 0, 0, width, height);
Brush brush1 = new SolidBrush(Color.Blue);
Brush brush2 = new SolidBrush(Color.SaddleBrown); g.DrawString("1997年-2006年出生人口的男女比例", font1, brush1, new PointF(100, 30));
//画图片的边框线
g.DrawRectangle(new Pen(Color.Blue), 0, 0, image.Width - 1, image.Height - 1); Pen mypen = new Pen(brush, 1);
Pen mypen2 = new Pen(Color.Red, 2);
//绘制线条
//绘制纵向线条
int x = 60;
for (int i = 0; i < 10; i++)
{
g.DrawLine(mypen, x, 80, x, 340);
x = x + 50;
}
Pen mypen1 = new Pen(Color.Blue, 2);
g.DrawLine(mypen1, x - 500, 80, x - 500, 340); //绘制横向线条
int y = 106;
for (int i = 0; i < 9; i++)
{
g.DrawLine(mypen, 60, y, 560, y);
y = y + 26;
}
g.DrawLine(mypen1, 60, y, 560, y);
}
finally
{
g.Dispose();
image.Dispose();
}
}
}
解决方案 »
- if (Request.QueryString["editnews"] != null)
- 请写一个验证表达式
- 关于sql的小小问题
- 网址判断正则表达式
- 奇怪问题:为什么动态添加的用户控件,在回发之后,里面的textbox还会显示原来的值,但label控件在回发之后,它的text的值就消失了,我试了很多
- 【求助】ppt转html或mht
- 当鼠标移动到日历的某天时浮现出那天的行程记录
- gridview嵌套gridview中,嵌套gridview的隐藏和展开问题
- 如何得到数据库的末条记录??
- Response.Write到底能不能在类库中使用???
- LINQ to XML 中 怎么样按照含某属性值子元素的个数来排序?
- ObjectDataSource控件问题
http://www.51aspx.com/CV/WebChart/