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