CT.2 Modifying a Chart Data Binding

The bindingInfo property of a Chart provides access to the data binding options in the Chart's 'Data Binding' dialog box. This includes the binding of fields to the X-axis, Y-axis, and VisualFrames (Color, Shape, etc.), as well as grouping and summarization settings.

Walkthrough

In the following example, you will bind a chart to the 'All Sales' query, set the axis bindings, define a subseries, and set grouping and summarization. Follow the steps below:

1. Create a new report or Viewsheet. (For a Viewsheet, select the 'All Sales' query as the data source.)

2. Add a new Chart element to the report or Viewsheet.

Note: bindingInfo modifications must be made prior to query execution. Therefore, attach bindingInfo scripts to the onLoad Handler.

3. Open the Script Editor for the onLoad Handler:

a. For a report, right-click an empty area of the report and select 'Script' from the context menu.

b. For a Viewsheet, press the 'Options' button in the toolbar to open the 'Viewsheet Options' dialog box, then click the Script tab.

4. In the Script Editor, enter the commands below to bind the chart to the 'All Sales' query.

For a report:

Chart1.query = "All Sales";

For a Viewsheet:

Note: The Viewsheet must be based on the 'All Sales' query.

Chart1.data = "All Sales";

5. Specify query fields to bind to the X-axis ('Company') and Y-axis ('Total'):

Chart1.bindingInfo.xFields = [["Company",Chart.STRING]];

Chart1.bindingInfo.yFields = [["Total",Chart.NUMBER]];

6. Set the aggregation/summarization method:

Chart1.bindingInfo.setFormula("Total",Chart.MAX_FORMULA)

7. Set the desired grouping options (e.g., top-N filtering):

Chart1.bindingInfo.setTopN("Company",5)

Chart1.bindingInfo.setTopNReverse("Company",false)

Chart1.bindingInfo.setTopNSummaryCol("Company",

   "Max(Total)");

8. Specify the query fields to bind to a “VisualFrame,” (i.e., for visual coding as subseries):

Chart1.bindingInfo.setColorField("Employee",Chart.STRING);

9. Close the Editor, an preview the report.

The complete script is shown below:

Chart1.query = "All Sales"; // report

Chart1.data = "All Sales";  // Viewsheet

 

Chart1.bindingInfo.xFields = [["Company",Chart.STRING]];

Chart1.bindingInfo.yFields = [["Total",Chart.NUMBER]];

Chart1.bindingInfo.setFormula("Total",Chart.MAX_FORMULA)

Chart1.bindingInfo.setTopN("Company",5)

Chart1.bindingInfo.setTopNReverse("Company",false)

Chart1.bindingInfo.setTopNSummaryCol("Company","Max(Total)");

Chart1.bindingInfo.setColorField("Employee",Chart.STRING);

 

See Also

bindingInfo.xFields, bindingInfo.yFields

bindingInfo.setFormula(col, formula, binding)

bindingInfo.setTopN(col,N), bindingInfo.setTopNReverse(col,boolean)

bindingInfo.setTopNSummaryCol(col,agg)

bindingInfo.setColorField(col, type)

Binding Data to a Chart Element, in Report Design, for information on the 'Data Binding' dialog box.

Modifying a Chart Element using API Functions, to modify other aspects of an existing chart.

Creating a Chart Using API Functions, to script a chart from the ground-up.

Appendix CR.1.6  , The Chart bindingInfo Property, for all binding properties.

<< CT.1.3 Modifying Axis Properties © 1996-2013 InetSoft Technology Corporation (v11.4) CT.3 Modifying a Chart Element using API Functions >>