Progress® Telerik® Reporting R3 2021

New to Telerik Reporting? Download free 30-day trial

How Do I Assign Individual Colors to Bars?

This article is obsolete. The Chart item is now superseded by the more advanced Graph item. The Graph item is most often used for building powerful OLAP/Pivot charts.

"I need each bar in a bar chart to be a different color.  How do I do this?"

By default the chart is designed so that all bars from a series have the same colors. If you need each to have a different color, loop through each chart series item and assign them a color from an array. This should be done after binding the chart, so the chart series items are available.

Colors Assigned to Individual Items

 

public ChartReport()
{
/// <summary>
/// Required for telerik Reporting designer support
/// </summary>
InitializeComponent();
// 
// TODO: Add any constructor code after InitializeComponent call
// 
            Color[] barColors = new Color[8]{
                Color.Purple,
                Color.SteelBlue,
                Color.Aqua,
                Color.Yellow,
                Color.Navy,
                Color.Green,
                Color.Blue,
                Color.Red
            };
                int i = 0;
                foreach (ChartSeriesItem item in chart1.Series[0].Items)
                {
                    item.Appearance.FillStyle.MainColor = barColors[i++];
                }
            }
        }

 

In this article
Not finding the help you need?