Page 1 of 1

Series.Add method and DataSource property Questions

Posted: Thu Jan 11, 2007 8:32 pm
by 9346394
I have a couple of questions which both relate to loading data into a series.

First, there is an overload of the series.Add method which takes a List as the parameter passed in (public Void Add(System.Collections.IList)).

How does that version of the Add method work?

That list is expected to be a collection of just single values or of value pairs or something else?

If it is possible to pass in a collection of objects, how do we specify where to find the XValues and the YValues? Is it done the same way the DataSource property is documented where you use the XValues.DataMember property to give the name of the property that holds the X value?

Finally, on this subject, since this an overload of the Add method, I assume that the data found in this List is taken and copied into a new memory location for storage by the series class itself right? It does not treat that list as a data source and just refer back to the List’s memory when it needs to get the data values again.


Second, is there any detailed documentation about using the DataSource property for a series? We are interested in this because we have a DLL that handles interaction with multiple data sources. That code handles caching the data in memory and it would be nice if we could put some sort of interface onto our objects that would allow us to assign it to the DataSource property of a chart series so that there would be no need to have the data exist in our data cache as well as in the series memory space as well.

Does that make sense? What we are looking for is what we would need to implement as an interface to our objects that would allow it to serve as your DataSource for your series classes. I can try to clarify this more if needed.

Thanks again for your time.

Aaron Peronto

Posted: Fri Jan 12, 2007 4:08 pm
by narcis
Hi Aaron,
First, there is an overload of the series.Add method which takes a List as the parameter passed in (public Void Add(System.Collections.IList)).

How does that version of the Add method work?
You can use this override like this:

Code: Select all

			int numPoints = 10;
			System.Collections.ArrayList YVals = new System.Collections.ArrayList();
			Random y = new Random();

			for (int i = 0; i < numPoints; i++)
			{
				YVals.Add((double)y.Next());
			}

			line.Add((System.Collections.IList)YVals);
That list is expected to be a collection of just single values or of value pairs or something else?
It is just a list of single values, X values are added automatically.
If it is possible to pass in a collection of objects, how do we specify where to find the XValues and the YValues? Is it done the same way the DataSource property is documented where you use the XValues.DataMember property to give the name of the property that holds the X value?
If you want to use an object that holds more than one valuetype then the only object you can use is a DataTable with the DataMembers of the ValueLists set to the names of the columns.
Finally, on this subject, since this an overload of the Add method, I assume that the data found in this List is taken and copied into a new memory location for storage by the series class itself right? It does not treat that list as a data source and just refer back to the List’s memory when it needs to get the data values again.
Yes, data is internally added to series's ValueLists.

Second, is there any detailed documentation about using the DataSource property for a series? We are interested in this because we have a DLL that handles interaction with multiple data sources. That code handles caching the data in memory and it would be nice if we could put some sort of interface onto our objects that would allow us to assign it to the DataSource property of a chart series so that there would be no need to have the data exist in our data cache as well as in the series memory space as well.

Does that make sense? What we are looking for is what we would need to implement as an interface to our objects that would allow it to serve as your DataSource for your series classes. I can try to clarify this more if needed.
Yes, you can achieve what you request as I told you above. You can find an example of DataMember usage here. Regarding DataSource documentation, you can have a look at Tutorial 6 - Working with Series, Tutorial 7 - Working with Functions and Tutorial8 - ADO.NET Database Access.