Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

how to databind scattergraph to c# datasource

Hi,
 
i notice there is the option to do...

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.

0 Kudos
Message 1 of 5
(4,407 Views)

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

0 Kudos
Message 2 of 5
(4,402 Views)
Thanks for the reply Elton.
 
I am trying to plot Data against Logtime on a scattergraph using a collection which is continually being added to.
 
I have a ChannelData business object, with properties Data and Logtime. I also have a ChannelDataCollection object, which implements System.Collections.CollectionBase and IBindingList through the following declaration:

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.

 

 

 

 

 

 

0 Kudos
Message 3 of 5
(4,397 Views)

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

0 Kudos
Message 4 of 5
(4,382 Views)
Okay it's not quite what i'm looking for then. Thanks.
0 Kudos
Message 5 of 5
(4,376 Views)