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

2 posts, 0 answers
  1. Shane
    Shane avatar
    9 posts
    Member since:
    Feb 2016

    Posted 30 Aug Link to this post

    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

     

  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 30 Aug Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top