This is a migrated thread and some comments may be shown as answers.

[Solved] change the color of pie chart series for bound data

1 Answer 195 Views
Chart for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Yiqing
Top achievements
Rank 1
Yiqing asked on 29 Jul 2013, 08:06 AM
Hi,

I've bound my pie chart to a dynamic data source, which contains number as the populating value and 'status' as the name of the series. I wonder if there's any way to manually control what color being assigned to each of the 'status'? For example, the automatic generated pie chart has red for 'passed' and green for 'failed', however I want red for 'failed' and green for 'passed'.

Thanks,
Yiqing

1 Answer, 1 is accepted

Sort by
0
Rosy Topchiyska
Telerik team
answered on 30 Jul 2013, 04:35 PM
Hello Yiqing,

Thank you for your interest in RadControls for Windows 8!

To change the default colors of the pie slices, you have to use the SegmentStyleSelector property of the RadPieChart. I have attached a sample project that demonstrates how you can achieve this. You have to define a class  that inherits from the StyleSelector class and override its SelectStyleCore property to return custom Style depending on the value of the Status property. Note that the Style that applies to a pie piece should have TargetType="Path".

In the sample I have added two properties of type Style to the style selector class (one for each status) and defined them in xaml. I have also displayed the value of the Status property in the chart labels to make it clear that the pieces are colored accordingly.

I hope this helps and don't hesitate to contact us again if there is anything else we can assist you with.

Regards,
Rositsa Topchiyska
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Chart for XAML
Asked by
Yiqing
Top achievements
Rank 1
Answers by
Rosy Topchiyska
Telerik team
Share this question
or