Stacked bars legend

Thread is closed for posting
4 posts, 1 answers
  1. Travis
    Travis avatar
    8 posts
    Member since:
    Nov 2007

    Posted 19 Sep 2008 Link to this post

    When I created stacked bars chars the legend is always reverse to what the order of the stacked bars are.  Is there any way to achieve the legend matching to colors of the stacked bar?
  2. Answer
    Ves
    Admin
    Ves avatar
    2879 posts

    Posted 23 Sep 2008 Link to this post

    Hello Travis,

    This is the expected behavior as the bars are stacked from the bottom towards the top, while the legend items are added top to bottom. You can wire BeforeLayout event of the chart and reorder the RadChart.Legend.Items collection.


    All the best,
    Ves
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Travis
    Travis avatar
    8 posts
    Member since:
    Nov 2007

    Posted 23 Sep 2008 Link to this post

    Here is a code snippet if anyone else runs across this.

        Protected Sub reverseLegend(ByRef collection As Telerik.Charting.ChartLabelsCollection) 
            Dim temp(collection.Count - 1) As Telerik.Charting.LabelItem 
            Dim i As Integer 
            Dim count As Integer = 0 
            For i = collection.Count - 1 To 0 Step -1 
                temp(count) = collection(i) 
                count += 1 
            Next 
            collection.Clear() 
            collection.AddRange(temp) 
        End Sub 

  5. Marc Fearby
    Marc Fearby avatar
    14 posts
    Member since:
    Aug 2012

    Posted 23 Aug 2012 Link to this post

    Thanks for providing the solution, Travis. This "expected behaviour" excuse just seems like a cover-up for sloppy design. Who in their right mind would want a legend ordered opposite to the many items in a stacked bar chart?
Back to Top