RPE & Google Charts Tools to generate charts

In some cases numeric data is much easier to understand when presented as a chart. Rational Publishing Engine does not have a special module for chart generation like BIRT or other specialized reporting tools, but leave open the possibility to generate charts using javascript language and some charting engines.

Such an engine is Google Charts Tools

What are Google Chart Tools?

The Google Chart Tools enable adding live charts into your document.

The advantages of the Google Chart Tools are:

  • A rich gallery of visualizations provided as:
    • Image charts – using a simple URL request to a Google chart server
    • Interactive charts – using a Google developed JavaScript library
  • Simple to use and free

Figure 1: Static Charts

The Google Chart API returns a PNG image of a chart in response to a URL GET or POST request. The API can generate many kinds of charts, from pie or line charts to QR codes and formulas. All the information about the chart that you want, such as chart data, size, colors, and labels, are part of the URL.

To make the simplest chart with the Chart API, you just need a URL that specifies the chart type, the chart data, and the chart size.

Take a look at this simple example:×100&chd=t:60,40&cht=p3&chl=Hello|World

Use Case Scenario

To demonstrate you how RPE deals with chart generating, I’ll consider a simple use case:

Let’s say that we have a list of requirements in DOORS, each requirement having assigned a “Priority” attribute. We want to generate a report with all the requirements and at the end of the document to create a chart that will expose the information about the priority attribute.

The possible values of the “Priority” attribute are: Luxury, Mandatory, Important and Minor importance

Figure 2: DOORS Edit Attribute Dialog

How to customize RPE template in order to generate charts?

In order to extract all the requirements from a DOORS module, we have to create a RPE template, to add a DOORS data source, and then to use a container to iterate through all objects. For each object we need to display Object Heading/ Object Text attribute. To generate the final chart we have to number all the requirements accordingly to each priority. Then insert an image element in the template, and configure the image URL with the customized Google Chart URL.

Step 1: Create RPE template, add DOORS data source

  • open RPE Document Studio
  • create a new template
  • select Data-> Add new Data Source Schema from the main menu. Select DOORS schema to be added.
  • customize DOORS schema if necessary, using DOORS Data Source Discovery wizard

Step 2: Add a container element, and iterate through all the objects

  • drag and drop a container element into the template
  • drag the Module/Object query on that container

Step 3: Add paragraphs elements to display Object Heading and Object Text attributes

  • drag 2 paragraphs into container
  • drag the Object Heading attribute in the first one
  • drag the Object Text attribute in the second one

Step 4: Insert a container to do all the count variables assignments

Figure 3: Set Assignments Editor

Figure 4: Variable Assignments Editor

Figure 5: RPE Template

Step 5: Add an image to the template and create the image URL, using the internal variables values
In our example I will create a simple “pie chart” showing proportional between luxury, mandatory, important and minor attributes.

Image URL:

“×150&chd=t:” + luxuryCount + “,” + mandatoryCount + “,” + importantCount + “,” + minorCount + “&cht=p3&chl=luxury|mandatory|important|minor&chdl=”+luxuryCount+”|”+mandatoryCount+”|”+importantCount+”|”+minorCount

Parameter Description
chs Chart size
chd You can specify values for individual pie chart slices
p3 A three-dimensional pie chart.
chl You can specify labels for individual pie chart slices
chdl Specify legend text in the same order as your data series.

The generated chart will look like this:

Figure 5: Final chart

To add more fancy charts into your document please read more about:

7 Comments to “RPE & Google Charts Tools to generate charts”

  1. Dominique Bontemps says:

    this is great as it is definitively something missing in RPE.
    At this stage, I have just tried to get the chart directly based on an URL but don’t get it.
    – I put the URL×200&chd=t:7,8,5,10&cht=p3&chl=luxury|mandatory|important|minor&chdl=luxuryCount|mandatoryCount|importantCount|minorCount in the Content field. Is this correct (didn’t find a URL field for the IMG element)?
    – do I need to use double quotes for the URL in the content field or not?
    – when running the doc, I get “The source url couldn’t be processed. Connection failed url”.
    Is it some setting to be done on my PC (local install of RPE Doc Studio or do I miss something?
    Thx in advance for your help…Dominique

  2. hategan.oana says:

    Hi Dominique,

    It is correct to put the image URL in the Content field of the Image element.
    The problem with the URL you are trying to use is that the URL should contain the runtime values of the RPE variables luxuryCount, mandatoryCount, importantCount, minorCount.
    If you look at the example created in this blog post, you can see that these four were created as internal RPE variables, and incremented each time a corresponding DOORS attribute was found.
    So, for example, luxuryCount is equal to the number of DOORS elements that have Luxury Priority. If let’s say there are 5 Luxury Priority elements, 2 with Mandatory Priority, 2 important and 1 minor, the URL should be something like this:×100&chd=t:5,2,2,1&cht=p3&chl=luxury|mandatory|important|minor&chdl=5|2|2|1
    Please note that RPE can create this URL at runtime, depending on the variables value. So if you do not want to use a static URL, you can add the script that creates this URL, like in the example above.
    Also, it it also a good practice to test the URL in the browser. If it does not work in the browser, it will not work in RPE either.


    • Dominique Bontemps says:

      Thx for your reply.
      As you could see, I replaced the calculated variables from Doors by actual dummy integer values (7,8,5,10) in order to test the charting capability.
      Other fields under chl and chdl are just legend stuff.
      I also tested it in IE without any problem.
      So, must be something else…

  3. hategan.oana says:

    Do you use RPE 1.2 to generate the document?
    I copied the URL you posted in my RPE 1.2 template, and the image was generated.
    The only thing I had to do was to delete the ‘x’ character from the chs parameter (chs=600X200), and retype it again from my keyboard, because it was copied with a strange encoding.
    Can you please post the URL RPE is using to generate the template? You can see it in the console log, when RPE makes the request to obtain the chart image. I am guessing the url encoding for the ‘x’ character makes the url not usable in your case, too.

  4. hategan.oana says:

    I think wordpress did not render the ‘x’ character correctly in the blog post, so the problem appears when you use copy paste to copy the link from the web page to the RPE property editor.
    Please let me know if this solves your problem.

  5. Dominique Bontemps says:

    I checked with IBM and the issue was not in the URL but in the need of setting proxy under Preferences -> General -> Network connections.
    A generic chart is working. I’m now trying with actual data.
    Thx for this tip about Google chart!

  6. Enrique Lopesino says:


    Thank you so much for the explanation, may be this is obvious for the rest of the people but I tested it with no results until I initialize counter variables to “0”, then it worked

Leave a Reply