【发布时间】:2016-07-22 20:36:54
【问题描述】:
我想在 asp.net 或 winForms 中制作一个显示过去 10 分钟的实时数据图表。
This is the image that i want to make it
我添加了系列,但无法添加数据点。我搜索了很多,但我失败了。
顺便说一句,我使用基础设施。
以下代码生成随机数并在图表中显示该数字。它有效,但只是最后一个数字,i can see it. 没有持续 10 分钟。
private void Form1_Load(object sender, EventArgs e)
{
Timer timer = new Timer();
timer.Interval = (1 * 1000); // 1 secs
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
}
private void timer_Tick(object sender, EventArgs e)
{
Random r = new Random();
int rnd=r.Next(1, 150);
DataTable dt = new DataTable();
dt.Columns.Add("Value", typeof(int));
dt.Columns.Add("Date", typeof(DateTime));
dt.Rows.Add(rnd, DateTime.ParseExact(DateTime.Now.ToLongTimeString(), "HH:mm:ss", null));
NumericTimeSeries series = new NumericTimeSeries();
series.DataBind(dt, "Date", "Value");
NumericTimeDataPoint ndp1 = new NumericTimeDataPoint(DateTime.Now, rnd, "ilk", false);
NumericTimeDataPoint ndp2 = new NumericTimeDataPoint(DateTime.Now, 5.0, "iki", false);
series.Points.Add(ndp1);
series.Points.Add(ndp2);
ultraChart2.Data.SwapRowsAndColumns = true;
ultraChart2.DataSource = dt;
}
【问题讨论】:
标签: c# asp.net .net winforms infragistics