This example builds on Example 2, producing an HTML report that describes a Program with two charts. Because the Program is specified as a parameter, this example report will be able to describe any Program.
This example will focus on the charts. Setting up the HTML template itself is described in more detail in Example 1.
Setting up Parameters
The report template is a straightforward HTML file, with a head section, a body section and some references to the Velocity template language. Lines that start with '#' are Velocity directives, and a number of Velocity variables are pre-defined. Within your HTML markup, refer to Velocity variables by their name, preceded with a '$.'
As in Example 2, issue a Velocity directive to create a variable called $program.
#set($program = $dashboardParameters.getProgram("AuditProject.id1", "Program")) |
Next, initialize the charts:
$dashboardParameters.initChart("Shared Reports/System/Project Reports/Entities in Project by Criticality", "large") $dashboardParameters.initChart("Shared Reports/System/Compliance/Compliance Score in a Project for Children of a Control","large") |
In this case, use the Velocity #set directive to attach the second chart to a variable, $report_1, you can insert into the HTML later.
#set($report_1 = $dashboardParameters.getChart("Shared Reports/System/Compliance/Compliance Score in a Project for Children of a Control")) |
Because the result of the getChart method invocation is assigned to the variable $report_1, place the chart wherever it is needed by simply embedding the Velocity variable in the HTML code. At runtime, the variable reference is replaced with the graphical chart:
$report_1 |
Adding the Charts
For this example, label the charts using Velocity method calls.
<table border='0' width='100%'> |
To display the program name, invoke the getName method on the program variable, just as you invoked the getProgram method on the pre-defined dashboardParameters object.
Example Template
The complete HTML template for this example is:
#set($program = $dashboardParameters.getProgram("AuditProject.id1", "Program")) $dashboardParameters.initChart("Shared Reports/System/Project Reports/Entities in Project by Criticality", "large") |
The next example, Example 4, explains how to include multiple charts in a report.