09-27-2005 10:06 AM
scatterGraph1.DataBindings.Add(...)
I have tried this with a few different combinations but haven't been able to get it to work. I am specifically trying to bind to a custom collection. Any sample code which binds a graph to anything would be usefull though.
Thanks.
09-27-2005 11:10 AM
Could you please provide a little more information about what you're trying to do? What are you trying to bind on ScatterGraph? Which properties are you trying to bind? What is the type of the property on the object in the custom collection that you're trying to bind? What are the different combinations that you tried? Could you please post a small test project that demonstrates what you're trying to do? Thanks.
- Elton
09-28-2005 03:34 AM
ChannelDataCollection : System.Collections.CollectionBase, IBindingList
I bind a listbox on my screen to this ChannelDataCollection object through the following code:
lbDeviceReading.DisplayMember = "Data";
lbDeviceReading.ValueMember = "ChannelDataID";
lbDeviceReading.DataSource = m_currentlyDisplayedChannelReadings; //m_currentlyDisplayedChannelReadings is a ChannelDataCollection object.
I would like to also bind m_currentlyDisplayedChannelReadings to a scatterGraph.
So far i have tried scatterGraph1.DataBindings.Add("YAxis", m_currentlyDisplayedChannelReadings, "Data") and a few variants.
Any ideas???
Thanks.
09-28-2005 11:58 AM
WaveformGraph supports data binding to plot data, but ScatterGraph does not. The reason for this is due to the nature of how each graph accepts data. Ultimately, both graphs plot pairs of x/y data. WaveformGraph specifies one dimension as a start and increment and the other dimension as an array of data. WaveformGraph uses the start and increment to generate an array that corresponds to the array that was specified explicitly. The start and increment can be specified via the DefaultStart and DefaultIncrements on WaveformPlot or via start and increment parameters to the Plot* methods. ScatterGraph always accepts both dimensions of data explicitly via parameters to its Plot* methods.
WaveformGraph supports data binding via its BindingData, BindingDataOrientation, BindingIncrement, BindingMethod, and BindingStart properties. You'll notice that these properties map to parameters to the Plot* methods. All properties except BindingData can be specified at design-time, then BindingData is data-bound and gets its value from the data source at run-time. The problem with ScatterGraph and data binding is that both dimensions of data are specified explicitly, and they must be specified simultaneously. This would mean that it would have to expose a property for data binding where the data is in a specific format (i.e., 2 row or 2 column 2D array, or a 2 element jagged array). This would force developers to maintain their data in an unnatural format for the purposes of data binding, which cancels out the benefit that you get from data binding. This is also an unnatural format for publishing data via DataSocket, which the graphs are frequently bound to via DataSocketSource.
In your example, you could data bind the WaveformGraph with this code:
waveformGraph1.DataBindings.Add("BindingData", m_currentDisplayedChannelReadings, "Data");
- Elton
09-29-2005 03:00 AM