Showing Slices with Zero Values in the Legend
Send Feedback

Glossary Item Box

Topic Overview


This topic provides an introductory overview of showing slices with zero values in the legend on the IGPieChartView™ control.

In this topic

This topic contains the following sections:


Slices with zero values summary

When the IGPieChartView creates its slices and legend items the pie chart skips all zeroes. To show zero value items in the legend the showZeroValuesInLegend property on the IGPieChartView allows zeroes to be treated as valid values. When this property is set to YES each zero slice will have its own brush and label. While the zero values are not actually rendering in the pie chart, they will appear in the pie chart’s legend.

Note: The IGPieChartView has a default ‘Others’ slice threshold. In order to get empty values to show in the legend, the property othersCategoryThreshold needs set to 0, otherwise, zero slices will get grouped into the ‘Others’ slice.

In Objective-C:

NSArray *values = @[@1,@0, @0, @1, @2];
_pieChartDataSourceHelper = [[IGPieChartViewDataSourceHelper alloc]initWithValues:values];
_pieChart = [[IGPieChartView alloc]initWithFrame:self.view.frame];
_pieChart.showZeroValuesInLegend = YES;
_pieChart.othersCategoryThreshold = 0;
_pieChart.dataSource = _pieChartDataSourceHelper;
_legend = [[IGLegend alloc]initWithFrame:CGRectMake(20, 20, 500, 40) andLegendType:IGChartLegendTypeItem];
_pieChart.legend = _legend;
 [self.view addSubview:_pieChart];
 [self.view addSubview:_legend];

In C#:

List<NSObject> values = new List<NSObject> { new NSNumber(1), new NSNumber(0), new NSNumber(0), new NSNumber(1), new NSNumber(2) };_pieChartDataSourceHelper = new IGPieChartViewDataSourceHelper(values.ToArray());_pieChart = new IGPieChartView ();_pieChart.Frame = this.View.Bounds;_pieChart.ShowZeroValuesInLegend = true;_pieChart.OthersCategoryThreshold = 0;_pieChart.DataSource = _pieChartDataSourceHelper;_legend = new IGLegend (new RectangleF (20, 20, 500, 40), IGChartLegendType.IGChartLegendTypeItem);_pieChart.Legend = _legend;this.View.AddSubview (_pieChart);this.View.AddSubview (_legend);

Related Content


The following topic provides additional information related to this topic.



The topics in this group cover enabling, configuring, and using the IGPieChartView control’s supported features.