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. Image for the cookie policy date

How to control interior color of a PieChart

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>

5 Replies

MA Mohammed Azarudeen Syncfusion Team October 20, 2014 05:43 AM UTC

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


RB Rodolphe Billottet October 27, 2014 01:12 AM UTC

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


MA Mohammed Azarudeen Syncfusion Team October 27, 2014 12:41 PM UTC

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


RB Rodolphe Billottet November 12, 2014 10:09 AM UTC

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)
 


MK Magesh Kumar Krishnan Syncfusion Team November 15, 2014 05:03 AM UTC

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

Loader.
Live Chat Icon For mobile
Up arrow icon