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
close icon

Programmatically set the value for PieSeries.ColorModel

Hi,

Hope you are doing well.

Can you please let me know if there is a possibility to set the ColorModel for a SfChart.PieSeries programmatically?
I achieved till setting the value for ChartColorModel which is as follows;

ChartColorModel colorModel = new ChartColorModel();
colorModel.CustomBrushes.Add((SolidColorBrush)(new BrushConverter().ConvertFrom("#49B792")));
colorModel.CustomBrushes.Add((SolidColorBrush)(new BrushConverter().ConvertFrom("#FCBF00")));
colorModel.CustomBrushes.Add((SolidColorBrush)(new BrushConverter().ConvertFrom("#B3181F")));

Now I facing a problem to add this ChartColorModel to PieSeries.ColorModel or I can say I don't know how to add this ChartColorModel to the PieSeries.ColorModel in C#.
Please help me with this.

Thank you very much in advance.

Best Regards,
Krishna Kumar

2 Replies

KK Krishna Kumar Nanjundaprasad July 14, 2015 10:40 AM UTC

Hi,

Fortunately, I bound the created object to the ColorModel property of the pie series and it worked.
Thanks again.

Code for reference;
<sfchart:PieSeries DockPanel.Dock="Left" LabelPosition="Inside" sfchart:ChartTooltip.EnableAnimation="True"
                                   ItemsSource="{Binding ChartData}" XBindingPath="{Binding XBindingPathValue}" YBindingPath="{Binding YBindingPathValue}" PieCoefficient="0.50" 
                                   EnableSmartLabels="True" SelectedIndex="{Binding SelectedChartSegmentIndex,Mode=TwoWay}"
                                   ShowTooltip="True" HorizontalContentAlignment="Left" Width="auto"
                                   Margin="-50,-50,-50,-50" FontSize="20" FontWeight="Bold"
                                   Palette="Custom" ColorModel="{Binding colorModel}">
</sfchart:PieSeries>

Best regards,
Krishna Kumar


RA Rachel A Syncfusion Team July 15, 2015 04:06 AM UTC

Hi Krishna,

Thanks for the update.

Please let us know if you need any further assistance.

Thanks,
Rachel. A

Loader.
Live Chat Icon For mobile
Up arrow icon