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

Pie Chart colors

2 Answers 102 Views
Chart
This is a migrated thread and some comments may be shown as answers.
wdudek
Top achievements
Rank 1
wdudek asked on 28 Jun 2010, 07:26 PM
Hi, I based my chart off of the code found at http://demos.telerik.com/silverlight/#Chart/Gallery/Pie but am having problems in that the colors I get are all the same shade of blue? I don't really care what they are but need some variation, I didn't see this happening anywhere in the example code though?


Here is what I have in the xaml for the chart and then my populating code

<telerik:RadChart x:Name="OrderChart"  d:LayoutOverrides="Width, Height"
        </telerik:RadChart> 



C# (this is a demo app where I want the user to be able to select multiple chart styles to decide what they like) The bar charts do ge the multiple colors, the rest do not??

public void ReloadChart() 
        { 
             
            if (OrderChart == null
                return
 
            OrderChart.DefaultView.ChartTitle.Content = "Account Sales"
 
            SeriesMapping seriesMapping = new SeriesMapping(); 
 
            string selection = ((System.Windows.Controls.ListBoxItem)(ChartSelector.SelectedItem)).Content.ToString (); 
 
             
            switch (selection) 
            { 
                case "Bar"
                    OrderChart.DefaultSeriesDefinition = new BarSeriesDefinition(); 
                    break
 
                case "3D Bar"
                    OrderChart.DefaultSeriesDefinition = new Bar3DSeriesDefinition(); 
                    break
 
                case "Doughnut"
                   OrderChart.DefaultSeriesDefinition = new DoughnutSeriesDefinition(); 
                    break
 
                case "3D Doughnut"
                    OrderChart.DefaultSeriesDefinition = new Doughnut3DSeriesDefinition(); 
                    break
 
                case "Pie"
                    OrderChart.DefaultSeriesDefinition = new  PieSeriesDefinition(); 
                    break
 
                case "3D Pie"
                    OrderChart.DefaultSeriesDefinition = new Pie3DSeriesDefinition(); 
                    break
            } 
 
             
 
             
            OrderChart.DefaultSeriesDefinition.ItemLabelFormat = "N0"
             
            ChartAggregateFunction aggFunct = ChartAggregateFunction.Sum; 
 
            seriesMapping.GroupingSettings.GroupDescriptors.Add(new ChartGroupDescriptor("AccountNumber")); 
            seriesMapping.GroupingSettings.ShouldCreateSeriesForLastGroup = true
 
            ItemMapping yMapping = new ItemMapping("OrderQuantity", DataPointMember.YValue, aggFunct); 
            ItemMapping catMapping = new ItemMapping("AccountNumber", DataPointMember.XCategory); 
 
            seriesMapping.ItemMappings.Add(yMapping); 
            seriesMapping.ItemMappings.Add(catMapping); 
 
            OrderChart.SeriesMappings.Clear(); 
            OrderChart.SeriesMappings.Add(seriesMapping); 
 
            OrderChart.ItemsSource = this.DataContext; 
 
        } 


Any suggestions would be great.

Thanks

Bill

2 Answers, 1 is accepted

Sort by
0
Accepted
Ves
Telerik team
answered on 30 Jun 2010, 11:26 AM
Hello Bill,

Your code shows that you use grouping in RadChart. Note, that when grouping in RadChart you get more than one DataSeries. Actually, it is one DataSeries for each distinct value in the grouping column. Unfortunately, RadChart does not support multiple pie series with a single DataItem in each of them. They are just placed over each other, so it appears there is a single color in the pie.

In order to debug this you can wire the ItemDataBound event and check OrderChart.DefaultView.ChartArea.DataSeries. For pie series you may want not to group the data within the chart, so that there is only one DataSeries.

Sincerely,
Ves
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
wdudek
Top achievements
Rank 1
answered on 30 Jun 2010, 08:53 PM
Thanks, 

   With that I was able to figure it out.
Tags
Chart
Asked by
wdudek
Top achievements
Rank 1
Answers by
Ves
Telerik team
wdudek
Top achievements
Rank 1
Share this question
or