Merlin – Do a bit of magic in reports

Those of you who have checked our new post series about “Merlin report templates” know by now…

Now let’s do some magic with the reports.

  • What if you want to map a status or flag information to a graphic file?
  • What if you want to be able to define the size of the project image over the options?

What if you want to map a status or flag information to a graphic file?

If your report is an xslt report, just proceed as shown in the “Next due Activities” report for the ‘Status’ and ‘MS’ column.

That means, just do a test for the value you want to check and add an image html tag accordingly:

<xsl:if test="flagStatus = 'red'">
   <img src="rsc/red.png" />
</xsl:if>


Note: red.png, green.png, yellow.png are picture files located in Merlin’s application bundle. Check the dictionary PWReportAdditionalResources in the info.plist of this report template, to see how they will get mapped.

To add your own pictures in your XSLT report, just place them in the /Contents/Resources of the template package.

When your XSLT report gets called, Merlin creates a new temporary folder for this report. It copies all css and picture elements from the /Contents/Resources in a  “rsc” folder within the report folder and renders an index.html based on the Report.xslt. Just right (or ctrl) click your report window and call ‘Reveal HTML file in Finder” to see your temporary report folder:

That means, an image tag in your report.xslt will only work, if it references the picture relative to the ‘rsc’ folder.


If your report is a python/wbl report… just proceed as shown in the “Checklist report” for the checkmark before a checklist item.

 

Which is, you test the value of checklistEntry.isChecked. If it is true, the checked.png image should be rendered.

<wbl:Conditional condition=checklistEntry.isChecked>
 <wbl:Image filename="checked.png" width=15 height=15/>
</wbl:Conditional>

Note: If you would like to use your own pictures, you need to place your images within /Contents/Resources

If you have 2 or three states, you need to define a python method delivering the name of the picture. For an example of how one can do this, just check the “Risk Report” template we have uploaded in the Merlin user forum.

In the wbl file

<wbl:Conditional condition=withFlagStatus><td><wbl:Image filename=flagToImageMapping width=17 height=17/></td></wbl:Conditional>

In the python file

def flagToImageMapping(self):
    status = self.iterItem.flagStatus()
    if status == 1:
       image = "FlagGreen.png"
    if status == 2:
       image = "FlagYellow.png"
    if status == 3:
       image = "FlagRed.png"
    return image

Python / Wbl reports won’t get rendered first in html content and then displayed the way xslt report do. That means, when  inserting an image to your report, there is no need to reference a “rsc”  folder in its path.

What if you want to be able to define the size of the project image over the options?

Please see next and last post in this series