Specifying the Color of Each Bar/Column in the Data Series

You can specify the color of each bar/column in the datat series PlotElementLoaded event using the following code:

 

var palette = new Brush[] { Brushes.Red, Brushes.Plum, Brushes.Purple };

      dataSeries.PlotElementLoaded += (s, e) =>

        {

          PlotElement pe = (PlotElement)s;

          if (pe.DataPoint.PointIndex >= 0)

            pe.Fill = palette[pe.DataPoint.PointIndex % palette.Length];

        };


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.