public class DataItem { public string Label { get; set; } public double Value { get; set; } } public class Data : ObservableCollection<DataItem> { public Data() { Add(new DataItem { Label = "Item 1", Value = 5 }); Add(new DataItem { Label = "Item 2", Value = 6 }); Add(new DataItem { Label = "Item 3", Value = 3 }); Add(new DataItem { Label = "Item 4", Value = 7 }); Add(new DataItem { Label = "Item 5", Value = 5 }); } }
This is how we're passing the Label name and value of every slice presented in the Pie Chart. I need to pass the color also. I need to take the control of the Color of every slices I creates. How to achieve this ?
Thanks in advance.
Hi Mohamed,
You can declare an Infragistics.BrushCollection and add the colors that you want to use. Then set the pie chart's Brushes to your collection. The colors will be applied to the slices in your pie chart in the order that the data items were added to your item source.
BrushCollection bc = new BrushCollection();
bc.Add(new SolidColorBrush(Colors.Red));
bc.Add(new SolidColorBrush(Colors.Green));
bc.Add(new SolidColorBrush(Colors.Blue));
bc.Add(new SolidColorBrush(Colors.Pink));
bc.Add(new SolidColorBrush(Colors.Brown));
pieChart.Brushes = bc;
Please let me know if you have any questions.
Hi this is vijay, thanks for your suggestion