How to Hide Zeros on bars

Thread is closed for posting
3 posts, 1 answers
  1. ManniAT
    ManniAT avatar
    885 posts
    Member since:
    Nov 2003

    Posted 14 May 2008 Link to this post


    I use horizontal Stacked Bars to show four different things about one person.
    The display is Red Bar (Number centered in it), Orange Bar (Number centered in it),
    Yellow Bar (Number centered in it) and Blue Bar (Number centered in it).

    Work fine as long as noone has 0 as value.
    Than it looks like
    NO Red bar -- but a number (Zero) of the red value on the right side in the following Orange bar.
    Or worse - Red==0 Orange == 3 Yellow == 0
    So I get an orange bar with it's value in the center
    AND 0 on the rigth as well as on the left :)

    I build the graph from a generic list of objects.
    So binding is simply done by setting datasource and the "Fieldnames" for the Series[x] values.

    Is it possible to show no number if the bar is not visilbe == the value is zero?


  2. Answer
    Dwight avatar
    475 posts

    Posted 15 May 2008 Link to this post

    Hello Manfred,

    Thanks for writing. There is no out of the box solution to your problem and such feature is not planned for development. I can suggest traversing the chart items in the series and hiding the corresponding labels. That, of course, should be done after the data binding.

    Here is a sample program that removes the labels from all items with value of 0 (in all series):
    1 for (int j = 0; j < this.radChart1.Series.Count; j++) 
    3     ChartSeriesItemsCollection items = this.radChart1.Series[j].Items; 
    4     for (int i = 0; i < items.Count; i++) 
    5     { 
    6         if (items[i].YValue == 0) 
    7             items[i].Label.Visible = false
    8     } 

    Removing of those labels should be done after data binding or in a PrePaint event handler.

    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. ManniAT
    ManniAT avatar
    885 posts
    Member since:
    Nov 2003

    Posted 15 May 2008 Link to this post


    thank you for the fast and great support.
    Took me 1 minute to add a function called after .DataBind().

    Works like a charm :)

    Thanks a lot

Back to Top