Environment for a charting application
The minimum requirements for creating a basic charting application are:
*The BIRT charting run-time engine
*The BIRT run-time engine, for an application that runs within the BIRT report context
*Java Development Kit 1.6.0 or later
*Deployment Java archive (.jar) files
To develop or run a Java application that incorporates a BIRT chart, you need to include certain JAR files in the Java CLASSPATH. To be certain that the CLASSPATH includes all the JAR files your application needs, include the following files in the CLASSPATH:
*All the JAR files in DeploymentRuntime/ChartEngine
*Any custom extension plug-in JAR files that you use
Typically, a charting application does not use the functionality from every JAR file in the ChartEngine folder, but having extra JAR files in the CLASSPATH does not affect the performance or size of an application, so the easiest technique is to include them all.
Configuring the chart engine run-time environment
An application using the BIRT Chart Engine can run either in the context of the BIRT Report Engine or as a stand-alone application. To deploy charts in a BIRT report, use the BIRT Report Engine. A stand-alone application does not use the BIRT Report Engine. Either application produces and consumes charts within itself or passes the chart structure and data to another application.
Verifying the environment for a charting application
Listing 6‑1 illustrates a very basic charting application. The output of this program is a file called myChart.chart, which contains several hundred lines of XML code. This code defines a basic chart with no data, no labels, no series, and no titles. Although this output does not represent a useful chart, compiling and running the program verifies that the environment is configured correctly for a charting application.
Listing 6‑1 Basic charting application
import java.io.*;
import org.eclipse.birt.chart.api.ChartEngine;
import org.eclipse.birt.chart.model.*;
import org.eclipse.birt.chart.model.impl.*;
import org.eclipse.birt.core.framework.PlatformConfig;
 
public class MyFirstChartProg {
 
public static void main( String[ ] args ) {
PlatformConfig pf = new PlatformConfig();
pf.setProperty("STANDALONE", true);
ChartEngine ce = ChartEngine.instance(pf);
Chart myChart = ChartWithAxesImpl.create();
Serializer si = SerializerImpl.instance();
try {
si.write( myChart,new FileOutputStream(
new File ( "C:/temp/myChart.chart" ) ) );
} catch ( IOException e ) { e.printStackTrace( ); }
}
}