Show Label When Value is Zero

2 posts, 0 answers
  1. Jon
    Jon avatar
    35 posts
    Member since:
    Sep 2013

    Posted 07 Nov 2013 Link to this post

    On my chart (see attached), the value is zero where the green arrow is.  I want the label to show "Current: 0" there.  Instead, it shows nothing.  The value is actually 0 and not null.  My users are going to think it's "missing".  How can I get the label to show?
  2. Stamo Gochev
    Stamo Gochev avatar
    154 posts

    Posted 12 Nov 2013 Link to this post


    This is a bug in Bar and ColumnSeries, so I have logged it in our Feedback portal, where you can vote and track its progress. I have also update your Telerik points for this bug report.

    There is a workaround, whose idea follows these steps:
    1. Create a constant variable which is a very small number  like 0.00000000001 and use it as a marker
    2. When you populate the SeriesItems, check if the next item's value is equal to 0 (zero) and if this is the case, change its value to the constant variable in step 1.
    3. Use the ClientTemplate property of the LabelsAppearance to switch the item's label - check if the item's values is equal to INVALID_VALUE (the constant in step 1) and show a label with the value "0" in this case:
      const decimal SPECIAL_VALUE = 0.000000000000000000000001M;
      BarSeries bar1 = new BarSeries();
      bar1.LabelsAppearance.ClientTemplate = "#= value === " + SPECIAL_VALUE + " ? 0 : value #";

    I also attach a sample page, where I have demonstrated this approach. You can use it as a reference and apply the idea in your scenario.

    Stamo Gochev
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top