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

stacked bar chard, only show label that have values

1 Answer 23 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Kristjan Einarsson
Top achievements
Rank 1
Kristjan Einarsson asked on 24 Jan 2012, 02:29 PM
Hi I have a stacked bar chart, can I disable labels that have 0 values as seen on the attached picture.

Thanks
sushibite

1 Answer, 1 is accepted

Sort by
0
Accepted
Evgenia
Telerik team
answered on 26 Jan 2012, 03:34 PM
Hello Kristjan,

In order to hide the labels of items with zero values, you can simply remove the DataPoints in the following manner :
RadChart1.ItemDataBound += new EventHandler<ChartItemDataBoundEventArgs>(RadChart1_ItemDataBound);
void RadChart1_ItemDataBound(object sender, ChartItemDataBoundEventArgs e)
       {
           if (e.DataPoint.YValue == 0)
               e.DataPoint.DataSeries.Remove(e.DataPoint);
       }

Alternatively, you may refer to the MeteoChart example, which uses a LabelVisibilityConverter class. Perhaps reviewing it would be helpful for you. Simply navigate to the Meteo Chart demo and press the View Code button to find the LabelVisibilityConverter.cs file.

Kind regards,
Evgenia
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
Chart
Asked by
Kristjan Einarsson
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Share this question
or