Data Source Helper
Send Feedback

Glossary Item Box

Topic Overview

Purpose

This topic provides a conceptual overview of the data source helper in the IGTreemapView™ and demonstrates its configuration using a code example.

In this topic


Introduction

Data source helper summary

Using the IGTreemapViewDataSourceHelper eliminates the need to implement any of the required protocol methods found in the IGTreemapViewDataSource class. Thus, simplifying your wiring up of data to the IGTreemapView control by using the data source helper specialized for this control.

The IGTreemapViewDataSourceHelper is extremely flexible in how the values, labels, and children load. The initialization method, initWithData:treemapView:, supports direct loading of your data arrays with an array of custom NSObjects. Additionally, you can initialize the IGTreemapViewDataSourceHelper using the generic init method, and depending on the use case, manually set the data and treemapView properties.

The IGTreemapView can contain many nested levels. To add a level and connect your custom data object paths to the data source helper, use the addLevelWithValuePath:labelPath:childSourcePath: method.

Note: Without adding at least 1 level, nothing will be rendered inside of the IGTreemapView.

IGTreemapView Data Source Helper – Code Example

Description

The code below demonstrates loading an NSMutableArray of NSObjects containing values for the tree map leaf node and the label properties. Once initialized, and after loading the values, labels, and children into the IGTreemapViewDataSourceHelper control, you can assign an instance of the data source helper to the IGTreemapView control’s dataSource property.

Prerequisites

This code example requires the inclusion of the Chart framework, detail about how to add this framework can be found in the Adding the Chart Framework File topic.

Code

In C#:

IGTreemapView treemapView = new IGTreemapView();
NSMutableArray data = new NSMutableArray();
// ...Add NSObjects to the array, the NSObject in this example must contain the property named “Value” and a property named “Label”. No children will be created.
IGTreemapViewDataSourceHelper dataSourceHelper = new IGTreemapViewDataSourceHelper(data, treemapView);
dataSourceHelper.AddLevel ("Value", "Label", String.Empty);
treemapView.DataSource = dataSourceHelper;

In Objective-C:

IGTreemapView *treemapView = [[IGTreemapView alloc]init];
NSMutableArray *data = [[NSMutableArray alloc]init];
// ...Add NSObjects to the array, the NSObject in this example must contain the property named “value” and a property named “label”. No children will be created.
IGTreemapViewDataSourceHelper *dataSourceHelper = [[IGTreemapViewDataSourceHelper alloc]initWithData:_data treemapView:_treemapView];
[_treemapViewDataSourceHelper addLevelWithValuePath:@"value" labelPath:@"label" childSourcePath:nil];
treemapView.dataSource = dataSourceHelper;

Related Content

Topics

The following topics provide additional information related to this topic.

Topic

Purpose

This topic serves as a gateway to the features and functionality of the IGTreemapView control.