Wednesday, November 25, 2009

Eclipse BIRT plugin - Chart scaling issue


We are using Eclipse BIRT plugin 2.5.0 in our application. We encountered a strange issue with BIRT. As you would normally do, we set the scaling in our BIRT chart (in report design) to AUTO, so that BIRT can dynamically figure out the min/max and step size for the axis. It worked fine until we hit a corner case. I wanted to share my problem and the workaround I used to solve this problem so that it helps anyone having the same issue.

Problematic case:

In one of our cases, all the values for the axis were either 0 or less than 0. In this case, it was between 0 and -.02 and so when displayed in percent it was from 0 to -2%. In this case, BIRT chose the axis scale to be from 0 to -100% and so the chart got squeezed (since the entire range is only between 0 and -2%), making the chart unusable. This seems like a bug in BIRT. I've just filed a bug for this:


Aftering unsuccessfully googling for some time and searching for other alternatives, I tried setting the step number and that solved the problem. This made BIRT choose the proper min/max and enlarged my chart.

If you are in report designer, edit chart and go to Format chart tab (or right click on chart and select Format chart). Under Chart Area->Axis, select the axis and hit scale button. This will open "Axis Scale" window. Here instead of "Auto" select the "Step Number" radio button. Specify a number here (10, 15 etc.,) to indicate the number of steps in the axis. This should add the following to the xml source of chart in rptdesign.


This solved my problem. Note that this workaround maintains the dynamic nature and does not hard code the chart values. The min/max (and so the step size) values in the chart are still dynamic based on the values in the chart.


kunal ahuja said...

Hi Raja,

Post was informative. But when I hit the scale button. A window pops up and I cannot seem to change values there.

Appreciate Help.


Ashwini Verma said...

Great tip on chart scaling. Can you also submit a link to your article on BIRT Exchange devshare ( so more BIRT developers can benefit from it?