ChartDirector 6.1 (Java Edition)

The DBTable Class

The ChartDirector API is designed to accept data values as array variables, which is the most flexible approach.

In Java, access to database is commonly through JDBC. Database query results are usually represented by java.sql.ResultSet objects. To use data from database to draw charts, one simply needs to read data from java.sql.ResultSet objects to array variables and pass them to ChartDirector.

To simplify things further, ChartDirector comes with a utility class DBTable. This class accepts java.sql.ResultSet objects as input, and creates arrays representing the columns of the query result. These arrays may then be used by ChartDirector to draw charts, or can be manipulated further (eg. using ChartDirector ArrayMath to compute moving averages, moving standard deviations, curve fitting, etc.)

Because of its convenience, all database examples in this documentation will use the DBTable class to read data from java.sql.ResultSet objects.