首页 新闻 会员 周边 捐助

问个GDI+的问题

0
悬赏园豆:5 [已关闭问题] 关闭于 2012-11-06 17:36

     实际的过程当中已经控制图片大小为1100*400

Model:

    public partial class ST_Histogram
    {
        /// <summary>
        /// 时间
        /// </summary>
        public DateTime X { get; set; }

        /// <summary>
        /// 降雨量
        /// </summary>
        public float Y { get; set; }
    }

list:

List<ST_Histogram> list =
               proc_Histogram.Day_ObjectList(dtStart, dtStart.AddDays(1), strSTCD);

 

 //获取数据量,X轴上的数据量,从数据库获取数据已经控制为24条数据
int count = list.Count();

Random rand = new Random(Guid.NewGuid().GetHashCode());
Pen pen;
float xDistance = 1000 / count;

 for (int i = 0; i < count; i++)
{
     //画刻度线
     g.DrawLine(blackPen, 50f + xDistance * i, 350f, 50f + xDistance * i, 355f);
     //画虚线
     if (i != 0)
     g.DrawLine(sliverPen, 50f + xDistance * i, 350f, 50f + xDistance * i, 100f);
     //画标签
     g.DrawString(list[i].X.Hour.ToString() + "", normalFont, blackBrush, 40f + xDistance * i, 357f);
    //画柱状图
     pen = new Pen(Color.FromArgb(rand.Next(255), rand.Next(255), rand.Next(255)), xDistance);
    if (list[i].Y != 0)
    {
       float x1 = 50f + ((TimeSpan)(list[i].X - list[0].X)).Hours * xDistance + xDistance / 2;
       float y1 = 350f;
       float x2 = x1;
       float y2 = y1 - list[i].Y * yDistance;
       g.DrawLine(pen, x1, y1, x2, y2);
     }
 }
问题补充:

凡一二三的主页 凡一二三 | 初学一级 | 园豆:85
提问于:2012-11-06 16:09
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册