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

How to Hide Zeros on bars

2 Answers 188 Views
Chart (obsolete as of Q1 2013)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
ManniAT
Top achievements
Rank 2
ManniAT asked on 14 May 2008, 11:08 PM
Hi,

I use horizontal Stacked Bars to show four different things about one person.
The display is Red Bar (Number centered in it), Orange Bar (Number centered in it),
Yellow Bar (Number centered in it) and Blue Bar (Number centered in it).

Work fine as long as noone has 0 as value.
Than it looks like
NO Red bar -- but a number (Zero) of the red value on the right side in the following Orange bar.
Or worse - Red==0 Orange == 3 Yellow == 0
So I get an orange bar with it's value in the center
AND 0 on the rigth as well as on the left :)

I build the graph from a generic list of objects.
So binding is simply done by setting datasource and the "Fieldnames" for the Series[x] values.

Is it possible to show no number if the bar is not visilbe == the value is zero?

Regards

Manfred

2 Answers, 1 is accepted

Sort by
0
Accepted
Dwight
Telerik team
answered on 15 May 2008, 08:59 AM
Hello Manfred,

Thanks for writing. There is no out of the box solution to your problem and such feature is not planned for development. I can suggest traversing the chart items in the series and hiding the corresponding labels. That, of course, should be done after the data binding.

Here is a sample program that removes the labels from all items with value of 0 (in all series):
 
for (int j = 0; j < this.radChart1.Series.Count; j++) 
    ChartSeriesItemsCollection items = this.radChart1.Series[j].Items; 
    for (int i = 0; i < items.Count; i++) 
    { 
        if (items[i].YValue == 0) 
            items[i].Label.Visible = false
    } 

Removing of those labels should be done after data binding or in a PrePaint event handler.
 

Regards,
Evtim
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
ManniAT
Top achievements
Rank 2
answered on 15 May 2008, 09:13 AM
Hi,

thank you for the fast and great support.
Took me 1 minute to add a function called after .DataBind().

Works like a charm :)

Thanks a lot

Manfred
Tags
Chart (obsolete as of Q1 2013)
Asked by
ManniAT
Top achievements
Rank 2
Answers by
Dwight
Telerik team
ManniAT
Top achievements
Rank 2
Share this question
or