Amazon festival offer

Monday, 8 September 2014

Add customizer class to remove Bar Gab between two series of Ba Chart

In This post I will see how to add a customizer class to remove space between two series of bar chart. 

Desired output after adding customizer class.

To get this output we have to create a executable jar file. Will use Netbeans to create .jar file.

Step 1:- Open NetBeans and create a new Java Application project.

Give a Project Name – customizerbargap   (you can give any other name also)
Here you can see the project location and class name, you can also change these parameters.
My Main class name CustomizerBarGap
and Finish

Copy below code in

package customizerbargap;

import net.sf.jasperreports.engine.JRAbstractChartCustomizer;
import net.sf.jasperreports.engine.JRChart;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.BarRenderer;

public class CustomizerBarGap extends JRAbstractChartCustomizer {

public void customize(JFreeChart chart, JRChart jasperChart) {

CategoryPlot categoryPlot = chart.getCategoryPlot();
BarRenderer renderer = (BarRenderer) categoryPlot.getRenderer();

//Spaces between bars

Add required jars in Library folder like Jfree.jar, Jcommon.jar, Jasperreports.jar
Right click on the project  and click on Clean and Build.
In output window you can find the path of .jar file

In my case it is –
Building jar: C:\Users\sharad\Documents\NetBeansProjects\Project_Name \dist\ Package_Name(CustomizerBarGap).jar

Open iReport and add CustomizerBarGap.jar in the Classpath.
To go add go to Tools --> Options --> ClassPath --> Click on Add JAR.

After adding .jar file click on the chart and go to Bar Chart - Properties section and set Customizer Class property to PackageName.ClassName  i.e.

Customizer Class =  customizerbargap.CustomizerBarGap

Then click on the Preview tab.

Saturday, 24 May 2014

How to install iReport in Linux machine

In this post you will see how to install iReport in Linux machine.

1:- First check out which version of iReport you want to install, to see the iReport versions you can use bellow link.
Now download iReport-5.5.1.tar.gz from bellow link 

2:- After downloading iReport go to the directory where you have downloaded it. In my case it is in Downloads directory.
$ cd /Downloads/
And if you want to copy in other directory you can use mv (move) or cp (copy) command.
$ mv/Downloads/ iReport-5.5.1.tar.gz     /opt/ iReport-5.5.1.tar.gz

3:- Extract iReport-5.5.1 directory from zipped file using bellow command.
$ tar -zxvf iReport-5.5.1.tar.gz

  1. -z : Work on gzip compression automatically when reading archives.
  2. -x : Extract archives.
  3. -v : Produce verbose output i.e. display progress and extracted file list on screen.
  4. -f : Read the archive from the archive to the specified file. In this example, read backups.tar.gz archive.
  5. -t : List the files in the archive.
4:- Now to start iReport open a terminal and type the bellow command.

$ /Downloads/iReport-5.5.1/bin/ireport

Now if your iReport starts that means you have successfully installed iReport.