Working with Tree Map Data View

Operating system requirements: iOS 5.0 or later.

Mobile device: iPad.

Description

This example describes some methods of working with a tree map data view. After starting the example the following operations are executed:

Required Files

It is required to add the following file to the base example Displaying of Express Report:

Source Code

Executing the example requires to place the following code in the body of the executeExample method of the ViewController class (see the Displaying of Express Report section):

// Get express report controller
MAExpressAnalysisReportViewController *contr = (MAExpressAnalysisReportViewController *)m_controller;
// Get express report delegate
EAReportDelegateImpl *delegate = [contr delegate];
// Get tree map data source
TreeMapDataViewDataSource *treeMapDataSource = (TreeMapDataViewDataSource *)delegate.treeMapDatasource;
// Create a tree map controller
MATreeMapDataViewController *treeMapController = [[MATreeMapDataViewController alloc] initWithDataSource: treeMapDataSource];
[treeMapController setDelegate: contr];
[treeMapController setIsDataViewTitleVisible: YES];
SNString plistPath = PPLFileManager::getReportPlistPath(m_olapReport->descriptor());
NSString* correctPath = plistPath?plistPath->nsString():NULL;
if (correctPath) {
    correctPath = [correctPath stringByDeletingLastPathComponent];
    [treeMapController setPathToDirReport:correctPath];
    NSLog(@"Report folder path: %@", correctPath);
}
// Get report settings
SNDictionary sett = m_olapReport->settings();
SNDictionary treeMapSett = NULL; // Tree map settings
SNDictionary selectDict = m_olapReport->selectionDictionary();
if (sett) {
    SNID treeMap = sett->objectForKey(NStr("treemap"));
    // Get tree map settings
    treeMapSett = (treeMap?treeMap->qClass<NDictionary>():NULL);
    if (treeMapSett) {
        // Load and apply tree map settings
        [treeMapDataSource loadSettings:treeMapSett withSelection:selectDict];
        [treeMapController setXmlNameSettingFromDic:(NSDictionary *)treeMapSett->nsObject()];
        } else {
        // Set tree map settings
        [treeMapController setXmlNameSetting];
    }
}
// Refresh tree map data
[delegate controllerViewDidLoaded];
// Hide size legend
[treeMapController setIsSizeIndicator: NO];
// Hide color legend
[treeMapController setIsSetColorIndicator: NO];
// Display tree map
[self showViewControllerInFullScreen: treeMapController];

After executing the example the tree map data view is displayed. Color and size legends are hidden:

The development environment console displays the path to the folder with the express report, based on which data a tree map is created:

Report folder path: /Users/sea/Library/Application Support/iPhone Simulator/7.1/Applications/AC4804D8-C173-4008-B14D-4A2401B0B49D/Documents/repositories/910419CE79EA52E95F2F8FE76E7C24DE/OBJ21110

See also:

Example of Component Use