InetSoft Product Information: General Chart Properties

The following sections present the top-level components required to build a chart. These include the DataSet object, which encapsulates data from a JavaScript array, and the EGraph object, which represents the global chart object. The TextSpec, AxisSpec, LegendSpec, and TitleSpec objects are used by various other components to set formatting for text, axes, legends, and titles.

DataSet

The Dataset object contains the aggregated values that are displayed on the graph. It has the form of a two-dimensional array, where each column represents a distinct measure. You can specify the Dataset by one of the following methods:

  1. In Report Designer or Visual Composer, set the chart binding using the Chart Editor. (See Binding Data to a Chart Element in the Report Designer, or Creating a Chart in the Viewsheet.)
  2. In Report Designer or Visual Composer script, pass a JavaScript array to the DefaultDataSet constructor. dataset = DefaultDataSet(arr)
  3. In Visual Composer script, assign a Worksheet Data Block (e.g., 'LimitedProducts') to the Dataset. dataset = LimitedProducts;
  4. In Report Designer script, assign a query result (e.g., 'sales by state') to the Data property of the chart. This implicitly sets the Dataset as well.

data = runQuery("sales by state");

The Dataset object is also accessible for reading. See the getData() method for more information.

Example (Setting the Dataset):

importPackage(inetsoft.graph)
importPackage(inetsoft.graph.data)
importPackage(inetsoft.graph.element)
importPackage(inetsoft.graph.scale)
 
var arr = [["State","Quantity"], ["CA",200], ["NY",3000]];
dataset = DefaultDataSet(arr)
graph = new EGraph();
var elem = new IntervalElement("State", "Quantity");
graph.addElement(elem);

Full Name

inetsoft.graph.data.DataSet

DataSet.getData(column,row)

Returns the value in the DataSet object specified by the column and row indices. The first column (index 0) contains the X-axis labels.

Parameters

 column
 Column index of value to return
 row
 Row index of value to return

For example, consider a chart with two datasets (measures), as shown below:

Use dataset.getData(j,i) with row index i and column index j to access these plotted values. The DataSet.getRowCount() and DataSet.getColCount() functions provide the number of rows and columns of summarized data.

var str = "";
// Loop through rows
for (var i = 0; i < dataset.getRowCount(); i++) {
  str = "";
  // Loop through columns
  for (var j = 0; j < dataset.getColCount(); j++) {
   str += dataset.getData(j, i) + ",";
  }
  // Output the results
  log(str);  // Report Designer
  alert(str); // Visual Composer
}
The following output is written by the log() function (for Report Designer) to the Console window:
Sun May 31 00:00:00 EDT 2009, 1.0, 4.0,
Mon Jun 01 00:00:00 EDT 2009, 2.0, 5.0,
Tue Jun 02 00:00:00 EDT 2009, 3.0, 6.0,
Wed Jun 03 00:00:00 EDT 2009, 4.0, 7.0,

The values in the first column (e.g., Sun...2009, Mon...2009, etc.) are the dates on the X-axis, while the second and third columns represent the two datasets (Measure 1 and Measure 2).

demo
Read how InetSoft saves money and resources with deployment flexibility.

Previous: Style Chart API - Object Hierarchy