How to Assign Individual Colors to Bars
RadChart has been deprecated since Q3 2014 and is no longer recommended for use, as it does not support modern browsers. We strongly recommend using RadHtmlChart, Telerik's modern client-side charting component. To transition from RadChart to RadHtmlChart, refer to the following migration articles:
Explore the RadHtmlChart documentation and online demos to determine how it fits your development needs.
"I need each bar in a bar chart to be a different color. How do I do this?"
By default RadChart 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.
protected void Page_Load(object sender, EventArgs e)
{
Color[] barColors = new Color[8]{
Color.Purple,
Color.SteelBlue,
Color.Aqua,
Color.Yellow,
Color.Navy,
Color.Green,
Color.Blue,
Color.Red
};
if (!IsPostBack)
{
int i = 0;
RadChart1.DataSourceID = "SqlDataSource1";
RadChart1.DataBind();
RadChart1.Series[0].Name = "Units by Category";
foreach (ChartSeriesItem item in RadChart1.Series[0].Items)
{
item.Appearance.FillStyle.MainColor = barColors[i++];
}
}
}