Jump to content
Software FX Community

ListProvider and multiple series?


CalsepDK
 Share

Recommended Posts

Hi

 I have some trouble grasping the databind examples provided by the PassingData sample application. Everything is working fine when I have just one serie, but I want to be able to show multiple series based on multiple lists of my business objects.

My business objects are structured like this:

Public Class Segment

 Public X as integer

 Public Y as integer

 Public SomethingIrrelevantToPlot as double

 Public SomethingIrrelevantToPlot2 as double

End Class

Public Class Segments

Public Pipeline as List (Of Segment)

End Class

When Segments is assigned to a ListProvider and a FieldMap is setup to X and Y, the graph shows up nicely. My problem is that I want to be able to show multiple Segments in the same chart. I have tried various possibilities (like Pipes as List (Of Segments)), but I am not able to get any data to show. Since each Segments is a graph by itself, I am not worried if they contain different numbers of points. Is this possible using databinding or do I have to fill it in using the API? I am also a bit unclear as to when I have to use the ListProvider and when it is okay to assign a list as the DataSource, but that is a minor concern.

Any help is appreciated.

...Henrik

Link to comment
Share on other sites

There are 2 ways to use databinding and object collections:

1) You have a collection of CLR objects, all of the same class. In this situation, each public property of the class will be seen as a column in the dataset. By default each column will become a series. For example:

 Department[] departments = new Department[5];  departments[0] = new Department("Human Resources", 1500000, 1000000);  departments[1] = new Department("Sales", 1200000, 800000);  departments[2] = new Department("Marketing", 4500000, 5000000);  departments[3] = new Department("Development", 7320000, 5310000);  departments[4] = new Department("Other", 150000, 100000);

 ListProvider lstProvider = new ListProvider(departments);  chart1.DataSourceSettings.DataSource = lstProvider;

Where:

class Department {  private string _name;  private double _budget;  private double _expenses;  public Department(string name, double budget, double expenses)  { _name = name; _budget = budget; _expenses = expenses;  }  public string Name  { get { return _name; } set { _name = value; }  }  public double Budget  { get { return _budget; } set { _budget = value; }  }  public double Expenses  { get { return _expenses; } set { _expenses = value; }  } }

2) You can pass an array of arrays (or list of lists) where each array is an array of simple types (numbers, srtings). Example:

 ICollection[] data = new ICollection[3];  data[0] = new double[] { 10,20,30,40 };  data[1] = new double[] { 60,70,80 };  data[2] = new string[] { "L1","L2","L3","L4" };

 ListProvider lstProvider = new ListProvider(data);  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...