Change BarSeries Color of Individual Bars

2 posts, 0 answers
  1. Brent Hetland
    Brent Hetland avatar
    61 posts
    Member since:
    Aug 2009

    Posted 24 Apr 2015 Link to this post

    Hi,

    I am using Q2 2014 SP1 of Telerik Reporting.  I am creating the entire Graph object in code (and setting it's datasource), and adding a couple of series to it (a line and a bar).

    I need to be able to change the color of the individual bars in the bar series.  I am graphing monthly measurements (metrics) where the Line Series is a "Planned" (like ar Budget) value and the Bar Series is the "Actual" value.  This Actual value will either be above or below the Planned value and if they have hit or exceeded their plan for we want to color the bar Green for that single data point.  If they've missed their plan, we want to color the bar Red.

    This is very easy to do with your ASP.NET HTML Chart, but I don't see an example of how to do this with the reporting Graph.  For now, I'm creating my BarSeries as below.

        var actualColumnSeries1 = new Telerik.Reporting.BarSeries();
        actualColumnSeries1.CategoryGroup = productCategoryGroup;
        actualColumnSeries1.CoordinateSystem = cartesianCoordinateSystem1;
        actualColumnSeries1.LegendItem.Value = "Actual";
        actualColumnSeries1.SeriesGroup = orderDateGroup;
        actualColumnSeries1.Y = "=CDbl(IsNull(Fields.ActualValue, 0))";

     

    But it seems what I really want to do, is to do it like I do it with the ASP.NET HTML Chart.  With the HTML Chart I:

     

       Dim actualColumnSeries As New ColumnSeries

       For Each bv As MyMetricValue in TheMetricValues

               Dim seriesItem As CategorySeriesItem

               seriesItem = New CategorySeriesItem(bv.ActualValueCalced)
               seriesItem.BackgroundColor = GetDrawingColorFromValueStatus(bv.ActualValueStatusFromDB, False)
               actualColumnSeries.SeriesItems.Add(seriesItem)
       Next

     

    Is there a way to do this in the Reporting Graph?  If not, then I'm in a bad spot because I can't use the ASP.NET HTML Charts due to their poor performance in older browser when there are a lot of them on my page (15 or more, and yes I've followed your article regarding performance optimization for the HTMLChart).

  2. Brent Hetland
    Brent Hetland avatar
    61 posts
    Member since:
    Aug 2009

    Posted 24 Apr 2015 Link to this post

    This has been resolved.  I figured out how to use an actual Graph object in the designer and bind it to a List of business objects that I have hanging off of the list of business objects I use for the report's datasource, so now I no longer need to create the graph and everything in code.

     

    That means I can use DataPointConditionalFormatting on that series...

Back to Top