Setting Microsoft Chart Series Colors
Microsoft Chart control provides different ways to set color of the series and data points:
Palettes
Selecting one of the predefined palettes is the easiest way to change chart series colors. There are 12 built-in palettes with about 10 unique colors each.
Chart types like column and line, will assign a unique color from the palette to each of the series. If chart runs out of the palette colors then it will start reusing them again.
// Set chart series palette Chart.Palette = ChartColorPalette.Pastel;
Chart type like Pie, assigns unique colors to each individual data point. You can still use Chart.Palette property or you can define different palettes for different series using Series.Palette property. Note that setting Series.Palette property will force all chart types including Column to use unique colors for each data point.
Important! To determine the color assigned to the series or data point from the palette you can call chart1.ApplyPaletteColors() method and then check Series or DataPoint.Color property.
Custom Palettes
If none of the predefined palettes fits your needs, you can always create custom palette with as many colors as you need:
// Set chart custom palette Chart.Palette = ChartColorPalette.None; Chart.PaletteCustomColors = new Color[] { Color.Red, Color.Blue, Color.Yellow};
Empty points
Not all series data points are equal… When you data bind your chart to the DBNull values the data points will be automatically marked as ‘empty’. You can also mark data points as empty by setting DataPoint.IsEmpty property. Each empty data point uses the visual attributes defined in Series.EmptyPointStyle property.
// Hide all series empty data point by making them transparent Chart.Series[0].EmptyPointStyle.Color = Color.Transparent;
Color Property
If all of the above methods does not work for you, then you can always set Color property for the series or individual data point.
// Set color for the whole series Chart.Series[0].Color = Color.Green; // Set color of a single data point Chart.Series[0].Points[5].Color = Color.Red;
You can always switch back to using the palette colors by setting both Series and DataPoint Color properties to Color.Empty.
Alex.