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

Standardising colors for multiple pie charts

1 Answer 67 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Qin Le
Top achievements
Rank 1
Qin Le asked on 10 May 2012, 07:06 AM

i have a pie chart showing a list of districts where each slice of the pie chart is clickable.
eg. i have the districts: A, B, and C
within each of these districts, there are categories of items grouped under each district with reference to a fixed category list.
the fixed category list would have items: a, b, c, d, and e.
and the following are the item categories group under each district and the colors of the slices are shown in order in bracket:
A has a, b, c (red, yellow, blue)
B has b, c, d (red, yellow, blue)
C has c, d, e (red. yellow, blue)

my current pie chart would load as stated above when i click into A, the item  c will be blue, for B, item c will be yellow, and in C, item c is red.

So i'm looking for a solution that is able to bind a value to a specific color as in if in A, B, and C regardless of the arrangement, the item c will be the same color (eg. only blue)

my XAML code:

<telerik:RadChart Grid.Row="0" Grid.Column="0" x:Name="MyMasterChart">
                    <telerik:RadChart.HierarchyManager>
                        <telerik:HierarchyManager x:Name="MyChartHierarchy"></telerik:HierarchyManager>
                    </telerik:RadChart.HierarchyManager>
  
                    <telerik:RadChart.DefaultView>
                        <telerik:ChartDefaultView ChartLegendPosition="Bottom">
                            <telerik:ChartDefaultView.ChartLegend>
                                <telerik:ChartLegend x:Name="MyChartLegend" UseAutoGeneratedItems="True"  telerik:StyleManager.Theme="Summer" MouseLeftButtonUp="MyChartLegend_MouseLeftButtonUp" Background="#FFEEEFF1"></telerik:ChartLegend>
                            </telerik:ChartDefaultView.ChartLegend>
                            <telerik:ChartDefaultView.ChartArea>
                                <telerik:ChartArea x:Name="MyChartArea" SmartLabelsEnabled="True" LegendName="MyChartLegend" ItemClick="MyChartArea_ItemClick" SelectionChanged="MyChartArea_SelectionChanged" Background="#FFDAEFFF"></telerik:ChartArea>
                            </telerik:ChartDefaultView.ChartArea>
                        </telerik:ChartDefaultView>
                    </telerik:RadChart.DefaultView>
  
                    <telerik:RadChart.HierarchicalViewDescriptors>
                        <telerik:ChartHierarchicalViewDescriptor>
                            <telerik:ChartHierarchicalViewDescriptor.SeriesMappings>
                                <telerik:SeriesMapping ChartAreaName="MyChartArea">
                                    <telerik:SeriesMapping.SeriesDefinition>
                                        <telerik:PieSeriesDefinition ItemLabelFormat="#%{P2}">
                                            <telerik:PieSeriesDefinition.InteractivitySettings>
                                                <telerik:InteractivitySettings HoverScope="Item" SelectionMode="Single" SelectionScope="None"></telerik:InteractivitySettings>
                                            </telerik:PieSeriesDefinition.InteractivitySettings>
                                        </telerik:PieSeriesDefinition>
                                    </telerik:SeriesMapping.SeriesDefinition>
                                    <telerik:ItemMapping FieldName="DistrictTotalSales" DataPointMember="YValue"></telerik:ItemMapping>
                                    <telerik:ItemMapping FieldName="DistrictName" DataPointMember="LegendLabel"></telerik:ItemMapping>
                                </telerik:SeriesMapping>
                            </telerik:ChartHierarchicalViewDescriptor.SeriesMappings>
                        </telerik:ChartHierarchicalViewDescriptor>
                        <telerik:ChartHierarchicalViewDescriptor>
                            <telerik:ChartHierarchicalViewDescriptor.Relation>
                                <telerik:PropertyRelation ParentPropertyName="SalesDetails"></telerik:PropertyRelation>
                            </telerik:ChartHierarchicalViewDescriptor.Relation>
                            <telerik:ChartHierarchicalViewDescriptor.SeriesMappings>
                                <telerik:SeriesMapping>
                                    <telerik:SeriesMapping.SeriesDefinition>
                                        <telerik:PieSeriesDefinition ItemLabelFormat="#%{P2}">
                                            <telerik:PieSeriesDefinition.InteractivitySettings>
                                                <telerik:InteractivitySettings HoverScope="Item" SelectionScope="None"></telerik:InteractivitySettings>
                                            </telerik:PieSeriesDefinition.InteractivitySettings>
                                        </telerik:PieSeriesDefinition>
                                    </telerik:SeriesMapping.SeriesDefinition>
                                    <telerik:ItemMapping FieldName="TotalSales" DataPointMember="YValue"></telerik:ItemMapping>
                                    <telerik:ItemMapping FieldName="ProductMajorName" DataPointMember="LegendLabel"></telerik:ItemMapping>
                                </telerik:SeriesMapping>
                            </telerik:ChartHierarchicalViewDescriptor.SeriesMappings>
                        </telerik:ChartHierarchicalViewDescriptor>
                    </telerik:RadChart.HierarchicalViewDescriptors>
                </telerik:RadChart>

p/s: the data loaded onto the pie chart is from a database. 

 hopefully these are enuf to give a clear view of my problem. thanks

1 Answer, 1 is accepted

Sort by
0
Sia
Telerik team
answered on 14 May 2012, 03:57 PM
Hello Qin Le Lee,

Please try to use a custom delegate to style your pie slices depending on some constant value [i.e. index or name]. Please try this approach and let me know how it works on your end.

Regards,
Sia
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
Chart
Asked by
Qin Le
Top achievements
Rank 1
Answers by
Sia
Telerik team
Share this question
or