Working with Tree Map Base 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 base 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 create a class of the delegate used to work with a tree map data view, and also to add a class file to source code of the ViewController class (see the Displaying of Express Report section). The it is required to place the following code in the body of the executeExample method of the ViewController class:

// 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 delegate
MATreeMap3DViewControllerDelegateImpl *treeMap3DCtrlDelegateImpl = [MATreeMap3DViewControllerDelegateImpl new];
// Create a controller for working with tree map base view
MATreeMap3DViewController *treeMap3DController = [[MATreeMap3DViewController new] autorelease];
[treeMap3DController setDataSource: [treeMapDataSource plusplusDataSource]];
[treeMap3DController setDelegate: treeMap3DCtrlDelegateImpl];
// Set controller for working with tree map base data view
[treeMap3DCtrlDelegateImpl setTreeMap3DViewController: treeMap3DController withDataSource: treeMapDataSource];
// Set path to the folder with the report, based on which a tree map is created
SNString plistPath = PPLFileManager::getReportPlistPath(m_olapReport->descriptor());
NSString* correctPath = plistPath?plistPath->nsString():NULL;
if (correctPath) {
    correctPath = [correctPath stringByDeletingLastPathComponent];
    [treeMap3DController setPathToDirReport: NString::stringWithNSString(correctPath)];
    NSLog(@"Path to report folder: %@", correctPath);
}
// Get report settings
SNDictionary sett = m_olapReport->settings();
SNDictionary treeMapSett = NULL; // Tree map settings
if (sett) {
    SNID treeMap = sett->objectForKey(NStr("treemap"));
    // Get tree map settings
    treeMapSett = (treeMap?treeMap->qClass<NDictionary>():NULL);
    if (treeMapSett) {
        // Set tree map settings
        SNID xmlNameSetting = treeMapSett->objectForKey(NStr("xmlsettingsfile"));
        [treeMap3DController setXmlNameSetting: (xmlNameSetting->qClass<NString>())];
    }
}
// Refresh tree data
[delegate controllerViewDidLoaded];
// Hide size legend
[treeMap3DController setIsSetSizeIndicator: NO];
// Hide color legend
[treeMap3DController setIsSetColorIndicator: NO];
// Load subviews
[treeMap3DController subviewsDidLayout];
// Delete all window subviews
NSArray *subviews = [self.view subviews];
for(UIView *subView in subviews)
{
    [subView removeFromSuperview];
}
// Display dimension panel
[self.view addSubview: [treeMap3DController view]];

After executing the example a tree map base 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, and also the path to the screenshot file:

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

See also:

Example of Component Use