This is a migrated thread and some comments may be shown as answers.

Change Individual Bar Colour If Higher Than Same Category In Another Series

1 Answer 50 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
IT
Top achievements
Rank 1
IT asked on 30 Aug 2016, 08:23 AM

Hi,

I have 2 series of data as shown in the picture. The green bar is the target time to complete a task and the blue bar is actual time taken. I need to make the blue bars turn red if they are higher than the green bars? Can this be done?

Thanks

 

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 30 Aug 2016, 10:08 AM
Hi Shane,

Thank you for writing.

You can iterate the elements after the series are added to the chart:
foreach (BarPointElement item in barSeries.Children)
{
    var point1 = ((CategoricalDataPoint)item.DataPoint);
    
    foreach (CategoricalDataPoint point in barSeries2.DataPoints)
    {
        if (point1.Category == point.Category)
        {
            if (point1.Value > point.Value)
            {
                item.BackColor = Color.Red;
                break;
            }
        }
    }   
}

Let me know if you have additional questions.

Regards,
Dimitar
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Tags
ChartView
Asked by
IT
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or