Jump to content
Software FX Community

ListProvider and multiple series?


CalsepDK

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...