We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to control interior color of a PieChart

Thread ID:

Created:

Updated:

Platform:

Replies:

117423 Oct 17,2014 07:28 AM Nov 15,2014 12:03 AM WPF 5
loading
Tags: SfChart
Rodolphe Billottet
Asked On October 17, 2014 07:28 AM

Hi
 
I'm using a basci PieChart like below.
 
I need to syncronize the Pie chart with another UI control to display related information.
I want to use the same color in both control.
 
How can I control the Pie Area color  ?  Is there any getter / setter or colorConverter  ??
 
Regards,
Rodolphe
 
                <chart:SfChart x:Name="AppsChart"  AreaBorderThickness="0" >                                   
                    <chart:SfChart.Legend>
                        <chart:ChartLegend DockPosition="Right" CheckBoxVisibility="Visible"/>                            
                    </chart:SfChart.Legend>
                    <chart:SfChart.PrimaryAxis>                         <chart:CategoryAxis/>                     </chart:SfChart.PrimaryAxis>                     <chart:SfChart.SecondaryAxis>                         <chart:NumericalAxis/>                     </chart:SfChart.SecondaryAxis>                     <chart:PieSeries ConnectorType="Line" EnableSmartLabels="true"                       LabelPosition="OutsideExtended" EnableAnimation="True"                   x:Name="pieSeries" ShowTooltip="True"                       chart:ChartTooltip.EnableAnimation="True"                   ItemsSource="{Binding ViewModel.PieList}"                       XBindingPath="Name" YBindingPath="Count"                    Margin="0">                     </chart:PieSeries>                 </chart:SfChart>

Mohammed Azarudeen [Syncfusion]
Replied On October 20, 2014 01:43 AM

Hi Rodolphe,

We have analyzed your requirement and you can manually set Pie segments color by using the property palette as custom for the PieSeries as shown in the below code snippet.

Code Snippet [XAML]:

<chart:PieSeries Palette="Custom" XBindingPath="Country" YBindingPath="Count" ItemsSource="{Binding Data}">

                <chart:PieSeries.ColorModel>

                    <chart:ChartColorModel>

                        <chart:ChartColorModel.CustomBrushes>

                            <SolidColorBrush Color="BlanchedAlmond"></SolidColorBrush>

                            <SolidColorBrush Color="CadetBlue"></SolidColorBrush>

                            <SolidColorBrush Color="Crimson"></SolidColorBrush>

                            <SolidColorBrush Color="Red"></SolidColorBrush>

                            <SolidColorBrush Color="DarkGray"></SolidColorBrush>

                        </chart:ChartColorModel.CustomBrushes>

                    </chart:ChartColorModel>

                </chart:PieSeries.ColorModel>

            </chart:PieSeries>

We have prepared a sample based on this and please find the attached sample.

Please let us know if you have any queries.

Thanks,

Mohammed Azarudeen.


Attachment: PiSeries_Color_6a5e7181.zip

Rodolphe Billottet
Replied On October 26, 2014 09:12 PM

Hi Mohammed,
 
Thanks for your reply and sample.
Is there a way to bind the colorModel to the ViewMode ?
I don't know in advance how many items will be displayed so better to control that in the ViewModel.
 
Regards,
Rodolphe

Mohammed Azarudeen [Syncfusion]
Replied On October 27, 2014 08:41 AM

Hi Rodolphe,

 

We have analyzed your requirement and you can able to bind view model property(with the brushes added to it) to the ColorModel property of the PieSeries as shown in the below code snippet.

 

Code Snippet [XAML]:

 

            <chart:PieSeries  ConnectorType="Line" ColorModel="{Binding CustomBrushes, Converter={StaticResource converter}}" Palette="Custom" XBindingPath="Country" YBindingPath="Count" ItemsSource="{Binding Data}" EnableSmartLabels="true"

                     LabelPosition="OutsideExtended" EnableAnimation="True" ShowTooltip="True” chart:ChartTooltip.EnableAnimation="True">

 

We have prepared a sample based on this and please find the attached sample.

 

Please let us know if you have any queries.

 

Thanks,

Mohammed Azarudeen.


Attachment: ColorModelBinding_fad4e097.zip

Rodolphe Billottet
Replied On November 12, 2014 05:09 AM

Hi Mohammed,
 
Thanks for your reply and sample but I'm sorry, this is not a proper Binding. I'm pretty sure you are aware of it.
In your sample you are using an instance different that one which really bind to the view.
 
Other point is that this is a bit tricky to bind something on a Converter.
And anyway you converter return a static ColorModel  so the result is exactly the same as your first solution : having the ColorModel define in the xaml.
 
That's not what I need, because my items are dynamics and the order can change.
With a static ColorModel , if the an item get his rank changed, I will also change color, which is bad..
 
Would mush more smarter to have a direct Binding on the ItemsSource like that :
XBindingPath="Country" YBindingPath="Count" PieColorBindingPath="AnyBrushProperty"
 
Or a Convert  wich convert  XBinding => Color   (but again Converter does not work with dynamic data)
 

Magesh Kumar Krishnan [Syncfusion]
Replied On November 15, 2014 12:03 AM

Hi Rodolphe,

               Currently we are not having the support to achieve your requirement. We have consider this as a feature request and it can be tracked through our Features Management System.
FR Link: http://www.syncfusion.com/support/directtrac/features/WRT-3707

Please let us know if you have any queries.

Thanks,
Magesh Kumar K

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;