我现在从数据库中调入了一个表,名称为dt1 其中有时间,客户1,客户2,客户3,....等字段 表形如:
时间 客户1 客户2 客户3 .......
1月 20 20 30
2月 30 20 20
3月 40 40 20
4月 60 30 40
5月 10 40 50
6月 20 10 20
... .... .... ... 我想要在窗体中绘制一个曲线图 ,横坐标和时间字段,纵坐标为量,在这一坐标系中绘制时间与客户1、客户2、客户3的累计量的关系曲线图。(必须是累计量的值)
还望高手能不吝赐教!小弟感激不尽!!!
时间 客户1 客户2 客户3 .......
1月 20 20 30
2月 30 20 20
3月 40 40 20
4月 60 30 40
5月 10 40 50
6月 20 10 20
... .... .... ... 我想要在窗体中绘制一个曲线图 ,横坐标和时间字段,纵坐标为量,在这一坐标系中绘制时间与客户1、客户2、客户3的累计量的关系曲线图。(必须是累计量的值)
还望高手能不吝赐教!小弟感激不尽!!!
解决方案 »
- 如何打开新窗体,不是默认那种~
- DevExpress谁能给我点学习材料,或者教程啊
- 子线程与主线程的交互,请教!`````````````````````````````
- 实现是没办法了, 向大家求且. 关于Assembly.CreateInstance(),一直报找不到构造函数
- 新手请教一个有关Table1 的问题!
- datagrid中加入checkbox取得checkbox的值 屏蔽一些列
- 各位大神,求助!!!
- 求助~!!C#怎么查找到电脑正在登录的QQ号码
- 关于邮件附件问题,请各位高手帮忙
- InstallShield的评估版在哪输入SN?有这方面的书给推一下,电子版好些!马上来结!!
- C#如何用程序来调用系统默认的浏览器
- 有办法减少Process.GetProcesses()函数的CPU占用吗
{
base.OnPaint(e);
Rectangle rect = e.ClipRectangle;
Graphics g = e.Graphics;
float p2m = 1 / g.DpiX * 0.0254f; //米和屏幕像素的单位换算
g.PageUnit=GraphicsUnit.Millimeter;
g.PageScale=1000.0f;
g.TranslateTransform(20*p2m,(rect.Y+rect.Height- 20)*p2m);
g.ScaleTransform((float)(rect.Width*p2m/ExpWay.TotalLength), -rect.Height*p2m/80);
Pen pen1 = new Pen(Color.White, 2*p2m);
Pen pen2 = new Pen(Color.Red, 1*p2m);
PointF pt1 = new PointF(0, 0);
PointF pt2 = new PointF(rect.Width*0.3f*p2m, 0);
g.DrawLine(pen1,pt1,pt2);
Random random=new Random();
float y;
for (float x = (float)ExpWay.StartStation; x < ExpWay.TotalLength-20; x = x + 20)
{
y = (float)random.Next(0, 60);
Console.WriteLine("at{0},v={1}", x, y);
pt2.X = x; pt2.Y = y;
g.DrawLine(pen1, pt1, pt2);
pt1 = pt2;
}
}
//根据传进来的数据 生成各点 以及坐标轴说明
public void CreatPoints(ArrayList timeList,ArrayList valueList,DateTime timeStart,DateTime timeEnd)
{
pointList = new Point[timeList.Count]; int yearStart = timeStart.Year;
int monthStart = timeStart.Month;
int dateStart = timeStart.Day;
timeEnd = timeEnd.AddSeconds(-1);
int yearEnd = timeEnd.Year;
int monthEnd = timeEnd.Month;
int dateEnd = timeEnd.Day; TimeSpan span = timeEnd.Subtract(timeStart);
int secondSpanMax = span.Days * 24 * 3600 + span.Hours * 3600 + span.Minutes * 60 + span.Seconds;//总共相差的秒数
int secondPerG;
if (span.Seconds % (Width - 50) == 0)
{
secondPerG = secondSpanMax / (Width - 50);//一像素代表多少秒
}
else
{
secondPerG = secondSpanMax / (Width - 50) + 1;
} for (int i = 0; i < timeList.Count ; i++)
{
DateTime tempX = (DateTime)timeList[i];
TimeSpan tempSpan = tempX.Subtract(timeStart);
int daysSpan = tempSpan.Days;
int hoursSpan = tempSpan.Hours;
int minutesSpan = tempSpan.Minutes;
int secondsSpan = tempSpan.Seconds;
int tempSecond = daysSpan * 24 * 3600 + hoursSpan * 3600 + minutesSpan * 60 + secondsSpan;
Point tempPoint = new Point();
tempPoint.X = tempSecond/secondPerG + 50;
tempPoint.Y = height - 50 - ((int)((float)valueList[i] * 5));
pointList[i] = tempPoint;
}
}最后 g.DrawLines(new Pen(foreColor,1), pointList);//曲线坐标轴以及说明还需自己画