This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
WPF has support for dynamic objects in .Net 4.0. Does the Mindscape Chart have support for binding to Dynamic Objects like the ExpandoObject? |
|
|
Hello Thanks for contacting us about this. In the next nightly build of WPF Elements 7.0, the Chart control will support binding to ExpandoObject. This can be used in the usual way of setting the XBinding and YBinding properties of each series to point to the appropriate property. -Jason Fauchelle |
|
|
Hello Jason! I know this was an old post, but I am having trouble implementing ExpandoObjects as a ItemsSource. When I set the ExpandoObject to the series ItemsSource I get an error "Cannot implicitly convert type 'System.Dynamic.ExpandoObject' to 'System.Collections.IList". When I look at the dynamic view of the expando object, I can see the properties and they are of type ObservableCollection. I can also expand these properties and see the values in each property. Thanks for your help! Ed |
|
|
Hello Ed The way this is currently supported is that you can provide a collection of ExpandoObjects, each one which represents a single data point and can provide an X and Y value. - I didn't realize you would want to set the whole ItemsSource as a single ExpandoObject. We wouldn't be able to support this unless we change the ItemsSource property to be an object type property. Is it possible you could bind the ItemsSource of the chart-series to the ObservableCollection within the ExpandoObject? Or maybe you could create a custom collection implementation that takes the ExpandoObject instance and provides the data points? If you need further help with this scenario, please send me a simple repro project demonstrating what you have so far and I'll recommend an approach you could take. -Jason Fauchelle |
|
|
I was taking this approach as we don't know which things a user will want to graph until the do it at runtime and I was trying to build an 'object' that had a number of ObservableCollection properties so I can bind to their x and y axis. By the way, How is the performance of this method compared with the highest performance usage? |
|
|
I'm not sure I fully understand the scenario, but to clarify, are you storing the X and Y values in separate collections (One collection for each thing that the user may want to plot) within your ExpandoObject, and then plan to switch between which collection is used to provide the X and Y data? The chart series expects to have a single collection of objects where each object provides both the X and Y value. So to get this to work, you may want to implement a custom collection that has a reference to the ExpandoObject, and then when items are requested from this custom collection, you can build the individual data point objects which will get the X and Y value from the appropriate collection. This may affect the performance of loading/changing what data is displayed, but then once the data is loaded/changed the performance of the chart will be the same as normal usage. When creating the individual data points, the best performance can be obtained by creating objects that the Chart control already knows about such as Point and StringDouble objects. This is fast because the chart knows how to get the X/Y data from it. If this is not an option, you'd need to use your own data point implementation (just a class that has properties to provide the X and Y values). Then set the XBinding and YBinding properties of the series to point to the appropriate properties on your objects. Using bindings can be slow though, so if you do need to use XBinding and YBinding and find that the performance is not very good, you can create a class that implements the IChartDataExtractor interface. In the GetX and GetY methods, you can cast the given object to your custom object type (or whatever data point object you are using), and then simply access the appropriate properties to return the X and Y values. This is much faster than using bindings. Then set the DataExtractor property of the chart series to be an instance of your custom IChartDataExtractor. Hope that helps. -Jason Fauchelle |
|
|
So if I go the IChartDataExtractor route, I just need a collection of my datapoint objects and set this to my series ItemsSource property? |
|
|
Yes, as long as the ItemsSource is set to be a collection of data objects that provide both X and Y values. Note that IChartDataExtractor is only necessary if you aren't plotting one of the built-in data point types such as Point or StringDouble. (e.g. if you are plotting your own data point objects, IChartDataExtractor is a high preformance replacement for using XBinding and YBinding). -Jason Fauchelle |
|
|
I implemented the IChartDataExtractor and the performance is phenomenal! But for some reason, autoscale on the x-axis is no longer working. Is this expected behavior? |
|
|
Good to hear the performance has greatly improved. There are no known issues with the IChartDataExtractor breaking the autoscale of the x-axis. Could you please send some code to help me reproduce this issue. In particular, it may be related to the type of data you are plotting on the X axis. |
|
|
This is similar to a previous issue, where when X-Axis values are less than 1 auto scaling won't work. http://www.mindscapehq.com/forums/thread/2179326 As soon as the X axis values a greater than 1, the auto scaling kicks in. |
|
|
Hi Ed Thanks for this extra info, but It still seems to be working fine at my end. Unfortunately I'll need some code examples to look into this further for you. -Jason Fauchelle |
|
|
Could you please provide me an email address, as I have a significant amount of production code that I can't reveal to the public. |
|
|
Certainly, you can send directly to me: jason@mindscape.co.nz |
|
|
Updating to the latest nightly build solved the issue. Thanks for all your help Jason! |
|