March 26, 2015

How to add an ellipsis for Birt bar chart long labels not being displayed

I recently had to design a few reports using Birt.

Amongst some other newby problems, I had this one which I think is a Birt engine bug : when designing or rendering a bar char with long labels, the "ellipsis" thing doesn't work as expected and either the chart isn't displayed at all, or X axis labels aren't displayed.

To address this, you can use scripting to simply cut labels after a certain amount of characters and manually add ellipsis :

To do so, simply select your chart in the designer and switch to the Script tab. Then add the folowing code :

var cutLabel = "";

function afterDataSetFilled( series, dataSet, icsc ) {

 for (var i=0; i 20) {
   // cut the string after 20 chars and add ellipsis
   dataSet.getValues()[i] = value.substring(0,20) + "...";

function beforeDrawAxisTitle( axis, label, icsc ) {
 if( axis.isCategoryAxis() ){

Hope this helps !

No comments:

Post a Comment