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

How do you hide stacked bar items which are zero or null?

3 Answers 186 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 30 Jan 2011, 05:38 AM
Hi,

I use horizontal Stacked Bars to show up to four different things.  This is working fine as long as no one has 0 as value. Than it looks like there's an extra  "0" on the stacked bar with no visible bar segment.

This is a databound chart (fed in the NeedDataSource event) using a sqladapter and all working and fine except for this which kills the credibility of the chart for users..

How do I show no number if the bar is not visilbe == the value is zero?

I've looked through the forums and found related articles from some time ago but no potential solutions seem to work for me in Q3-2010 Reporting.  I'm using VS 2010 also (VB).

Thanks in advance,
Steve

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 02 Feb 2011, 04:10 PM
Hi Steve,

Telerik Reporting is a data driven reporting solution thus the easiest way to avoid the null and zeros is by setting up Chart Filters. Filters are used to limit the number of records in a report based on specified filter rules. If the conditions of the rules are met, the record is included in the report. Multiple rules can be defined that make up a filter. Filters are defined using the the Edit Filter Dialog

Regards,
Peter
the Telerik team
Get started with Telerik Reporting with numerous videos and detailed documentation.
0
Steve
Top achievements
Rank 1
answered on 02 Feb 2011, 06:50 PM
Hi Peter,

I appreciate the Filters and use them elsewhere in our application to filter out records in Telerik Reporting, however, in this case I have a different need.  The resulting SQL Adapter data (fed at NeedDataSource) might look like this:

Columns:     Location    Data1    Data2    Data3     

Record 1:     Chicago          3           4           8
Record 2:     New York      17          0           6
Record 3:     Dallas            20          9           1
Record 4:     Portland          5           7           2

When I produce a bar chart or stacked bar chart, we see a "0" on the chart for New York Data 2 which looks bad.

I had tried using a Filter (Data1 > 0 and Data2 > 0 and Data3 > 0) and it filtered out the the entire New York record which is no good.

How can a developer, in VB code or otherwise in the designer, identify the New York Data 2 as a zero (or any other record/column item) and set it's label to blank or to make it not visible?

Thanks,
Steve
0
Peter
Telerik team
answered on 07 Feb 2011, 05:39 PM
Hello Steve,

Currently the only way to hide the labels for zero value items is to create your chart programmatically and handle the items' labels as shown in the following code snippet:

ChartSeries chartSeries2 = new ChartSeries();
chartSeries2.Appearance.LabelAppearance.Visible = true;
chartSeries2.Name = "Series2";
chartSeries2.Type = ChartSeriesType.StackedBar;
 
var item = new ChartSeriesItem(0);
item.Label.Appearance.Visible = false;
chartSeries2.AddItem(item);

Best wishes,
Peter
the Telerik team
Get started with Telerik Reporting with numerous videos and detailed documentation.
Tags
General Discussions
Asked by
Steve
Top achievements
Rank 1
Answers by
Peter
Telerik team
Steve
Top achievements
Rank 1
Share this question
or