Standardising colors for multiple pie charts

2 posts, 0 answers
  1. Qin Le
    Qin Le avatar
    1 posts
    Member since:
    May 2012

    Posted 10 May 2012 Link to this post

    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
  2. Sia
    Admin
    Sia avatar
    667 posts

    Posted 14 May 2012 Link to this post

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

  3. DevCraft banner
Back to Top