Domanda

i am working on a signal generator project and i am finding it very difficult to understand how Infragistics XamDataChart works.

The project uses WPF and a MVVM model, where the MainWindow is bound to a ViewModel, which gets all its data from the model class (SigGenChannel.cs in my case), all the signal values and timing and refresh are being done in the model class, and bound all the way back to the MainWindow, where i have a text field displaying the current value (signal value), it is autorefreshing at 100ms.

so the two values i have are the current signal value (CurrentValue) and the current time (CurrentStepTime), how can i use the XamDataChart to map these two datapoints and get it to refresh at the same rate as the text field and display the data on the chart as a signal wave?

Thanks for any help, and please let me know if you need any specific code snippets

È stato utile?

Soluzione

The XamDataChart will automatically refresh the visual for a series if you change the items of the bound collect, provided that the bound collection implements INotifyCollectionChanged. If you wan't to display a "Scrolling Window" effect, you would add new points to the end of the collection, and remove points from the head of the collection, in this way data would appear to scroll from right to left.

Since your X axis is TIME you have two options for how to set up the series. You can either use the CategoryXAxis, which treats times as string values, and each data point is equidistant from the previous (this is appropriate, though, if you have a constant sampling rate), or you can use the CategoryDateTimeXAxis if you have a non constant sampling rate and you want the values to appear at precisely the positions horizontally that would equate to their time value. In either case you would bind the data to the ItemsSource of the axis so that the axis knows how many items there are and can retrieve labels. In the case of the CategoryXAxis you would indicate the labels should come from CurrentStepTime, but for the CategoryDateTimeXAxis you would additionally specify that CurrentStepTime should be used for the DateTimeMemberPath.

The disadvantage of using CategoryDateTimeXAxis is that its less efficient than CategoryXAxis, so unless you need the non-constant time sampling, I'd stick with the latter.

In either case you would be creating a line (or other category) series, binding the data to ItemsSource, and set the ValueMemberPath to CurrentValue.

I assume this sample may elucidate things further: http://www.infragistics.com/products/silverlight/sample/data-chart/#/binding-real-time-data

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top