会画折线图的进来瞅瞅啊

nvlixxzhong 2007-11-21 12:39:36

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 Estate_ZheXianTu : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//存月
string[] month = new string[6] { "2007.01", "2007.02", "2007.03", "2007.04", "2007.05", "2007.06" };
float[] d = new float[6] { 7000, 7219, 7500, 11000, 7000, 7650 }; //图中的点的数据

int Max_d2 = MaxNum(d); //点最大值


//画图初始化
System.Drawing.Bitmap bmap = new System.Drawing.Bitmap(325,265);
Graphics gph = Graphics.FromImage(bmap);
gph.Clear(Color.White);
PointF cpt = new PointF(40, 200);//中心点

//画x轴
gph.DrawLine(Pens.Black, cpt.X, cpt.Y, cpt.Y+100, cpt.Y);
gph.DrawString("月份", new Font("宋体", 12), Brushes.Black, new PointF(cpt.Y + 80, cpt.Y + 10));

//画y轴
gph.DrawLine(Pens.Black, cpt.X, cpt.Y, cpt.X, cpt.X);
gph.DrawString("单位(元)", new Font("宋体", 12), Brushes.Black, new PointF(0, 7));

//画y轴刻度
int r = (int)Math.Ceiling(Convert.ToDecimal(Max_d2 / 1000));
for (int i = 1; i <= r + 1; i++)
{
if (i <= 6)
{
gph.DrawString(Convert.ToString((r + 1) * 1000 - (6 - i) * 1000), new Font("宋体", 11), Brushes.Black, new PointF(cpt.X - 40, cpt.Y - (i - 1) * 30 - 5));
gph.DrawLine(Pens.Black, cpt.X - 3, cpt.Y - (i - 1) * 30, cpt.X, cpt.Y - (i - 1) * 30);
}
}

//画x轴项目
for (int j = 1; j <= 6; j++)
{
gph.DrawString(month[j - 1].Substring(5, 2), new Font("宋体", 11), Brushes.Black, new PointF(cpt.X + j * 40 - 5, cpt.Y + 5));

//画点
Pen pen2 = new Pen(Color.Orange, 6);
gph.DrawEllipse(pen2, cpt.X + j * 40 - 1.5f, cpt.Y - d[j - 1], 3, 3);
string price = (d[j - 1]).ToString();
gph.DrawString(price, new Font("宋体", 12), Brushes.Black, new PointF(cpt.X + j * 40 - 1.5f, 0));
}
//输出到浏览器
System.IO.MemoryStream ms = new System.IO.MemoryStream();
bmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
Response.ClearContent();
Response.ContentType = "image/Gif";
Response.BinaryWrite(ms.ToArray());
gph.Dispose();
bmap.Dispose();
}

public int MinNum(float[] str)
{
int min = Int32.Parse(str[0].ToString());
for (int i = 0; i < str.Length; i++)
{
if (min > Int32.Parse(str[i].ToString()))
{
min = Int32.Parse(str[i].ToString());
}
}
return min;
}
public int MaxNum(float[] str)
{
int max = Int32.Parse(str[0].ToString());
for (int i = 0; i < str.Length; i++)
{
if (max < Int32.Parse(str[i].ToString()))
{
max = Int32.Parse(str[i].ToString());
}
}
return max;
}
}


帮我看看这个点的纵坐标,怎么写啊,谢谢了
...全文
57 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangxinjia 2007-11-21
  • 打赏
  • 举报
回复
顶一下,
lishijie910123 2007-11-21
  • 打赏
  • 举报
回复
帮你顶一下

62,266

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