This question is locked. New answers and comments are not allowed.
Hello,
I want to use the different bar colors in the chart and AxisX labels can be modified.
Here is my code:
private void BindData() { List<TestModal1> lst = new List<TestModal1>(); lst.Add(new TestModal1() { Name = "FY10 Revenue", Value = 1845 }); lst.Add(new TestModal1() { Name = "Quota", Value = 2398 }); lst.Add(new TestModal1() { Name = "ITB", Value = 3487 }); lst.Add(new TestModal1() { Name = "Called Deals", Value = 3343 }); lst.Add(new TestModal1() { Name = "Run Rate", Value = 2069.96 }); lst.Add(new TestModal1() { Name = "Gap", Value = 2234 }); lst.Add(new TestModal1() { Name = "Pipeline", Value = 2433 }); chart.ItemsSource = lst; } void InitChart() { chart.DefaultView.ChartLegend.Visibility = System.Windows.Visibility.Collapsed; chart.DefaultView.ChartArea.AxisY.DefaultLabelFormat = "N0"; //SeriesMapping seriesMapping = new SeriesMapping(); //seriesMapping.SeriesDefinition = new BarSeriesDefinition(); //seriesMapping.SeriesDefinition.ItemLabelFormat = "N0"; //ItemMapping yMapping = new ItemMapping("Value", DataPointMember.YValue); //ItemMapping catMapping = new ItemMapping("Name", DataPointMember.XCategory); BrushCollection bcBrushes = new BrushCollection() { new SolidColorBrush(Color.FromArgb(255, 198, 156, 109)), new SolidColorBrush(Color.FromArgb(255, 247, 148, 29)), new SolidColorBrush(Color.FromArgb(255, 9, 132, 9)), new SolidColorBrush(Color.FromArgb(255, 5, 5, 254)), new SolidColorBrush(Color.FromArgb(255, 254, 167, 9)), new SolidColorBrush(Color.FromArgb(255, 167, 49, 49)), new SolidColorBrush(Color.FromArgb(255, 86, 116, 185))}; foreach (Brush item in bcBrushes) { chart.PaletteBrushes.Add(item); } chart.PaletteBrushesUseSolidColors = true; chart.DefaultSeriesDefinition.LegendDisplayMode = LegendDisplayMode.DataPointLabel; chart.DefaultSeriesDefinition.ItemLabelFormat = "N0"; //seriesMapping.ItemMappings.Add(yMapping); //seriesMapping.ItemMappings.Add(catMapping); //chart.SeriesMappings.Add(seriesMapping); }
But in my code, I can not change the AxisX labels. Please see attached image, it is a set of numbers.
However, if use SeriesMapping, the AxisX labels can be modified, but the color for that Series is solo color, not different colors for different bars.
Could you please tell me how to implement this?
Thanks,
George