将表适配器查询绑定到图表
我正在编写一些代码,将数据库中的数据与图表同步(它是 ZedGraph,事实上 - 但这并不重要)。 我想做这样的事情:
- 图表都会从数据库中绘制数据
- 每当新数据添加到数据库时,
,它会立即绘制在图表上到目前为止,一切正常,因为我可以将图表线数据源绑定到数据表。但我还想在图表上绘制值的移动平均值。 因此,我使用 Table Adapter 编写了一个计算移动平均值并返回结果的查询。然后,我创建了一个新的图表线并将其绑定到查询结果:
it = new DatabaseDataSetTableAdapters.IntradayAdapter();
line.DataSource = it.GetSMABy(name);
是否有可能,每当将新数据添加到数据库时,它就会绘制在图表上并重新计算移动平均值,而无需任何操作侦听器?
I'm writing some code that will synchronize data in a database with a chart (it's ZedGraph, in fact - but it doesn't matter).
I want to do something like this:
- chart draws data from the databse
- whenever new data is added to database, it's immediately drawn on the chart
So far everything works OK, because I can bind chart line DataSource to a data table. But I also want to draw a moving average of the values on the chart.
So I used Table Adapter to write a query that calculates the moving average and returns the result. Then I created a new chart line and bind it to the result of a query:
it = new DatabaseDataSetTableAdapters.IntradayAdapter();
line.DataSource = it.GetSMABy(name);
Is it possible, that whenever new data is added to the database, it gets drawn on the chart and recalculates the moving average without any action listeners?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 SQL Server 通知服务 将更新推送到您的客户端,此时它可以更新图表。
虽然它已经有一段时间没有更新了,但您可能想查看一下 WPF 动态数据显示。它是一个图表库,具有一些出色的功能,并包含许多有用的示例,其中一些示例会实时更新图表。
You could use SQL Server Notification Services to push updates to your client, at which point it could update the graph.
Although it hasn't been updated in a while, you may want to check out WPF Dynamic Data Display. It's a charting library with some great features, and includes lots of useful samples, some of which update the charts in real time.