Actuate JavaScript API classes : Class actuate.report.Chart

Class actuate.report.Chart

Description

Provides functions to operate on a Chart element, such as changing its format or retrieving data from specific elements.

Constructor

The actuate.report.Chart object is created when actuate.report.Content.getChartByBookmark( ) is called.

Function summary

Table 4-25 lists actuate.report.Chart functions.

Submits all the asynchronous operations that the user has requested on this report and renders the chart component on the page.

actuate.report.Chart.clearFilters

Syntax

void Chart.clearFilters(string columnName)

Clears the filters of a given column.

Parameters

columnName

String. The name of the column.

Example

This example clears existing filters from the PRODUCTLINE column of a chart and changes the chart title.

function resetFilter(bchart){
  bchart.clearFilters("PRODUCTLINE");
  bchart.setChartTitle("Orders By Country");
  bchart.submit( );
}

actuate.report.Chart.drillDownCategory

Syntax

void Chart.drillDownCategory(string categoryData)

Drills down into a chart by category.

Parameters

categoryData

String. The name of the data category to drill down to.

actuate.report.Chart.drillDownSeries

Syntax

void Chart.drillDownSeries(string seriesName)

Drills down into a chart by series.

Parameters

seriesName

String. The name of the data series to drill down to.

actuate.report.Chart.drillUpCategory

Syntax

void Chart.drillUpCategory( )

Drills up into a chart by one data category level.

actuate.report.Chart.drillUpSeries

Syntax

void Chart.drillUpSeries( )

Drills up into a chart by one series level.

actuate.report.Chart.getBookmark

Syntax

string Chart.getBookmark( )

Returns the chart’s bookmark name.

Returns

String. The chart’s bookmark name.

Example

This example sets the chart’s title to the bookmark name.

function titleBookmark(bchart){
  bchart.setChartTitle(bchart.getBookmark( ));
  bchart.submit( );
}

actuate.report.Chart.getHtmlDom

Syntax

HTMLElement Chart.getHtmlDom( )

Returns the HTML element for this chart.

Returns

HTMLElement.

Example

This example displays the HTML DOM element for this chart inside a red border.

function showHtmlDom(myChart){
  var domNode = myChart.getHtmlDom( );
  var box = document.createElement('div');
  box.style.border = '2px solid red';
  var label = document.createElement('h2');
  label.innerHTML = 'The HTML DOM:';
  box.appendChild(label);
  box.appendChild(domNode);
  document.body.appendChild(box);
}

actuate.report.Chart.getPageContent

Syntax

actuate.viewer.PageContent Chart.getPageContent( )

Returns the content of the page to which this chart belongs.

Returns

actuate.report.PageContent. The report content.

Example

This example displays the viewer ID of the page content in an alert box.

function showViewID(myChart){
  var pageContent = myChart.getPageContent( );
  var pageViewerID = pageContent.getViewerId( );
  alert (pageViewerID);
}

actuate.viewer.Chart.getType

Syntax

string Chart.getType( )

Returns the chart’s report element type.

Returns

String. This method returns the string "Chart" when the type is actuate.report.Chart.CHART and the string "Flash Chart" when the type is actuate.report.Chart.FLASH_CHART.

Example

This example displays the chart type in an alert box.

alert ("Chart is of type " + myChart.getType( ));

actuate.report.Chart.hide

Syntax

void Chart.hide( )

Hides this element.

Example

To hide the chart bchart, use code similar to the following:

alert("Hiding chart" + bchart.getBookmark( ));
bchart.hide( );
bchart.submit( );

actuate.report.Chart.setChartTitle

Syntax

void Chart.setChartTitle(string title)

Sets the title for this chart element.

Parameters

title

String. The title for the chart.

Example

This example sets the chart’s title to the bookmark name.

function titleBookmark(bchart){
  bchart.setChartTitle(bchart.getBookmark( ));
  bchart.submit( );
}

actuate.report.Chart.setDimension

Syntax

void Chart.setDimension(actuate.report.Chart dimension)

Sets the number of dimensions for the Chart element. The chart dimension only works if supported by the chart’s type. A 3D chart does not support multiple value axes. Remove all of the y-axes after the first before converting a chart to 3D.

Parameters

dimension

actuate.report.Chart. The number of dimensions in which to display the chart element. Supported values are 2D and 2D with Depth. The constants defined for this argument are:

n  
n  

Example

This example changes the chart bchart’s dimension to 2D with depth.

bchart.setChartTitle(bchart.getBookmark( ) + ": 2D with Depth");
bchart.setDimension(actuate.report.Chart.CHART_DIMENSION_2D_WITH_DEPTH );
bchart.submit( );

actuate.report.Chart.setFilters

Syntax

void Chart.setFilters(actuate.data.Filter filter)
void Chart.setFilters(actuate.data.Filter[ ] filters)

Applies filters to this chart element. To apply more than one filter to a chart element, call this function multiple times, once for each filter object.

Parameters

filter

An actuate.data.Filter object. A single filter condition to apply to this chart element.

filters

An array of actuate.data.Filter objects. Filter conditions to apply to this chart element.

Example

This example applies a filter to the chart and changes the chart’s title to reflect the filter.

function chartFilter(bchart){
  var filter = new actuate.data.Filter("PRODUCTLINE", "=", "Trucks and Buses");
  var filters = new Array( );
  filters.push(filter);
  bchart.setFilters(filters);
  bchart.setChartTitle("Orders By Country (Trucks and Buses)");
  bchart.submit( );
}

actuate.report.Chart.setSize

Syntax

void Chart.setSize(integer width, integer height)

Sets the width and height of the chart element displayed.

Parameters

width

Integer. The width in pixels

height

Integer. The height in pixels

Example

To set the chart bchart to be 600 pixels wide by 800 pixels high, use code similar to the following:

alert("Resizing " + bchart.getBookmark( ) + " to 600x800");
bchart.setSize(600,800);
bchart.submit( );

actuate.report.Chart.setSubType

Syntax

void Chart.setSubType(string chartType)

Sets a subtype for this chart element. When the report calls submit( ), the report redraws the chart element as the requested type.

Parameters

chartType

String. The format in which to redraw the chart element. The constants that define the chart subtypes are:

n  
n  
n  

Example

To change the subtype of the chart bchart to side-by-side, use code similar to the following:

bchart.setChartTitle("Side by Side Chart");
bchart.setSubType(actuate.report.Chart.CHART_SUBTYPE_SIDEBYSIDE);
bchart.submit( );

actuate.report.Chart.show

Syntax

void Chart.show( )

Shows this element.

Example

To reveal the hidden chart bchart, use code similar to the following:

alert("Showing chart" + bchart.getBookmark( ));
bchart.show( );
bchart.submit( );

actuate.report.Chart.submit

Syntax

void Chart.submit(function callback)

Submits all the asynchronous operations for this chart. The submit( ) function triggers an AJAX request for all asynchronous operations. When the server finishes the processing, it returns a response and the results are rendered on the page in the chart container.

Parameters

callback

Function. The function to execute after the asynchronous call processing is done.

Example

This example sets the chart’s title to the bookmark name and pops up an alert box after calling submit( ).

function titleBookmark(bchart){
  bchart.setChartTitle(bchart.getBookmark( ));
  bchart.submit(alert("Title Changed"));
}

(c) Copyright Actuate Corporation 2011