tags:

views:

12

answers:

1

Hi, I'm writing some code that will synchronize data in database with chart (it's zedgraph in fact - but it doesn't matter). I want to do something like this:

  • chart draws data from databse
  • whenever new data is added to DB, 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 DB it gets drawn on the chart and recalculates the moving average without any action listeners?

A: 

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.

Winston Smith