Jump to content
Software FX Community

Binding collection of point collection


RajeshDhiman

Recommended Posts

Hi,

I am working with WPF ChartFx Beta (v.0.8.3015.33879)

I want to achieve the following:

We can bind a series of WPF chart to an Observeable point collection (working fine).

Now I have a Observeable collection of Observeable point collections.

Please tell me that how to bind the chart to outer Observeable collection, so that chart itself could create number of series according to the number of Observeable point collections inside outer collection.

Thanks

Rajesh Dhiman.

 

Link to comment
Share on other sites

We support both a collection of ObservableCollections as well as a collection of CLR objects that in turn contain a Collection property. In these scenarions the number of series will be dictated by the number of objects in the outer collection. Please note that we will not observe changes in the outer collection in the current builds.

To use this you need to add a reference to ChartFX.WPF.Data and your XAML would look like this

Scenario 1) Collection of CLR objects that expose a collection property

class OuterObject {

List<InnerObject> Sales {get;}

}

class InnerObject {

  double Price {get;}

}

<cfx:Chart.DataTransforms>

  <cfxData:ListTransform ColumnPath="Sales" ValuePath="Price" />

</cfx:Chart.DataTransforms>

Please note that in this scenario each series will have a different number of points, you can additionally use the XValuePath to point to a numerical or datetime property. If the OuterObject exposes a string property that identifies each series you can use the SeriesPath to point to this property.

Scenario 2) Collection of Collections

In this case there is only one class (InnerObject) and you are providing a collection where each item is in turn a collection of InnerObjects.

<cfx:Chart.DataTransforms>

  <cfxData:ListTransform ValuePath="Price" />

</cfx:Chart.DataTransforms>

Scenario 3) Inner CLR objects contains a string field that should be used to "match" objects in different collections

class InnerObject {

double Price {get;}

string Product {get;}

}

In this case we will match InnerObjects in different collections by Product Names, i.e. you will get a chart with as many series as items in the outer collection and as many points as the combined products found in all collections.

Important: we assume in this case that the inner collections are ordered by Product.

 <cfx:Chart.DataTransforms>

  <cfxData:ListTransform RowPath="Product" ColumnPath="Sales" ValuePath="Price" />

</cfx:Chart.DataTransforms>

Hope this helps.

JuanC

Link to comment
Share on other sites

Hi,

Thanks for quick reply.

I tried with your sugession but I am not able to get <cfxData:ListTransform >  my code. I am using ChartFX WPF (V.0.8.3015.33879). I have added two assemblies 1. ChartFX.WPF.dll 2. ChartFX.WPF.Data.dll in my project. May be my Assemblies are not latest.

My Actual requirement is I want to Bind Collection of Observable Point Collection to the chart. If i have 10 Observable Point Collection and each point collection have 100 points. Now my requirement is Chart Should be able to create 10 series or n-series as per observable collection count(Main Collection) and each series assign with 100 or n-points (Sub Collection) which is given. e.g.

public ObservableCollection<Point> getObservableCollection()

{

Random rnd = new Random(1000);

ObservableCollection<Point> obc = new ObservableCollection<Point>();for (int i=0;i<100;i++)

obc.Add(

new Point(i,i));return obc;

}

public ObservableCollection<ObservableCollection<Point>> getCollectionOfCollection()

{

ObservableCollection<ObservableCollection<Point>> obc = new ObservableCollection<ObservableCollection<Point>>();for (int i = 0; i < 10; i++)

obc.Add(getObservableCollection());

return obc;

}

ObservableCollection<ObservableCollection<Point>> obcChart = new ObservableCollection<ObservableCollection<Point>>();

obcChart =  getCollectionOfCollection();

 Now i want to bind obcChart (Collection of Point Collection) to Chart. So as per this example Chart should be able to created 10 series and each series having 100 point.  The number of series and number of point collection may vary as per the input.

If chart supports binding with other collection not with observable collection then it is ok for me.

Please Guide me how can i Bind this Collection of PointCollection with Chart. Please give me brief knowledge on the same.

 

Regards,

Rajesh Dhiman

 

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.

×
×
  • Create New...