Jump to content
Software FX Community

distributions in a Pie chart


rudi

Recommended Posts

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.

Link to comment
Share on other sites

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

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...