JFree Bar Chart Customization in iReport.. Category axis labels overlapping is removed.

HI Folks,

Today we are going to learn how to customize BarChart Category axis.

Credit of developing code goes to Mr. Sharad Sinha who is my colleague. As part of sharing knowledge I’m gonna explain the steps.  I’m starting with the problem statement followed by the solution.

Prerequisites :

iReport : 5.0.4

PostgreSQL : 9.2

Jasper Server : 5.0

Problem :

* We have a bar chart having many values to display on the chart .. i.e, let us say 100+

* This is not an XY Chart … simply it is Vertical Bar Chart.

* Bars are coming up properly BUT the labels on the category axis are overlapped and coming in a line. or when the angle is set up to -70 the labels are coming as clumsy as shown in figure below.

* The values which we want to show on the category axis are : dates like 1 Jan 2013 and the next label we want to show 8 Jan 2013 and etc..

* Here is the snapshot of the problem statement.



Our final out put should looks some thing like as follows.

What we have to do to get the above output?

We have to write Chart customizer class and have to call that class from iReport.

I’m going to explain step by step how to achieve this.


Read the points:

1.  Write chart customizer class java code in NetBeans.

2. Make a jar file.

3. Add that jar file in iReport as well in Jasper Server.

4. Call the class from the properties of Vertical Bar Chart in customizer class.


1.  Write chart customizer class java code in NetBeans.

package com.xyz.bar.chart.customizer;  //xyz is name of the company generally we give
import java.awt.Color;

import org.jfree.chart.axis.CategoryAxis;

import org.jfree.chart.axis.CategoryLabelPositions;

public class BarChartCustomizer




private Number tickUnits;
public BarChartCustomizer() {

tickUnits = Integer.valueOf(0);


public void customize(org.jfree.chart.JFreeChart chart, net.sf.jasperreports.engine.JRChart jasperChart) {

org.jfree.chart.renderer.category.BarRenderer renderer;

org.jfree.chart.plot.CategoryPlot plot;

org.jfree.chart.axis.NumberAxis rangeAxis;

org.jfree.chart.axis.CategoryAxis axis;

renderer = (org.jfree.chart.renderer.category.BarRenderer) chart.getCategoryPlot().getRenderer();


plot = chart.getCategoryPlot();

rangeAxis = (org.jfree.chart.axis.NumberAxis) plot.getRangeAxis();
axis = plot.getDomainAxis();
CategoryAxis domainAxis = plot.getDomainAxis();

CategoryLabelPositions pos = domainAxis.getCategoryLabelPositions();

for(int i=0; i< plot.getCategories().size()-1; i++)



String cat_Name = (String) plot.getCategories().get(i);



String cat_Names = (String) plot.getCategories().get(i);

domainAxis.setTickLabelPaint(cat_Names, Color.white);



// plot.getDomainAxis().setLabel(“TEST “+plot.getCategories().size()+”  “+pos.);



2. Make a jar file.

* Right click on the project and click on clean and build

* Net beans will automatically create jar file.

* Find this jar file in “dest” folder of your project.


3. Add that jar file in iReport as well in Jasper Server.

Location to place this jar files in Jasepr server.

C:\Program Files\jasperreports-server-5.0\apache-tomcat\webapps\jasperserver-pro\WEB-INF\lib

Location to call the jar files in iReport.

* On the menu bar go to

Tools –> Option –> iReport –>Class Path–> Add jar

* Select the location of jar file.


4. Call the class from the properties of Vertical Bar Chart in customizer class.
* High light the chart (bar chart in our case)  that you want to apply the customizer class.

* Go to properties (right side appears) —> go to customizer –> in the blank space write the classname including the package.

* For example in our case:

package com.xyz.bar.chart.customizer.BarChartCustomizer

That’s it we have done with the customization of the chart.


NOTE: after adding jar file to the server, you must restart your server otherwise you can’t see the effect of added jar file in our report

NOTE: Make sure to import necessary library files in Netbens while developing the plugin.

* Your imported library files (nothing but jars) should compatible with the files that your jasper server is using otherwise you will get minor/higher version related error when you run your report.

* Find the image below.

Thanks for reading document 🙂


Queries are welcome @ [email protected]

Helical IT Solutions (an Open source DWBI company providing services on Jaspersoft, Pentaho, Talend, Kettle, Data visualization) covered by a growing magazine.. Business for All

Helical Covered by Biz for All Magazine

Helical Covered by Biz for All Magazine



Among the many Information Technology startups, Helical IT Solutions, a Hyderabad based technology company providing services in open source data warehousing and business intelligence services, has been moving up the ladder with incredible pace and bagged a seed funding of INR 2.5 million from the Singapore based Citibank within six months of starting operations.


The company which started in Nov. 2012 has catered to the technology needs of clients in various domains including e-commerce, insurance, energy, social media analytics, healthcare and human resource while building and managing their Business Intelligence (BI) platforms.


The eight member strong team in Helical is quite excited with the fund inflow and plans to use it primarily for recruitment and partnering with leading BI vendors in the open source space such as Jaspersoft and Pentaho. “We want to focus and build up our capability of providing sector specific BI offering with this fund,” one of founders Nikhilesh Tiwari said. Specializing in Open source technologies, Helical has proved to be a great bet for its clients cutting down on their costs and adding to their efficiency and turnover. Their services include BI, ETL, Data warehousing and data modelling, data visualization to name a few. Helical IT Solutions is an open source Data warehousing and BI company based out of Hyderabad. The company works primarily on Jaspersoft and Pentaho BI suite and on talend, on Talend and Kettle. According to Gartner’s 2012 CIO survey, analytics and BI is the No. 1 technology priority for CIOs in 2012.



BI, analytics and PM software market was the second-fastest growing sector in the overall worldwide enterprise software market in 2011. “India is growing faster than any other country in BI sector in Asia Pacific with 36 per cent growth rate and the market for BI software in India is forecast to reach revenue of $81.5 million in 2012,” he said. Every 15 seconds, an open source BI s/w is downloaded and around 80 per cent of them need consultation and services as to how use them. With the angel investment, plans are underway to expand the team and hiring, develop infrastructure, SI partnership with Jaspersoft & Pentaho to get projects from even bigger clients and at a higher margin. “Building a parallel team after some time and start working towards building a product (we have energy domain, ecommerce domain primarily in mind),” he said about future plans. It is not that the company had walked a rosy path as due to lack of resources, they had to turn down many clients like Jabong.com, Mangaquest, Inspire edge IT solutions,  XiBoss.