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

Issue with ShowZeroValueLabels

2 Answers 89 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Yoeri
Top achievements
Rank 1
Yoeri asked on 18 Jan 2012, 05:25 PM
An easy question, hopefully with an easy solution : 

I use piecharts and StackedBar100 charts in our application to display voting results and results of multiple choice tests. The results are updated during the test, as answers are coming in. We get complaints about the "0" labels which are disturbing both in the stacked barcharts and in the piechart. However, when I set LabelSettings.ShowZeroValueLabels = false, no labels are ever shown. All datavalues are zero at the start of the test, and updating the dataseries dynamically works ok, but the hidden labels don't appear when a value becomes non-zero.  Only solution I see to make the labels appear is to redraw the chart on each incoming result, but that is not feasible. 
Is there a way to solve this issue ? 

thanks,
Xavier De Donder
Televic Education.

2 Answers, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 23 Jan 2012, 09:33 AM
Hello Xavier,

Your question was already answered in the support thread you started. I'm copying the answer here for the others who may be interested in this:
You can subscribe to ItemDataBound event of the RadChart and remove each datapoint which has YValue = 0:

private void radChart1_ItemDataBound(object sender, ChartItemDataBoundEventArgs e)
{
 if (e.DataPoint.YValue == 0)
 {
   radChart1.DefaultView.ChartArea.DataSeries[0].Remove(e.DataPoint);
 }


This should both work with StackedBars and Pie.

I suggest that we keep any further communication on the same topic in one of the threads ( either support or forum). This way we'll avoid duplicate questions and it will be easier for both sides to follow the conversation.

Greetings,
Evgenia
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Yoeri
Top achievements
Rank 1
answered on 23 Jan 2012, 12:05 PM
This replay is also just for the others who may be interested in this  (I first tried the public forum before entering a support ticket)  :

I don't use databinding but each datapoint value is updated explicitly in code. I simply worked around the zero-label problem as follows : 

dataPoint.YValue = newValue;
dataPoint.Label = "";
dataPoint.LabelFormat = (dataPoint.YValue != 0) ? "#Y" : "#LABEL";

This hides all "0" labels from the chart. Should have thought about that from the start...
In attachment a screenshot of the charts before and after codechange.

Tags
Chart
Asked by
Yoeri
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Yoeri
Top achievements
Rank 1
Share this question
or