www.projectwizards.net/

Merlin – Do a bit of magic in reports

on 8. August 2011

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

Tags: , , ,

Written by Vicky Stamatopoulou
Vicky Stamatopoulou works at ProjectWizards. She contributes to the MacPM.net blog, Merlin user forums, or other web spaces of ProjectWizards. The content provided is about Merlin or Mac usage, documentation, AppleScripting, or customization. Google+

12 Comments »

  1. Pingback by Merlin – do a bit of magic in reports – part III » MacPM (September 2, 2011 @ 1:30 pm

    [...] Merlin – do a bit of magic in reports – part III [...]

  2. Pingback by MERLIN – DO A BIT OF MAGIC IN REPORTS – PART VII » MacPM (November 10, 2011 @ 11:26 pm

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

  3. Pingback by Merlin – Do a bit of magic in reports – Part VIII » MacPM (December 7, 2011 @ 12:55 pm

    [...] Merlin – Do a bit of magic in reports – Part VIII [...]

  4. Pingback by Merlin – Do a bit of magic in reports – Part IX » MacPM (February 22, 2012 @ 10:59 pm

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

  5. Pingback by Merlin – Do a bit of Magic in Reports – Part XV » MacPM (April 12, 2013 @ 12:10 pm

    [...] Merlin – Do a bit of Magic in Reports – Part XV [...]

  6. Pingback by Merlin – Do a bit of Magic in Reports – Part XVII » MacPM (April 12, 2013 @ 12:10 pm

    [...] Merlin – Do a bit of Magic in Reports – Part XVII [...]

  7. Pingback by Merlin – Do a bit of magic in reports – PART XXII » MacPM (May 3, 2013 @ 1:59 pm

    [...] Merlin – Do a bit of magic in reports – PART XXII [...]

  8. Pingback by Merlin - Do a bit of magic in Merlin reports – PART XX » MacPM (May 3, 2013 @ 2:35 pm

    [...] Merlin – Do a bit of magic in Merlin reports – PART XX [...]

  9. Pingback by Merlin – Do a bit of magic in Merlin reports – PART XXII » MacPM (May 23, 2013 @ 7:36 pm

    [...] Map a status or flag information to a graphic file [...]

  10. Pingback by Merlin – Do a bit of magic in Merlin reports – PART XXIII » MacPM (June 12, 2013 @ 9:23 pm

    [...] Map a status or flag information to a graphic file [...]

  11. Pingback by Merlin – Do a little bit of magic in Merlin reports – part XXVI » (May 20, 2014 @ 2:58 pm

    […] Map a status or flag information to a graphic file […]

  12. Pingback by Merlin – Do a little bit of magic in Merlin reports – part XXVII » (May 20, 2014 @ 2:58 pm

    […] Map a status or flag information to a graphic file […]

RSS feed for comments on this post. TrackBack URL

Leave a comment