Reputation: 491
I am trying to generate a splined chart which will have multiple series each with a number of points. I have done something in Excel which looks like this
Except I will have more like seven ellipses within each other.
I have selected the WPF Toolkit to use as it is free, and I have generated all of the points, I have put them in the following structure.
List<List<KeyValuePair<double, double>>>
Where the outer list is the list of series and the inner list is the list of points in that series.
I do not see a item source to bind to to generate the list of series, how would I go about binding to this?
Edit
I have backed off on what I want to do, I had wanted to have a dynamic binding to a list of lists where the user can define any gradient curves they would like, each one with a collection of points.
Now what I have done is made a specific set of curves (about 7) and filled them with all the points, letting the user choose from that defined list.
Here is the XAML I wrote for this,
<chartingToolkit:Chart Title="Compressor Map">
<chartingToolkit:LineSeries DependentValuePath="Value"
IndependentValuePath="Key"
ItemsSource="{Binding Path=Points[0]}"
IsSelectionEnabled="True" />
<chartingToolkit:LineSeries DependentValuePath="Value"
IndependentValuePath="Key"
ItemsSource="{Binding Path=Points[1]}"
IsSelectionEnabled="True" />
</chartingToolkit:Chart>
Where I am planning on toggling visibility based on a set of choices. This however does not work, it gives the following error,
System.Windows.Data Error: 17 : Cannot get 'Item[]' value (type 'List
1') from 'Points' (type 'List1'). BindingExpression:Path=Points[0]; DataItem='ChartViewModel' (HashCode=4925117); target element is 'LineSeries' (Name=''); target property is 'ItemsSource' (type 'IEnumerable') ArgumentOutOfRangeException:'System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index'
I would rather not have to make seven different properties, one for each level set. First I feel like that is brute force, also I have an inner loop that fills the points for each level and writing the entire loop out would be horrific.
Thank you for the help.
Upvotes: 3
Views: 715
Reputation: 3312
You have a few options for achieving your desired results. I inherited from Chart and created a MultiChart by adding a couple of Dependency Properties. One for my source of items and one for the template to use. In the property changed callback for the source, you foreach through the SeriesSource adding an instance of the template for each subcollection of points.
Here is a link to a SilverLight version that is using an Attached Property to achieve this. It should be fairly straightforward to convert this to WPF if it even needs any changes at all.
Upvotes: 1