BIRT Data Analyzer API classes : Class actuate.xtabanalyzer.Crosstab

Class actuate.xtabanalyzer.Crosstab

Description

The actuate.xtabanalyzer.Crosstab class represents a cross tab report element.

Constructor

Syntax

actuate.xtabanalyzer.Crosstab( )

Constructs a new Crosstab object.

Function summary

Table 5-3 lists actuate.xtabanalyzer.Crosstab functions.

actuate.xtabanalyzer.Crosstab.addDimension

Syntax

void Crosstab.addDimension(actuate.xtabanalyzer.Dimension dimension)

Adds a dimension to the cross tab object.

Parameters

dimension

actuate.xtabanalyzer.Dimension object.

Example

This example adds a date-based, multi-level dimension to a cross tab.

function addDimension( ){
// Create a dimension for dates in the first column
  var dimension = new actuate.xtabanalyzer.Dimension( );
  dimension.setIndex(0);
  dimension.setAxisType(actuate.xtabanalyzer.Dimension.COLUMN_AXIS_TYPE);
  dimension.setDimensionName("dates");
 
// Create levels using levels from the data cube.
  var level = new actuate.xtabanalyzer.Level( );
  level.setLevelName("year");
  dimension.addLevel(level);
  var level = new actuate.xtabanalyzer.Level( );
  level.setLevelName("quarter");
  dimension.addLevel(level);
 
// Add the dimension to the cross tab.
  crosstab.addDimension(dimension);
  crosstab.submit( );
}

actuate.xtabanalyzer.Crosstab.addMeasure

Syntax

void Crosstab.addMeasure(actuate.xtabanalyzer.Measure measure, integer options)

Adds a measure to the cross tab object.

Parameters

measure

actuate.xtabanalyzer.Measure object.

options

The options for the add measure operation. These options distinguish the function call’s origin, which can be from another dialog or directly from the Actuate JavaScript API.

Example

This example adds a measure to a cross tab.

function addMeasure( ){
//Create a measure for revenue organized by date and product line.
  var measure = new actuate.xtabanalyzer.Measure( );
  measure.setIndex(1);
  measure.setMeasureName("Quarter Rate");
  measure.setExpression("[revenue]/[revenue_SalesDate/year_Product/PRODUCTLINE]");
 
// Apply the measure to the cross tab
  crosstab.addMeasure(measure);
  crosstab.submit( );
}

In this example, the expression set with setExpression( ) is in easyscript, which is described in Using Actuate BIRT Designer Professional.

actuate.xtabanalyzer.Crosstab.applyOptions

Syntax

void Crosstab.applyOptions(actuate.xtabanalyzer.Options xtOptions, string measureDirection, string rowMirrorStartingLevel, string columnMirrorStartingLevel, string emptyCellValue)

Sets measure direction, empty settings, row mirror starting level, column mirror starting level, and empty cell value.

Parameters

xtOptions

actuate.xtabanalyzer.Options object. Contains a set of xtabanalyzer options. When an actuate.xtabanalyzer.Options object is specified, applyOptions( ) ignores all subsequent parameters.

measureDirection

String. Sets the measure direction.

rowMirrorStartingLevel

String. Sets the mirror starting level empty setting for a row.

columnMirrorStartingLevel

String. Sets the mirror starting level empty setting for a column.

emptyCellValue

String. Sets the value of an empty cell.

actuate.xtabanalyzer.Crosstab.
changeMeasureDirection

Syntax

void Crosstab.changeMeasureDirection( )

Switches the measure direction between horizontal and vertical.

Example

This example changes the measure direction.

function changeMeasureDirection( ){
  if( crosstab ){
    crosstab.changeMeasureDirection( );
    crosstab.submit( );
  }
}

actuate.xtabanalyzer.Crosstab.clearFilters

Syntax

void Crosstab.clearFilters(actuate.xtabanalyzer.Level level)

Clears the filters contained within a level.

Parameters

level    

actuate.xtabanalyzer.Level object. The level from which to clear the filters. To clear all filters, do not specify a level.

Example

This example clears the filters from the level filterLevel.

function clearLevelFilters( ){
  if( crosstab ){
    var levelName = "filterLevel";
    crosstab.clearFilters(levelName);
    crosstab.submit( );
  }
}

actuate.xtabanalyzer.Crosstab.drill

Syntax

void Crosstab.drill(actuate.xtabanalyzer.Driller driller)

Drills up or down a dimension level.

Parameters

driller    

