Jump to content
Software FX Community

Binding multi-dimensional arrays?


mhowes
 Share

Recommended Posts

 I have two two dimensional arrays. One array is all the X values for each element and the other array is all the Ys. They are arrays of doubles

 Does anyone have a pointer on how I should munge this data so it can be bound to the chart.

 I guess the first question is, using the ListProvider or some other means, can I bind multi-dimensional arrays to the chart?

 I assume I'd have to create individual multiple dimensional arrays for each element that contain all the X and Y for that element instead of having the X and Ys in separate arrays?

thanks

mike

 

 

 

 

 

Link to comment
Share on other sites

 I would be fairly easy to bust the individual arrays out.

In other words instead of having something like

X-Values

A 1, 4, 5, 7B  1,  2, 3 4

 in one multi-dimensional array 

and

Y-ValuesA .1 .2 .3 .4B .11 .22 .33. .44

 I can have an array with all the A x values and an array with all A's y values  

 What I need to do is dynamically add/remove new Series, one for A and then B (and of course many more).

 Is that possible? and then bind A's arrays to a series and B's array to a Series

looping through every point will take way, way to long

 In other words, if I could bind each elements X and Y value arrays at a time?

 any ideas?

thanks

mike

 

 

 

Link to comment
Share on other sites

 A different way to put this question is

 If I have an array of X Values and a matching array of Y Values do I have to loop through each of a half a million points and add each point to the chart?

 And what I really have is up to 96 array pairs of X and Y values (192 arrays)

 I just need up to 96 line charts 

 Soon that number is going to multiply by 4. Each array having lots of points

thanks

mike 

Link to comment
Share on other sites

In this case you can use the list provider and pass all the arrays, then use the Fields collection (DataSourceSettings) to indicate how you want each of these arrays to be used.

For example if you want to end up with 4 series you will be passing 8 arrays in total to the ListProvider (and array of 8 arrays to be precise), then you will use the fields collection to indicate which is X and which is Y. For instance, lets say you pass them interlaced Array of X, Array of Y, Array of X, Array of Y, and so on, then you will indicate the following in the Fields collection prior to Data Binding.

ICollection[] data = new ICollection[4];

data[0] =

new double[] { 10,20,30,40 };data[1] = new double[] { 60,70,80,100 };

data[2] =

new double[] { 10,20,30,40 };data[3] = new double[] { 60,70,80,100 };

//data[2] = new string[] { "L1","L2","L3","L4" };ListProvider lstProvider = new ListProvider(data);

chart1.DataSourceSettings.Fields.Clear();

chart1.DataSourceSettings.Fields.Add(
new FieldMap("Field1",FieldUsage.XValue));

chart1.DataSourceSettings.Fields.Add(

new FieldMap("Field2",FieldUsage.Value));chart1.DataSourceSettings.Fields.Add(new FieldMap("Field3",FieldUsage.XValue));

chart1.DataSourceSettings.Fields.Add(

new FieldMap("Field4",FieldUsage.Value));

chart1.DataSourceSettings.DataSource = lstProvider;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...