Imagine a world without sentences like "Uh .. sure JFreeChart supports this feature, but it is not exposed in the Report Designer".
Well, with Pentaho Reporting 3.7 you can live in that world right now.
All chart expressions now have the "Chart Post-Processing Script Language" and "Chart Post-Processing Script" properties. The "Script Language" property defines the scripting language in which the actual script is written (so that the more masochistic ones among our users can continue to use JavaScript all day long) and the "Script" property itself then contains the script.
Like the well-known BeanShell- and BSH-Expressions, a set of predefined variables grants access to the outside world.
"chart" is the fully initialized JFreeChart object. "dataRow" grants access to the values of the other named expressions and the data-table "runtime" grants access to the current ExpressionRuntime instance. The runtime itself allows the use of the ResourceBundles (for internationalization) and grants access to the report's defined DataFactories (to get more data from the outside world).
A simple post processing script could look like this (Language = BeanShell):
import java.util.Date;
chart.setTitle("My Title: " + new Date());
But with the ability to fire queries, you can easily add your own line or item marker to explain significant details or enrich the plots with your own styling.
Your imagination (and coding abilities) are the limit now!
7 comments: