Chart for WinRT > Chart Types > Bar and Column Charts > Specifying the Color of Each Bar/Column in the Data Series |
You can specify the color of each bar or column in your chart in the DataSeries.PlotElementLoaded event by using the following code:
C# |
Copy Code
|
---|---|
var palette = new Brush[] { new SolidColorBrush(Colors.MediumSlateBlue), new SolidColorBrush(Colors.Purple), new SolidColorBrush(Colors.Blue), }; ds.PlotElementLoaded += (s, e) => { PlotElement pe = (PlotElement)s; if (pe.DataPoint.PointIndex >= 0) pe.Fill = palette[pe.DataPoint.PointIndex % palette.Length]; }; |