Wednesday, November 25, 2009

Eclipse BIRT plugin - Chart scaling issue

Background:

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: https://bugs.eclipse.org/bugs/show_bug.cgi?id=296207

Workaround:

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.

<Scale>
<StepNumber>10</StepNumber>
</Scale>

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.

2 comments:

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.

Thanks
Kunal

Ashwini Verma said...

Great tip on chart scaling. Can you also submit a link to your article on BIRT Exchange devshare (http://www.birt-exchange.org/org/devshare/) so more BIRT developers can benefit from it?