In this example, you will use scripted
queries as the data source.
- In the Data Source perspective, from the Data Source list, click SCRIPTING Queries, and then click scriptable over scripting twice.
- In the Datasources panel, in the Name column, enter chartQuery for the first data source, and tableQuery for the second.
- Add the following script to the Query property for the chartQuery data source:
import org.pentaho.reporting.engine.classic.core.util.TypedTableModel; String[] columnNames = new String[]{ "Country", "Population growth per City [%]" }; Class[] columnTypes = new Class[]{ String.class, Float.class }; TypedTableModel model = new TypedTableModel(columnNames, columnTypes); model.addRow(new Object[]{ new String("Tokyo"), new Float("60") }); model.addRow(new Object[]{ new String("Nice"), new Float("20") }); model.addRow(new Object[]{ new String("London"), new Float("-10") }); model.addRow(new Object[]{ new String("Munich"), new Float("30") }); model.addRow(new Object[]{ new String("Porto"), new Float("10") }); model.addRow(new Object[]{ new String("Brasilia"), new Float("10") }); return model;
- Add the following script to the Query property for the tableQuery data source:
import org.pentaho.reporting.engine.classic.core.util.TypedTableModel; String[] columnNames = new String[]{ "Country", "City", "Population growth per City" }; Class[] columnTypes = new Class[]{ String.class, String.class, Float.class }; TypedTableModel model = new TypedTableModel(columnNames, columnTypes); model.addRow(new Object[]{ new String("Japan"), new String("Tokyo"), new Float("60") }); model.addRow(new Object[]{ new String("France"), new String("Nice"), new Float("20") }); model.addRow(new Object[]{ new String("UK"), new String("London"), new Float("-10") }); model.addRow(new Object[]{ new String("Germany"), new String("Munich"), new Float("30") }); model.addRow(new Object[]{ new String("Portugal"), new String("Porto"), new Float("10") }); model.addRow(new Object[]{ new String("Brazil"), new String("Brasilia"), new Float("10") }); return model;