actuate.xtabanalyzer.Driller object. The driller object specifies drill conditions on a dimension.

Example

This example drills to a level within a dimension. Any existing drill conditions are replaced.

function drillToDimension( ){
  var driller = new actuate.xtabanalyzer.Driller( );
  driller.setAxisType(actuate.xtabanalyzer.Dimension.ROW_AXIS_TYPE);
//Add the member list to the Driller. Add the Driller to the crosstab.
  driller.addMember(memberVal);
  myCrosstab.drill(driller);
  myCrosstab.submit( );
}

actuate.xtabanalyzer.Crosstab.drillDown

Syntax

void Crosstab.drillDown(actuate.xtabanalyzer.Driller driller)

Drills down a dimension level. This method updates the drill conditions specified in the driller object and leaves all other conditions in place.

Parameters

driller

A drill condition object.

Example

This example drills down a level within a dimension. Any existing drill conditions are updated.

function drillToDimension( ){
  var driller = new actuate.xtabanalyzer.Driller( );
  driller.setAxisType(actuate.xtabanalyzer.Dimension.ROW_AXIS_TYPE);
//Add the member list to the Driller. Add the Driller to the crosstab.
  driller.addMember(memberVal);
  myCrosstab.drillDown(driller);
  myCrosstab.submit( );
}

actuate.xtabanalyzer.Crosstab.drillUp

Syntax

void Crosstab.drillUp(actuate.xtabanalyzer.Driller driller)

Drills up a dimension level. This method updates the drill conditions specified in the driller object and leaves all other conditions in place.

Parameters

driller

A drill condition object.

Example

This example drills up a level within a dimension. Any existing drill conditions are updated.

function drillToDimension( ){
  var driller = new actuate.xtabanalyzer.Driller( );
  driller.setAxisType(actuate.xtabanalyzer.Dimension.ROW_AXIS_TYPE);
//Add the member list to the Driller. Add the Driller to the crosstab.
  driller.addMember(memberVal);
  myCrosstab.drillUp(driller);
  myCrosstab.submit( );
}

actuate.xtabanalyzer.Crosstab.editMeasure

Syntax

void Crosstab.editMeasure(actuate.xtabanalyzer.Meaure Measure, integer opts)

Edits a measure in the Computed Measure view.

Parameters

Measure

actuate.xtabanalyzer.Measure object.

opts

Integer. Options for the editMeasure function. These options distinguish the function call’s origin, which can be from another dialog or directly from the Actuate JavaScript API.

Example

This example edits a measure.

function editComputedMeasure( ){
  if( crosstab ){
// Create a measure object, and specify the measure to edit.
    var measure = new actuate.xtabanalyzer.Measure( );
    measure.setMeasureName("measureName");
    
// Set the new value of the measure expression.
      measure.setExpression("measureExpression");
    
// Add the new measure to the crosstab.
    crosstab.editMeasure(measure);
    crosstab.submit( );
  }      
}

actuate.xtabanalyzer.Crosstab.getBookmark

Syntax

string Crosstab.getBookmark( )

Returns the bookmark that is associated with the cross tab element.

Returns  

String. The cross tab bookmark.

Example

The following code retrieves the bookmark that is associated with the Crosstab object.

function getCrosstabBookmark( ){
  var crosstabBookmark = crosstab.getBookmark( );
  if( !crosstabBookmark ){
    alert( "No cross tab bookmark found!" )
    return null;
  }
 
  return crosstabBookmark;
}

actuate.xtabanalyzer.Crosstab.getColumn

Syntax

string[ ] Crosstab.getColumn(integer columnIndex)

Returns the table data by column index.

Parameters  

columnIndex

Integer. The column index, starting with 1.

Returns

String[ ]. An array of string values. This function returns null when the value of columnIndex is out of range. This function only returns data from the current visible page.

Example

The following code retrieves data from a data column.

function getColumnData(index,value){
  var columnData = crosstab.getColumn(index);
  if( !columnData ){
    alert( "Invalid column index!" )
    return null;
  }
 
  return columnData[value];
}

actuate.xtabanalyzer.Crosstab.getData

Syntax

Array Crosstab.getData(boolean forceReparse)

Returns the data in a cross tab.

Parameters

forceReparse

Boolean. Forces a cache refresh when true.

Returns

Array. The array of string values in the cross tab.

actuate.xtabanalyzer.Crosstab.getHtmlDom

Syntax

HtmlElement Crosstab.getHtmlDom( )

Returns the HTML element DOM object.

