rudi Posted October 16, 2008 Report Share Posted October 16, 2008 Hello, I'm binding to a observablecollection containing a field called Result. The content of Result can be Success, Failed or Running. What I would like to show in a Pie chart is the distribution of this field. Let's say I have 4 items in the observablecollection of which 2 are Success, 1 is Failed and 1 is Running. What I would like to see in my chart is one slice of 50% and two of 25%. What I'm getting at the moment is 4 slices. Is it possible to obtain this via the Chart control or do I need to prepare the data before I bind to the SeriesAttributes? Thanks for all help. Rudi. Quote Link to comment Share on other sites More sharing options...
JuanC Posted October 23, 2008 Report Share Posted October 23, 2008 We have made some changes in our beta3 branch to support this scenario. xmlns:cfxData="clr-namespace:ChartFX.WPF.Data;assembly=ChartFX.WPF.Data"<XmlDataProvider x:Key="myXmlData"> <x:XData> <Elems xmlns=""> <Elem Result="Success" /> <Elem Result="Failed" /> <Elem Result="Running" /> <Elem Result="Success" /> </Elems> </x:XData></XmlDataProvider> <cfx:Chart Gallery="Pie" x:Name="chart1" Grid.Row="2" Margin="10" DataBound="OnDataBound"> <cfx:Chart.ItemsSource> <Binding Source="{StaticResource myXmlData}" XPath="Elems/Elem" /> </cfx:Chart.ItemsSource> <cfx:Chart.DataTransforms> <cfxData:CrosstabTransform RowPath="@Result" Sorted="false"/> </cfx:Chart.DataTransforms></cfx:Chart>You can upgrade your bits to beta3 here Because you will be binding to a collection of CLR objects your RowPath should be the name of the property (enum or string) that represents the result without the @ sign. Please note that we also fixed some issues related to the ObservableCollection change events when using DataTransforms. Regards, JuanC Quote Link to comment Share on other sites More sharing options...
rudi Posted October 24, 2008 Author Report Share Posted October 24, 2008 Thanks a lot for you quick support on this! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.