This is a migrated thread and some comments may be shown as answers.

Show Label When Value is Zero

1 Answer 112 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Gaurab
Top achievements
Rank 1
Gaurab asked on 07 Nov 2013, 11:44 PM
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?

1 Answer, 1 is accepted

Sort by
0
Stamo Gochev
Telerik team
answered on 12 Nov 2013, 09:51 AM
Hi,

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.

Regards,
Stamo Gochev
Telerik
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.
Tags
Chart (HTML5)
Asked by
Gaurab
Top achievements
Rank 1
Answers by
Stamo Gochev
Telerik team
Share this question
or