In this recipe, we will guide you through the steps required to fetch data from a MongoDB instance and render a Pentaho chart into the report. Similar to the previous recipe, we will be using a Pentaho Data Integration transformation to get order summary data to populate the chart. This data will consist of total order values grouped by country.
chapter5-getorders-summary.ktr
transformation, as done in the previous recipe. (This file is provided as source code along with this book.)You will notice that the Orders data is broken down into countries this time. We have used a simple Group By step in the transformation to do this.
Now that we have our data, we can use it to populate a simple bar chart in the Pentaho Report:
The following screenshot appears:
If everything goes well, you will be looking at a simple chart in the Report Header band. Before we finish up, we can set a couple of common options to make the chart look a little more pleasing to the eye:
The following screenshot shows the final output chart:
Rendering a chart to a report is similar to adding tabular data to a report. The only real difference is that all the report data is rendered in a single chart component, so we place our chart into the Report Header band. The report header band is only executed once per report. If we were to place the chart into the Details band, then we would be seeing the same chart for every row in the database.
Reporting charts have many options. Feel free to open the chart component and play around with the other options available to you.