Returns

HtmlElement.

Example

The following code retrieves the DOM object and uses the DOM object to retrieve an element within the document.

function getContainer(containerName){
  var HTMLDom = crosstab.getHtmlDom( );
  var container = HTMLDom.getElementById(containerName);
 
  return container;
}

actuate.xtabanalyzer.Crosstab.getPageContent

Syntax

actuate.xtabanalyzer.PageContent Crosstab.getPageContent( )

Returns the page content of the current page that this cross tab belongs to. This function returns the same information as XTabAnalyzer.getCurrentPageContent( ).

Returns

actuate.xtabanalyzer.PageContent. The report content.

Example

This example retrieves the page content.

function retrievePageContent( ){
  crosstab.getPageContent( );
}

actuate.xtabanalyzer.Crosstab.getRow

Syntax

string[ ] Crosstab.getRow(integer rowIndex)

Returns table data based on row index.

Parameters  

rowIndex

Integer. The row index, starting with 1.

Returns

String[ ]. An array of string values. This function returns null when the value of rowIndex is out of range. This function only returns data from the current visible page.

Example

The following code retrieves data from a data row.

function getRowData(index,value){
  var rowData = crosstab.getRow(index);
  if( !rowData ){
    alert( "Invalid row index!" )
    return null;
  }
 
  return rowData[value];
}

actuate.xtabanalyzer.Crosstab.getType

Syntax

string Crosstab.getType( )

Returns the report element type.

Returns

String containing the value "Crosstab".

actuate.xtabanalyzer.Crosstab.hideDetail

Syntax

void Crosstab.hideDetail(string levelName)

Hides details of the specified level.

Parameters  

levelName

String. The dimension level full name.

Example

This example hides lower level details in a level.

function hideDetail( ){
  if(crosstab){
    var levelName = "rollLevelName";
    crosstab.hideDetail(levelName);
    crosstab.submit( );
  }
}

actuate.xtabanalyzer.Crosstab.pivot

Syntax

void Crosstab.pivot( )

Pivots the crosstab.

Example

This example pivots a crosstab.

function pivot(crosstab){
  crosstab.pivot( );
  crosstab.submit( );
}

actuate.xtabanalyzer.Crosstab.removeDimension

Syntax

void Crosstab.removeDimension(object dimension, integer axisType, integer[ ] levels)

Removes a dimension from the cross tab.

Parameters

dimension

actuate.xtabanalyzer.dimension object, or a dimension index or a dimension name. The dimension to remove.

axisType

Integer. The dimension axis type. Axis type can be one of the following values:

n  
n  

levels

An array of actuate.xtabanalyzer.Level objects, a level index array, or a level name array.

Example

This example removes a dimension with several layers. The level names are in a text control named levelNames and are separated by semicolons.

function removeDimension( ){
  if(crosstab){
    var dimensionName = "dimensionName";
    var levelName ="levelName";
    crosstab.removeDimension(dimensionName,null,levelNames);
    crosstab.submit( );
  }
}

actuate.xtabanalyzer.Crosstab.reorderDimension

Syntax

void Crosstab.reorderDimension(actuate.xtabanalyzer.Dimension dimension, integer axisType, integer newIndex, integer newAxisType)

Reorders a dimension within a cross tab. This function can change a dimension’s index or axis type.

Parameters

dimension

actuate.xtabanalyzer.dimension object, or a dimension index or a dimension name. The dimension to reorder.

axisType

Integer. The dimension axis type. Axis type can be one of the following values:

n  
n  

newIndex

The new index for the dimension.

newAxisType

The new axis type.

Example

This example changes the index and axis type of a dimension.

function changeDimensionOrder( ){
  var dimensionIndex = 5;
  var newDimensionIndex = 2;
  
  var axisType = actuate.xtabanalyzer.Dimension.ROW_AXIS_TYPE;
  var newAxisType = actuate.xtabanalyzer.Dimension.COLUMN_AXIS_TYPE;
  crosstab.reorderDimension(dimensionIndex, axisType, newDimensionIndex, newAxisType);
  crosstab.submit( );
}

actuate.xtabanalyzer.Crosstab.removeMeasure

Syntax

void Crosstab.removeMeasure(actuate.xtabanalyzer.Measure measure)
void Crosstab.removeMeasure(integer measure)
void Crosstab.removeMeasure(string measure)

Removes a measure from the cross tab.

Parameters

measure

actuate.xtabanalyzer.measure object, index, or name. The measure to remove.

Example

This example removes a measure from a cross tab.

function removeMeasure( ){
  var measureName = "measureName";
  crosstab.removeMeasure(measureName);
  crosstab.submit( );
}

actuate.xtabanalyzer.Crosstab.reorderMeasure

Syntax

void Crosstab.reorderMeasure(actuate.xtabanalyzerMeasure measure,
  integer newIndex)
void Crosstab.reorderMeasure(integer measure,integer newIndex)
void Crosstab.reorderMeasure(string measure,integer newIndex)

Reorders a measure within a cross tab.

Parameters

measure

actuate.xtabanalyzer.Measure object, or a measure index or a measure name. The measure to reorder.

newIndex

The new index for the measure.

Example

This example reorders a measure.

function changeMeasureOrder( ){
  var index = 6;
  var newIndex = 3;
                          
  crosstab.reorderMeasure(index,newIndex);
  crosstab.submit( );
}

actuate.xtabanalyzer.Crosstab.setFilters

Syntax

void Crosstab.setFilters(actuate.xtabanalyzer.Filter[ ] filters)

Sets an array of filters for the cross tab.

Parameters

filters

Array of actuate.xtabanalyzer.Filter objects.

Example

This example creates a filter object and then places it into the cross tab.

function filterLevel( ){
  var levelName = "levelName";
  var operator = "BETWEEN";
  var filterValue = "20000;50000";
  var filter = new actuate.xtabanalyzer.Filter(levelName, operator);
  filter.setValues(filterValue.split(";"));
  crosstab.setFilters(filter);
  crosstab.submit( );
}

actuate.xtabanalyzer.Crosstab.setSorters

Syntax

void Crosstab.setSorters(actuate.xtabanalyzer.Sorter[ ] sorters)

Sets an array of sorters for the cross tab.

Parameters

sorters

Array of actuate.xtabanalyzer.Sorter objects.

Example

This example creates a sorter and adds it to the cross tab.

function sortLevel( ){
  var levelName = "levelName";
  var sortAscending = true;
  var sorter = new actuate.xtabanalyzer.Sorter(levelName);
  sorter.setAscending(sortAscending);
  crosstab.setSorters(sorter);
  crosstab.submit( );
}

actuate.xtabanalyzer.Crosstab.setTotals

Syntax

void Crosstab.setTotals(actuate.xtabanalyzer.GrandTotal[ ] grandTotals, actuate.xtabanalyzer.SubTotal[ ] subTotals)

Sets totals for the cross tab. To set a subtotal, make the first parameter null.

Parameters

grandTotals

Array of actuate.xtabanalyzer.GrandTotal objects.

subTotals

Array of actuate.xtabanalyzer.SubTotal objects.

Example

This example adds a grand total to a cross tab.

function addGrandTotal( ){
  var grandTotal = new actuate.xtabanalyzer.GrandTotal( );
  grandTotal.setAxisType(
    actuate.xtabanalyzer.Dimension.ROW_AXIS_TYPE);
  
  var total = new actuate.xtabanalyzer.Total( );
  total.setMeasureIndex(1);
  total.setAggregationFunction("SUM");
  total.setEnabled(true);
  grandTotal.addTotal(total);
  
  crosstab.setTotals(grandTotal);
  crosstab.submit( );
}

actuate.xtabanalyzer.Crosstab.showDetail

Syntax

void Crosstab.showDetail(string axisType, Dimension dimension)

Shows a level of detail within a cross tab.

Parameters

axisType

String. The dimension axis type. Axis type can be one of the following values:

n  
n  

dimension

An actuate.xtabanalyzer.Dimension object, index, or name that indicates the dimension information to show.

Example

This example uses showDetail to expose extra detail on a level.

function showDetail( ){
  var axisType = actuate.xtabanalyzer.Dimension.ROW_AXIS_TYPE;
  crosstab.showDetail(axisType);      
  crosstab.submit( );
}

actuate.xtabanalyzer.Crosstab.submit

Syntax

void Crosstab.submit(function callback)

Applies the changes made to this element. This is an asynchronous operation.

Parameters

callback

Function. An optional function called when submit( ) completes. This function receives the current XTabAnalyzer object as a parameter.

Example

This example uses submit( ) to confirm changes to the cross tab.

function showDetail(crosstab){
  var axisType = actuate.xtabanalyzer.Dimension.ROW_AXIS_TYPE;
  crosstab.showDetail(axisType);      
  crosstab.submit( );
}

(c) Copyright Actuate Corporation 2011