Issue with ShowZeroValueLabels

3 posts, 0 answers
  1. Sylvie
    Sylvie avatar
    2 posts
    Member since:
    Sep 2011

    Posted 18 Jan 2012 Link to this post

    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. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 23 Jan 2012 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Sylvie
    Sylvie avatar
    2 posts
    Member since:
    Sep 2011

    Posted 23 Jan 2012 Link to this post

    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.

Back to Top