Setting chart options through scripting
The before functions are called after BIRT generates the static JavaScript options, which are based on the chart’s data and formatting options set in the chart builder. The beforeGeneration( ) function is the first function called after the generation of the static JavaScript options, but before a chart object is created. Use beforeGeneration( ) to add chart options that Highcharts provides, but that are not available through the chart builder’s format page.
For example, Highcharts provides a credits option to display a credits label in the chart. To add this label to the lower right corner of the chart (the default position), you would write code as follows:
beforeGeneration: function(options)
options.credits = {
enabled: true,
text: 'Acme Inc.'
As the code example shows, beforeGeneration( ) receives an options object. You use this options object to configure chart options. When you type the word, options, followed by a period (.), the script editor displays a list of options, as shown in Figure 15-11. Click an option to view summary information about it. Double-click an option to add it to your code.
Figure 15-11  
The other before functions also receive an options object, for example, axisOptions or seriesOptions, which is specific to the associated chart element. Your code typically makes changes to the options object to change the appearance of an axis, series, or data point. The following code example shows how to use beforeDrawSeries( ) and the seriesOptions object to display a legend for all series types except pie:
beforeDrawSeries: function(series, seriesOptions, chart, seriesIndex)
  if ( series.type == "pie" )
    seriesOptions.showInLegend = false;
    seriesOptions.showInLegend = true;
All the before functions, except beforeGeneration( ), also receive the chart object, which represents the chart that is created based on the original static options and any options created with beforeGeneration( ). With the exception of beforeGeneration( ), your code can query the chart object to determine what changes to make to the options. You typically use these before functions to dynamically add, change, or remove a chart element based on specified conditions. Your code, however, should not make any changes to the chart object itself because it is a temporary object. Changes to this temporary chart are discarded along with the chart.
After the before functions run, BIRT passes the original options and your scripted options into a constructor to create a new chart object. The afterRendering( ) function provides the final opportunity to make changes to this new chart object. To get the chart object, use the getCore( ) method, as shown in the following code snippet:
afterRendering: function(Chart)

Additional Links:

Copyright Actuate Corporation 2012