Adjust alignment of label to right and fix label truncating issue in stacked bar chart

Softwares:

Jasper Server 5.6.0
IReport 5.6.0

Now we will see how to work on Lables Alignment and fix truncating in Stacked Bar Chart

First create a sample report which includes Stacked Bar Chart

Report Output in Jasper Server as follows

OriginalOutputt

Expected Output in Jasper Server as follows

ExpectedOutput

In order to achieve Expected Output,write custom code in java and include below lines of code:

For Label Alignment include below line

 plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

For avoid truncating Labels include below line

  categoryAxis.setMaximumCategoryLabelWidthRatio(3.0F);

Create jar file of the java code and add it in chart customiser property of chart in the format: ‘packagename.classname’ as follows:-
Refer the screenshot:

ChartCustomzeer

Publish the Report,and add the Jar for the Report which had published
Right Click on the Report –>Edit

EditJaar

Control Resources –>Add Resource–>Upload Jar

UploadJar

Give a valid name and then Submit

Execute the Report and output as follows

ExpectedResult

Thanks,
Satya Gopi,
BI Developer

Leave a Reply