Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example implements working with a pivot object for building data tables and its headers. After starting the example the following operations are executed:
Data matrix description is displayed in the development environment console.
Data aggregation is set.
Selection is removed by specified dimension.
The console displays description of title copy of the pivot object for building data table.
New titles are created, and their information is displayed.
New dimensions are added to title, after which they are moved.
The console displays the number of header dimensions, after which they are removed, and information about their number is displayed again.
A pivot object for building data tables is deleted.
Executing the example requires to place the following code in the body of the executeExample method of the ViewController class (see the Data Analysis section):
// Get pivot object for building data tables SPPLPivot pivot = m_gridPivot; // Get data matrix SPPLDataSourceMatrix matrix = pivot->matrix(); // Get data matrix description SNString matrixDescription = matrix->description(); // Display matrix description printf("Data matrix description: %s\n", matrixDescription->UTF8String()); // Get data source SPPLDataSource ds = pivot->dataSource(); // Set data aggregation ds->setIsAggregate(true); // Set data source pivot->setDataSource(ds); // Refresh pivot object for building data tables pivot->refresh(); // Redraw chart [chart setNeedsRedraw]; // Display whether data is aggregated printf("Whether data is aggregated: "); printf(ds->isAggregate() ? "true\n" : "false\n"); // Get dimension selection container SPPLDimensionSelectionSet selectionSet = pivot->selectionSet(); // Get number of dimension selections int selectionCount = selectionSet->selectionsCount(); // Get dimension selection SPPLDimensionSelection selection = selectionSet->getSelectionByIndex(0); // Get dimension SPPLDimension dimension = selection->dimension(); // Remove selection by specified dimension selectionSet->removeSelection(dimension->id()); // Set dimension selection container if number of selections is changed if(selectionCount != selectionSet->selectionsCount()) pivot->setSelectionSet(selectionSet); // Get copy of header of pivot object for building data tables SPPLPivotHeader originalHeader = pivot->topHeader(); SNID header = originalHeader->copy(); SPPLPivotHeader headerCopy = header->qClass<PPLPivotHeader>(); // Get header description SNString description = headerCopy->description(); printf("Header copy description: %s\n", description->UTF8String()); // Create a header PPLPivotHeader newHeader1 = PPLPivotHeader::PPLPivotHeader(); // Get title dimension array SNArray h1DimArray = newHeader1.dimensions(); // Display number of array elements if(h1DimArray != NULL) printf("Number of dimensions: %d\n", h1DimArray->count()); // Create a header for pivot object for building data tables SPPLPivotHeader newHeader2 = PPLPivotHeader::pivotHeader(originalHeader->relatedPivot()); // Display created header description printf("Description of created header: %s\n", newHeader2->description()->UTF8String()); // Get top header copy dimension SPPLDimension dim1 = headerCopy->dimensions()[0]->qClass<PPLDimension>(); // Get left header dimension SPPLDimension dim2 = pivot->leftHeader()->dimensions()[0]->qClass<PPLDimension>(); // Get fixed header dimension SPPLDimension dim3 = pivot->fixedHeader()->dimensions()[0]->qClass<PPLDimension>(); // Add dimensions to header headerCopy->putDimension(dim2); headerCopy->putDimension(dim3); // Move dimension up in header headerCopy->moveUp(dim3); // Move dimension down in header headerCopy->moveDown(dim1); // Display number of dimension in header printf("Number of dimensions in header: %d\n", headerCopy->dimensions()->count()); // Remove all dimensions headerCopy->removeAllDimensions(); // Display number of header dimensions after removal printf("Dimensions are removed\n"); printf("Number of header dimensions: %d\n", headerCopy->dimensions()->count()); // Delete pivot object for building data tables pivot->~PPLPivot();
After executing the example the development environment console displays information about the pivot object for building data tables and its headers:
Data matrix description: Matrix size: 1775
Whether data is aggregated: true
Header copy description: <NMutableArray:
id: CALENDAR_Y_ENG_533
name: Calendar
Elements tree:
Elements count: 11
>
Created header description: <NMutableArray:
>
Number of header dimensions: 3
Dimensions are removed
Number of header dimensions: 0
See also: