将 Infragistics UltraChart(线图)绑定到 DataView
我试图通过其 NumericTimeSeriesDataAppearance 实例将 DataView 绑定到 NumericTimeSeries,但该系列最终有零点。我正在使用以下代码进行测试:
DataTable table = new DataTable();
table.Columns.Add("date", typeof(DateTime));
table.Columns.Add("value", typeof(double));
DataView view = new DataView(table);
view.AllowDelete = true;
view.AllowNew = true;
view.AllowEdit = true;
NumericTimeSeries series = new NumericTimeSeries();
series.Data.TimeValueColumn = "date";
series.Data.ValueColumn = "value";
series.Data.DataSource = view;
series.DataBind();
// Update series when data is changed
view.ListChanged += (sender, args) => series.DataBind();
table.RowChanged += (sender, args) => series.DataBind();
table.TableNewRow += (sender, args) => series.DataBind();
table.RowDeleted += (sender, args) => series.DataBind();
table.Rows.Add(DateTime.Now, 42.0);
System.Console.WriteLine("Number of datapoints in view is {0}", view.Count);
System.Console.WriteLine("Number of datapoints in series is {0}", series.Points.Count);
这会为视图输出 1 个数据点,但为系列输出 0 个数据点。直接绑定到 DataTable 效果很好,但不足以解决我的问题(我正在使用 DataView 按日期对 DataTable 进行排序)。
I'm trying to bind a DataView to NumericTimeSeries through its NumericTimeSeriesDataAppearance instance, but the series end up having zero points. I'm testing using the following code:
DataTable table = new DataTable();
table.Columns.Add("date", typeof(DateTime));
table.Columns.Add("value", typeof(double));
DataView view = new DataView(table);
view.AllowDelete = true;
view.AllowNew = true;
view.AllowEdit = true;
NumericTimeSeries series = new NumericTimeSeries();
series.Data.TimeValueColumn = "date";
series.Data.ValueColumn = "value";
series.Data.DataSource = view;
series.DataBind();
// Update series when data is changed
view.ListChanged += (sender, args) => series.DataBind();
table.RowChanged += (sender, args) => series.DataBind();
table.TableNewRow += (sender, args) => series.DataBind();
table.RowDeleted += (sender, args) => series.DataBind();
table.Rows.Add(DateTime.Now, 42.0);
System.Console.WriteLine("Number of datapoints in view is {0}", view.Count);
System.Console.WriteLine("Number of datapoints in series is {0}", series.Points.Count);
This outputs 1 datapoint for the view, but 0 for the series. Binding directly to the DataTable works fine, but isn't sufficient for my problem (I'm using a DataView to sort a DataTable on date).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最终使用事件触发器 DataTable.RowChanged、TableNewRow 和 RowDeleted 更新 NumericTimeSeries:
I ended up using a trigger for events DataTable.RowChanged, TableNewRow and RowDeleted updating the NumericTimeSeries: