An Oracle blog about BI Publisher

En-Gauging Output

One of the lesser known and probably even lesser used features we have provided is to support MSWord shape and clipart support ... you know those shapes you use mainly in Powerpoint but sometimes where a simple diagram is needed in Word or you want a goofy piece of clipart in your document.
Its a cool feature but how can you use it in a reporting context? Well the extension of the simple shape support is the ability to manipulate the shapes, you can dulplicate along x and y axes, stretch, skew, rotate, shrink and stretch them ... so what? Well you could think about building your own data visualizations using shapes to build up a 'chart' to represent the data. As an example I have picked on the 'hot' gauge or speedometer ... admittedly more of a BI type object but its a good illustration and will hopefully spark your interest to think of others.

Heres a fairly common sight in reports these days.


Normally requiring a charting engine to render this output ... you can use your RTF template ... you could even develop a set of objects that could be re-used across the organization.  

Getting in Shape

Apologies, a poor pun ... but you just need to put together a set of MSWord shapes, data enable them and bind them together as a 'group'. At runtime the shapes are then driven by the incoming data in the case of the gauge the amount of rotation of the arrow and the upper, middle and lower measures. In the attached RTF you can see the gauge object, just ungroup it to see how its made up. The only shapes that are manipulated are the arrow and the text areas for the measures and the grouped shape. We manipulate them by putting the controls into the Web tab of the image properties.

We're using the following XML for demo purposes here:

These are pretty well documented in the user guide but I'll explain as I go.

  1. Background 'ring', this is made up of 3 'donut' rings where I have reduced the angle using the yellow carat in MSWord and then colored and rotated them as appropriate to create the desired layout. You could of course play with this and used graduated shading from red to yellow to green or even just use a single half ring and shade it. No controls here, its just a static object.

  2. The arrow, this is an arrow drawn from the bottom center of the ring - this is important because we are going to rotate it and the engine needs to know about which point to rotate the image ie center- bottom. The code to drive the amount of rotation:

    <?shape-rotate:number(.) * 1.8;'c/b'?> 
     - shape-rotate is strangely enough the command to rotate the shape
     - number(.) * 1.8 - this the calculation to work out the rotation in degrees. You can see there is no element name '.' refers to the current element. 
    - c/b - is the shortened version of center/bottom ie the rotation point. Now you see how important it is to start the arrow from the bottom.

  3. The text boxes have some sample test but it is replaced at runtime with a minimum, mid and maximum value for the gauge.

     - low, mid and highVal variables are calculated earlier in the template to minimize processing

  4. Finally we have the command to repeat the entire shape down the page for as many members of the XML as are available ie 6. This command is added to the grouped properties, you need to group the members of the gauge, right click, Format Object.
    <?end for-each?>

    The for-each should be familiar, the at shape just tells the engine we're dealing with shapes and looping over the 'speed' group.
     - this offsets the shape along the y-axis ie down the page. The sneaky bit to ensure that we get a gauge at the position we placed it on the page is yo use the position()-1 expression. Position() returns the record number we are at, first record is 1 and so on. Without the '-1', setting the value to '0' we would not get the gauge showing in the position we initially set it on the template, it would immediately be offset by 150 pixels.

So thats the gauge, not that tough to do and with a little time you can build a much better looking gauge than I did but you get the idea. You could even just put in a background image of your choice so you get something more realistic.


Heres the sample and Happy Driving !

Join the discussion

Comments ( 4 )
  • Rajendran Tuesday, December 8, 2009
    Can i user this Speedometer chart in oracle forms. pl reply me.
  • Ernie Schindele Saturday, January 9, 2010
    You made some good points there. I did a search on the topic and found most people will agree with your blog.
  • Dary Hall Tuesday, April 27, 2010
    Really good post, this will help me a lot to get comments in my blog. Now I know why people do not comment in my blog.
  • Kenneth Waisman Sunday, September 26, 2010
    Well the dentist probably knows that we most likely don't brush our teeth for 2 minutes. 2 minutes everytime u brush is the reccomended time to REALLY prevent cavities. Most people only brush for 1 minute but that's not enough.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.